-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
bpo-31333: Re-implement ABCMeta in C #5273
Changes from 1 commit
5c34508
cb7ffcf
b83ee80
181e83f
c084a7f
a192d5d
35a2472
4812450
b9038e2
bbee578
a3464fd
947bf7d
7ffc59e
41287a7
569cc44
34665a8
576acac
30098b4
51ede5d
5263e1a
1f7aee9
11fea70
7ff3fbb
9b4eb2f
ab20a33
39f2692
493d0ec
2fe2c54
9476af6
ab68cdb
3eb0a60
ed36b76
25fc5b9
b2f75b9
cdb5cdf
a1a3a52
a66b08c
86af9ae
b22232a
e51c5ca
bac7a43
4571649
0d7513b
c429f49
357b56d
cd80fcb
34e13c3
c5633b6
3cbbc12
23bcb07
0aab479
86e0660
c55e482
5f9526a
8174b61
bb8d623
ef59e54
22699fe
95cbf34
4d596cc
fa3cba3
6f18293
9100891
36c5643
dd2abda
99d950c
3762d49
404d1ce
0dc5fae
287b26a
ef34364
d4d78a1
f58822e
3b74bdc
db1c852
6e62be7
5384726
a48eecc
16a8db1
5ad3ea8
86a9b8d
36c2013
09c5370
207d8e9
a15377b
d31da13
eaff1cb
48de70e
3bd0666
702347a
e0c978b
b370dfe
a1ae0a7
4746211
001b416
fc528df
289c414
ac0c639
079e3be
9c49e5a
4146588
c133605
f82e04d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,8 +97,16 @@ abcmeta_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |
(It is safe to assume everything is fine since type.__new__ succeeded.) */ | ||
ns = PyTuple_GET_ITEM(args, 2); | ||
items = PyMapping_Items(ns); /* TODO: Fast path for exact dicts with PyDict_Next */ | ||
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. This could be null if ns is a subclass of dict that overwrites the items method to raise an error or return a non-iterable |
||
if (!items) { | ||
Py_DECREF(result); | ||
return NULL; | ||
} | ||
for (pos = 0; pos < PySequence_Size(items); pos++) { | ||
item = PySequence_GetItem(items, pos); | ||
if (!PyTuple_Check(item) || (PyTuple_GET_SIZE(item) != 2)) { | ||
PyErr_SetString(PyExc_TypeError, "Iteration over class namespace must" | ||
" yield length-two tuples"); | ||
} | ||
key = PyTuple_GetItem(item, 0); | ||
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. item isn't necessarily a tuple, for example in
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. Furthermore, item could be a empty tuple or 1-tuple, meaning that key and/or value could be null, which again needs to be checked for. |
||
value = PyTuple_GetItem(item, 1); | ||
int is_abstract = _PyObject_IsAbstract(value); | ||
|
@@ -158,6 +166,9 @@ abcmeta_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |
Py_DECREF(key); | ||
} | ||
Py_DECREF(iter); | ||
if (PyErr_Occurred()) { | ||
goto error; | ||
} | ||
} | ||
if (_PyObject_SetAttrId((PyObject *)result, &PyId___abstractmethods__, abstracts) < 0) { | ||
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. Doesn't this cause a change in behavior; |
||
goto error; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer accurate