Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-39481: WIP: PEP 585 #18239
bpo-39481: WIP: PEP 585 #18239
Conversation
}; | ||
|
||
static PyMemberDef ga_members[] = { | ||
{"__origin__", T_OBJECT, offsetof(gaobject, origin), READONLY}, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gvanrossum
Jan 28, 2020
Author
Member
I think not. The two attributes should never be allowed to be NULL. (This is a change from an earlier design.)
static PyObject * | ||
ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | ||
{ | ||
if (kwds != NULL) { |
This comment has been minimized.
This comment has been minimized.
serhiy-storchaka
Jan 28, 2020
Member
It is worth to use Argument Clinic which generates simpler code using non-public C API similar to the following:
if (!_PyArg_NoKeywords("GenericAlias", kwds) ||
!_PyArg_CheckPositional("GenericAlias", PyTuple_GET_SIZE(args), 2, 2))
{
return NULL;
}
}; | ||
|
||
static PyObject * | ||
ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gvanrossum
Jan 28, 2020
Author
Member
I first had a tp_init. Then calling GenericAlias() somehow worked and produced an object with NULL attributes (or maybe it was some more clever incantation, I forget, but I definitely saw it). I do want the class instantiable from Python (so it can potentially be used from typing.py). Using tp_new instead solved that problem.
This comment has been minimized.
This comment has been minimized.
So I'm looking into the test failures. I've fixed two simple ones, but now I'm stuck with at least two:
The problem with test_typing.py is that when we have a class that derives from
its MRO contains |
This comment has been minimized.
This comment has been minimized.
Using a debug build I can repro the test_genericalias.py crash. The upper few lines of the stack trace are:
@ethanhs does this give you a clue? Methinks there's a refcount bug in ga_repr(). :-( |
gvanrossum commentedJan 28, 2020
•
edited by bedevere-bot
https://bugs.python.org/issue39481