-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and typing #23060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2c4a297
588d421
050fa13
f60ea8a
2f3c6dc
2c4508e
19d2973
3116c8e
f2b593a
93d51e4
327e1a5
e971ccb
abd8b98
3ddca06
1ab59c5
ee2d2e1
2015738
6704ffd
598d29b
c43ebcf
37ae3a9
adbfcad
d1dd627
2c21045
9f71667
a789620
1890b37
4e928c6
6b11d33
4215c3b
585bf19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…ericAlias
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -567,15 +567,38 @@ static PyGetSetDef ga_properties[] = { | |
static PyObject * | ||
ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | ||
{ | ||
gaobject *self; | ||
Fidget-Spinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
assert(type != NULL && type->tp_alloc != NULL); | ||
Fidget-Spinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self = (gaobject *)type->tp_alloc(type, 0); | ||
if (self == NULL) | ||
return NULL; | ||
|
||
if (!_PyArg_NoKwnames("GenericAlias", kwds)) { | ||
return NULL; | ||
} | ||
if (!_PyArg_CheckPositional("GenericAlias", PyTuple_GET_SIZE(args), 2, 2)) { | ||
return NULL; | ||
} | ||
PyObject *origin = PyTuple_GET_ITEM(args, 0); | ||
PyObject *origin = PyTuple_GET_ITEM(args, 0); | ||
PyObject *arguments = PyTuple_GET_ITEM(args, 1); | ||
return Py_GenericAlias(origin, arguments); | ||
|
||
// almost the same as Py_GenericAlias' code, but to assign to self | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd refactor this to avoid so much code duplication. Also, I'm sorry, I have forgotten this detail myself, I wonder what the difference is between what tp_alloc calls (PyType_GenericAlloc) and what Py_GenericAlias calls (PyObject_GC_New). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, from what I can see PyType_GenericAlloc calls _PyObject_GC_Malloc if Py_TPFLAGS_HAVE_GC flag is set, else it will call PyObject_MALLOC. While PyObject_GC_New calls _PyObject_GC_Malloc all the time. So it should be okay to replace one with another since that flag is set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally when calling |
||
if (!PyTuple_Check(arguments)) { | ||
arguments = PyTuple_Pack(1, arguments); | ||
if (arguments == NULL) { | ||
return NULL; | ||
} | ||
} | ||
else { | ||
Py_INCREF(arguments); | ||
} | ||
|
||
Py_INCREF(origin); | ||
self->origin = origin; | ||
self->args = arguments; | ||
self->parameters = NULL; | ||
return (PyObject *) self; | ||
} | ||
|
||
static PyNumberMethods ga_as_number = { | ||
|
@@ -600,7 +623,7 @@ PyTypeObject Py_GenericAliasType = { | |
.tp_hash = ga_hash, | ||
.tp_call = ga_call, | ||
.tp_getattro = ga_getattro, | ||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, | ||
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, | ||
.tp_traverse = ga_traverse, | ||
.tp_richcompare = ga_richcompare, | ||
.tp_weaklistoffset = offsetof(gaobject, weakreflist), | ||
|
Uh oh!
There was an error while loading. Please reload this page.