Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Include/internal/pycore_fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ extern void _Py_skiproot(const wchar_t *path, Py_ssize_t size, Py_ssize_t *drvsi
// Export for 'select' shared extension (Argument Clinic code)
PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *);

#ifdef MS_WINDOWS
/* Windows uses long long for offsets */
typedef long long Py_off_t;
#else
typedef off_t Py_off_t;
#endif

// Export for '_ssl' and 'zlib' shared extensions (Argument Clinic code)
PyAPI_FUNC(int) _Py_Off_t_Converter(PyObject *, void *);

// Export for test_peg_generator
PyAPI_FUNC(char*) _Py_UniversalNewlineFgetsWithSize(char *, int, FILE*, PyObject *, size_t*);

Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3561,18 +3561,23 @@ def test_cli_converters(self):
""")
expected_converters = (
"bool",
"BOOL",
"byte",
"char",
"defining_class",
"double",
"DWORD",
"fildes",
"float",
"HANDLE",
"int",
"long",
"long_long",
"object",
"pid_t",
"Py_buffer",
"Py_complex",
"Py_off_t",
"Py_ssize_t",
"Py_UNICODE",
"PyByteArrayObject",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Argument Clinic: the ``pid_t``, ``Py_off_t``, ``HANDLE``, ``DWORD`` and
``BOOL`` converters, previously defined in 9 different files, are now
provided by Argument Clinic itself.
4 changes: 1 addition & 3 deletions Modules/_io/_iomodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "exports.h"

#include "pycore_fileutils.h" // Py_off_t
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_typeobject.h" // _PyType_GetModuleState()
#include "structmember.h"
Expand Down Expand Up @@ -94,8 +95,6 @@ extern int _PyIO_trap_eintr(void);

#ifdef MS_WINDOWS

/* Windows uses long long for offsets */
typedef long long Py_off_t;
# define PyLong_AsOff_t PyLong_AsLongLong
# define PyLong_FromOff_t PyLong_FromLongLong
# define PY_OFF_T_MAX LLONG_MAX
Expand All @@ -106,7 +105,6 @@ typedef long long Py_off_t;
#else

/* Other platforms use off_t */
typedef off_t Py_off_t;
#if (SIZEOF_OFF_T == SIZEOF_SIZE_T)
# define PyLong_AsOff_t PyLong_AsSsize_t
# define PyLong_FromOff_t PyLong_FromSsize_t
Expand Down
16 changes: 0 additions & 16 deletions Modules/_multiprocessing/multiprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@

#include "multiprocessing.h"

/*[python input]
class HANDLE_converter(CConverter):
type = "HANDLE"
format_unit = '"F_HANDLE"'

def parse_arg(self, argname, displayname, *, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
goto exit;
}}}}
""",
argname=argname)

[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=3cf0318efc6a8772]*/

/*[clinic input]
module _multiprocessing
Expand Down
16 changes: 0 additions & 16 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ module _posixsubprocess
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c62211df27cf7334]*/

/*[python input]
class pid_t_converter(CConverter):
type = 'pid_t'
format_unit = '" _Py_PARSE_PID "'

def parse_arg(self, argname, displayname, *, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsPid({argname});
if ({paramname} == -1 && PyErr_Occurred()) {{{{
goto exit;
}}}}
""",
argname=argname)
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=c94349aa1aad151d]*/

#include "clinic/_posixsubprocess.c.h"

/* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */
Expand Down
42 changes: 21 additions & 21 deletions Modules/_remote_debugging/clinic/module.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions Modules/_remote_debugging/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class _remote_debugging.RemoteUnwinder "RemoteUnwinderObject *" "&RemoteUnwinder
/*[clinic input]
@permit_long_summary
_remote_debugging.RemoteUnwinder.__init__
pid: int
pid: pid_t
*
all_threads: bool = False
only_active_thread: bool = False
Expand Down Expand Up @@ -334,14 +334,14 @@ other runtime data.

static int
_remote_debugging_RemoteUnwinder___init___impl(RemoteUnwinderObject *self,
int pid, int all_threads,
pid_t pid, int all_threads,
int only_active_thread,
int mode, int debug,
int skip_non_matching_threads,
int native, int gc,
int opcodes, int cache_frames,
int stats)
/*[clinic end generated code: output=0031f743f4b9ad52 input=9d25ae328d62626d]*/
/*[clinic end generated code: output=acfe554c8a92cf6b input=3b5a5ad153709125]*/
{
// Validate that all_threads and only_active_thread are not both True
if (all_threads && only_active_thread) {
Expand Down Expand Up @@ -1376,7 +1376,7 @@ cleanup_runtime_offsets(RuntimeOffsets *offsets)
}

static int
init_runtime_offsets(RuntimeOffsets *offsets, int pid, int debug)
init_runtime_offsets(RuntimeOffsets *offsets, pid_t pid, int debug)
{
offsets->debug = debug;
if (_Py_RemoteDebug_InitProcHandle(&offsets->handle, pid) < 0) {
Expand Down Expand Up @@ -1414,7 +1414,7 @@ class _remote_debugging.GCMonitor "GCMonitorObject *" "&GCMonitor_Type"
/*[clinic input]
@permit_long_summary
_remote_debugging.GCMonitor.__init__
pid: int
pid: pid_t
*
debug: bool = False

Expand All @@ -1437,9 +1437,9 @@ a running Python process.
[clinic start generated code]*/

static int
_remote_debugging_GCMonitor___init___impl(GCMonitorObject *self, int pid,
_remote_debugging_GCMonitor___init___impl(GCMonitorObject *self, pid_t pid,
int debug)
/*[clinic end generated code: output=2cdf351c2f6335db input=03da0b2d3282ae1b]*/
/*[clinic end generated code: output=03b4c92bef0673ad input=dcc6ee2ec5a16fa1]*/
{
return init_runtime_offsets(&self->offsets, pid, debug);
}
Expand Down Expand Up @@ -2226,7 +2226,7 @@ _remote_debugging_zstd_available_impl(PyObject *module)
/*[clinic input]
_remote_debugging.get_child_pids

pid: int
pid: pid_t
Process ID of the parent process
*
recursive: bool = True
Expand All @@ -2248,24 +2248,24 @@ list is returned.
[clinic start generated code]*/

static PyObject *
_remote_debugging_get_child_pids_impl(PyObject *module, int pid,
_remote_debugging_get_child_pids_impl(PyObject *module, pid_t pid,
int recursive)
/*[clinic end generated code: output=1ae2289c6b953e4b input=c6437b52e2fdd880]*/
/*[clinic end generated code: output=fa3dfd1b02eed29b input=3325d95e9f39d75d]*/
{
return enumerate_child_pids((pid_t)pid, recursive);
return enumerate_child_pids(pid, recursive);
}

/*[clinic input]
_remote_debugging.is_python_process

pid: int
pid: pid_t

Check if a process is a Python process.
[clinic start generated code]*/

static PyObject *
_remote_debugging_is_python_process_impl(PyObject *module, int pid)
/*[clinic end generated code: output=22947dc8afcac362 input=13488e28c7295d84]*/
_remote_debugging_is_python_process_impl(PyObject *module, pid_t pid)
/*[clinic end generated code: output=63541478c889e536 input=ff998fef4aeef433]*/
{
proc_handle_t handle;

Expand All @@ -2288,7 +2288,7 @@ _remote_debugging_is_python_process_impl(PyObject *module, int pid)
/*[clinic input]
_remote_debugging.get_gc_stats

pid: int
pid: pid_t
*
all_interpreters: bool = False
If True, return GC statistics from all interpreters.
Expand All @@ -2314,9 +2314,9 @@ Get garbage collector statistics from external Python process.
[clinic start generated code]*/

static PyObject *
_remote_debugging_get_gc_stats_impl(PyObject *module, int pid,
_remote_debugging_get_gc_stats_impl(PyObject *module, pid_t pid,
int all_interpreters)
/*[clinic end generated code: output=d9dce5f7add149bb input=a2a08a45a8f0b119]*/
/*[clinic end generated code: output=dd33199ccb6a56e9 input=41399e77788aa369]*/
{
RuntimeOffsets offsets;
if (init_runtime_offsets(&offsets, pid, /*debug=*/1) < 0) {
Expand Down
Loading
Loading