We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contactedHave 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
| Expand Up | @@ -677,21 +677,43 @@ def test_heaptype_with_custom_metaclass(self): | |
|
|
||
| def test_multiple_inheritance_ctypes_with_weakref_or_dict(self): | ||
|
|
||
| class Both1(_testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithDict): | ||
| with self.assertRaises(TypeError): | ||
| class Both1(_testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithDict): | ||
| pass | ||
| with self.assertRaises(TypeError): | ||
| class Both2(_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithWeakref): | ||
| pass | ||
|
|
||
| def test_multiple_inheritance_ctypes_with_weakref_or_dict_and_other_builtin(self): | ||
|
|
||
| with self.assertRaises(TypeError): | ||
| class C1(_testcapi.HeapCTypeWithDict, list): | ||
| pass | ||
|
|
||
| with self.assertRaises(TypeError): | ||
| class C2(_testcapi.HeapCTypeWithWeakref, list): | ||
| pass | ||
|
|
||
| class C3(_testcapi.HeapCTypeWithManagedDict, list): | ||
| pass | ||
| class Both2(_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithWeakref): | ||
| class C4(_testcapi.HeapCTypeWithManagedWeakref, list): | ||
| pass | ||
|
|
||
| for cls in (_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithDict2, | ||
| _testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithWeakref2): | ||
| for cls2 in (_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithDict2, | ||
| _testcapi.HeapCTypeWithWeakref, _testcapi.HeapCTypeWithWeakref2): | ||
| if cls is not cls2: | ||
| class S(cls, cls2): | ||
| pass | ||
| class B1(Both1, cls): | ||
| inst = C3() | ||
| inst.append(0) | ||
| str(inst.__dict__) | ||
|
|
||
| inst = C4() | ||
| inst.append(0) | ||
| str(inst.__weakref__) | ||
|
|
||
| for cls in (_testcapi.HeapCTypeWithManagedDict, _testcapi.HeapCTypeWithManagedWeakref): | ||
| for cls2 in (_testcapi.HeapCTypeWithDict, _testcapi.HeapCTypeWithWeakref): | ||
| class S(cls, cls2): | ||
| pass | ||
| class B1(C3, cls): | ||
| pass | ||
| class B2(Both1, cls): | ||
| class B2(C4, cls): | ||
| pass | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentShould we also assert that the mro of these classes looks correct?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentThis won't change the mro. That's determined by the C3 algorithm. https://en.wikipedia.org/wiki/C3_linearization
Sorry, something went wrong.
All reactions
|
||
|
|
||
| def test_pytype_fromspec_with_repeated_slots(self): | ||
| Expand Down | ||
| @@ -0,0 +1,4 @@ | ||
| Extensions classes that set ``tp_dictoffset`` and ``tp_weaklistoffset`` | ||
| lose the support for multiple inheritance, but are now safe. Extension | ||
| classes should use :const:`Py_TPFLAGS_MANAGED_DICT` and | ||
| :const:`Py_TPFLAGS_MANAGED_WEAKREF` instead. |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentShould the extension docs be updated to provide examples of using the new API? (Probably as a separate PR...)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide commentYes, they should. I also plan to add a new file documenting the new object layout.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.