Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76ba4b6

Browse files
Merge branch 'master' into disable-wchar-cache
2 parents 8a9259b + d878349 commit 76ba4b6

3 files changed

Lines changed: 177 additions & 48 deletions

File tree

Modules/_ctypes/callproc.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,18 +1308,14 @@ static PyObject *load_library(PyObject *self, PyObject *args)
13081308
if (!PyArg_ParseTuple(args, "U|i:LoadLibrary", &nameobj, &load_flags))
13091309
return NULL;
13101310

1311-
#if USE_UNICODE_WCHAR_CACHE
1312-
const WCHAR *name = _PyUnicode_AsUnicode(nameobj);
1313-
#else /* USE_UNICODE_WCHAR_CACHE */
1314-
WCHAR *name = PyUnicode_AsWideCharString(nameobj, NULL);
1315-
#endif /* USE_UNICODE_WCHAR_CACHE */
1316-
if (!name)
1317-
return NULL;
1318-
13191311
if (PySys_Audit("ctypes.dlopen", "O", nameobj) < 0) {
13201312
return NULL;
13211313
}
13221314

1315+
WCHAR *name = PyUnicode_AsWideCharString(nameobj, NULL);
1316+
if (!name)
1317+
return NULL;
1318+
13231319
Py_BEGIN_ALLOW_THREADS
13241320
/* bpo-36085: Limit DLL search directories to avoid pre-loading
13251321
* attacks and enable use of the AddDllDirectory function.
@@ -1328,9 +1324,7 @@ static PyObject *load_library(PyObject *self, PyObject *args)
13281324
err = hMod ? 0 : GetLastError();
13291325
Py_END_ALLOW_THREADS
13301326

1331-
#if !USE_UNICODE_WCHAR_CACHE
13321327
PyMem_Free(name);
1333-
#endif /* USE_UNICODE_WCHAR_CACHE */
13341328
if (err == ERROR_MOD_NOT_FOUND) {
13351329
PyErr_Format(PyExc_FileNotFoundError,
13361330
("Could not find module '%.500S' (or one of its "

Objects/clinic/codeobject.c.h

Lines changed: 137 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/codeobject.c

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -442,46 +442,45 @@ validate_and_copy_tuple(PyObject *tup)
442442
return newtuple;
443443
}
444444

445-
PyDoc_STRVAR(code_doc,
446-
"code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n\
447-
flags, codestring, constants, names, varnames, filename, name,\n\
448-
firstlineno, lnotab[, freevars[, cellvars]])\n\
449-
\n\
450-
Create a code object. Not for the faint of heart.");
445+
/*[clinic input]
446+
@classmethod
447+
code.__new__ as code_new
448+
449+
argcount: int
450+
posonlyargcount: int
451+
kwonlyargcount: int
452+
nlocals: int
453+
stacksize: int
454+
flags: int
455+
codestring as code: object(subclass_of="&PyBytes_Type")
456+
constants as consts: object(subclass_of="&PyTuple_Type")
457+
names: object(subclass_of="&PyTuple_Type")
458+
varnames: object(subclass_of="&PyTuple_Type")
459+
filename: unicode
460+
name: unicode
461+
firstlineno: int
462+
lnotab: object(subclass_of="&PyBytes_Type")
463+
freevars: object(subclass_of="&PyTuple_Type", c_default="NULL") = ()
464+
cellvars: object(subclass_of="&PyTuple_Type", c_default="NULL") = ()
465+
/
466+
467+
Create a code object. Not for the faint of heart.
468+
[clinic start generated code]*/
451469

452470
static PyObject *
453-
code_new(PyTypeObject *type, PyObject *args, PyObject *kw)
471+
code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
472+
int kwonlyargcount, int nlocals, int stacksize, int flags,
473+
PyObject *code, PyObject *consts, PyObject *names,
474+
PyObject *varnames, PyObject *filename, PyObject *name,
475+
int firstlineno, PyObject *lnotab, PyObject *freevars,
476+
PyObject *cellvars)
477+
/*[clinic end generated code: output=612aac5395830184 input=85e678ea4178f234]*/
454478
{
455-
int argcount;
456-
int posonlyargcount;
457-
int kwonlyargcount;
458-
int nlocals;
459-
int stacksize;
460-
int flags;
461479
PyObject *co = NULL;
462-
PyObject *code;
463-
PyObject *consts;
464-
PyObject *names, *ournames = NULL;
465-
PyObject *varnames, *ourvarnames = NULL;
466-
PyObject *freevars = NULL, *ourfreevars = NULL;
467-
PyObject *cellvars = NULL, *ourcellvars = NULL;
468-
PyObject *filename;
469-
PyObject *name;
470-
int firstlineno;
471-
PyObject *lnotab;
472-
473-
if (!PyArg_ParseTuple(args, "iiiiiiSO!O!O!UUiS|O!O!:code",
474-
&argcount, &posonlyargcount, &kwonlyargcount,
475-
&nlocals, &stacksize, &flags,
476-
&code,
477-
&PyTuple_Type, &consts,
478-
&PyTuple_Type, &names,
479-
&PyTuple_Type, &varnames,
480-
&filename, &name,
481-
&firstlineno, &lnotab,
482-
&PyTuple_Type, &freevars,
483-
&PyTuple_Type, &cellvars))
484-
return NULL;
480+
PyObject *ournames = NULL;
481+
PyObject *ourvarnames = NULL;
482+
PyObject *ourfreevars = NULL;
483+
PyObject *ourcellvars = NULL;
485484

486485
if (PySys_Audit("code.__new__", "OOOiiiiii",
487486
code, filename, name, argcount, posonlyargcount,
@@ -963,7 +962,7 @@ PyTypeObject PyCode_Type = {
963962
0, /* tp_setattro */
964963
0, /* tp_as_buffer */
965964
Py_TPFLAGS_DEFAULT, /* tp_flags */
966-
code_doc, /* tp_doc */
965+
code_new__doc__, /* tp_doc */
967966
0, /* tp_traverse */
968967
0, /* tp_clear */
969968
code_richcompare, /* tp_richcompare */

0 commit comments

Comments
 (0)