-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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-41073: PyType_GetSlot() can now accept static types. #21931
bpo-41073: PyType_GetSlot() can now accept static types. #21931
Conversation
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.
Can you also test getting Py_nb_add
and Py_mp_length
from PyLong_Type
?
That will expose the reason this is complicated: static types don't have the sub-slots structs allocated as part of the type.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
sure. Let me try it. |
the |
Right. The offsetoff is done for Static types, You could record which sub-slots table each slot belongs to, in a similar table as |
Hi petr. Do we have developers to get sub-slots of static types by |
requested changes; please review again. |
@vstinner Hi, victor. Do you have some suggestions about this PR? |
Sorry, I do not understand what the recent changes are supposed to do. |
Ok, copy that. I will try to add some tests to against this function.
This is a problem. Can we add a new function something like |
@encukou Hi, petr. I updated this PR and add some testcases. Pls take a look again when you have free time. |
…lots1 * origin/master: (63 commits) bpo-41627: Distinguish 32 and 64-bit user site packages on Windows (pythonGH-22098) bpo-38585: Remove references to defusedexpat (pythonGH-22095) bpo-41721: Add xlc options (pythonGH-22096) bpo-40486: Specify what happens if directory content change diring iteration (pythonGH-22025) bpo-41638: Improve ProgrammingError message for absent parameter. (pythonGH-21999) bpo-41713: _signal doesn't use multi-phase init (pythonGH-22087) bpo-41700: Skip test if the locale is not supported (pythonGH-22081) [doc] Update documentation on logging optimization. (pythonGH-22075) Fix 'gather' rules in the python parser generator (pythonGH-22021) bpo-41697: Correctly handle KeywordOrStarred when parsing arguments in the parser (pythonGH-22077) [doc] Fix a typo in the graphlib docs (python#22030) bpo-1635741: Port _signal module to multi-phase init (PEP 489) (pythonGH-22049) bpo-39883: Use BSD0 license for code in docs (pythonGH-17635) bpo-39010: Improve test shutdown (python#22066) bpo-41696: Fix handling of debug mode in asyncio.run (python#22069) bpo-41690: Use a loop to collect args in the parser instead of recursion (pythonGH-22053) closes bpo-41689: Preserve text signature from tp_doc in C heap type creation. (pythonGH-22058) Fix invalid escape sequences in the peg_highlight Sphinx extension (pythonGH-22047) bpo-41675: Modernize siginterrupt calls (pythonGH-22028) bpo-41685: Don't pin setuptools version anymore in Doc/Makefile (pythonGH-22062) ...
I think this PR is getting more and more complicated, without getting closer to solving the issue. I think the issue can be solved like this: For each slot, record two pieces of information:
The one-number entries currently in Given this info,
That way, there would be no need for new constants for type slots, or a new function specific to static types. |
Thanks for your blueprint, petr. Let me consider it again : ) |
C asserts are removed in non-debug builds.
This is how most of the table is formatted. Fix a few lines around the one added.
IMO, things are more easier to follow this way (combined with the comment added to pyslot_offsets).
This way the table will be kept in sync if a slot is removed (which shouldn't happen).
Hi, |
Hi, petr. You are the co-author, so you can go ahead ;) |
Lib/test/test_capi.py
Outdated
@@ -544,6 +544,10 @@ def test_pynumber_tobase(self): | |||
self.assertRaises(TypeError, pynumber_tobase, '123', 10) | |||
self.assertRaises(SystemError, pynumber_tobase, 123, 0) | |||
|
|||
def test_get_statictype_slots(self): | |||
from _testcapi import test_get_statictype_slots |
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.
Why do we need add this testcase in python level? Test_testcapi will take care of it:)
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.
Ah, you're right!
…lots1 * origin/master: (80 commits) bpo-42282: Fold constants inside named expressions (pythonGH-23190) bpo-41028: Doc: Move switchers to docsbuild-scripts. (pythonGH-20969) bpo-42133: update parts of the stdlib to fall back to `__spec__.loader` when `__loader__` is missing (python#22929) Remove outdated reference to pywin32 from platform module (pythonGH-22005) bpo-41832: PyType_FromModuleAndSpec() now accepts NULL tp_doc (pythonGH-23123) Minor grammar edits for the descriptor howto guide (GH-python#23175) bpo-42179: Doc/tutorial: Remove mention of __cause__ (pythonGH-23162) bpo-26389: Allow passing an exception object in the traceback module (pythonGH-22610) bpo-42260: PyConfig_Read() only parses argv once (pythonGH-23168) bpo-42260: Add _PyConfig_FromDict() (pythonGH-23167) bpo-41877 Check for asert, aseert, assrt in mocks (pythonGH-23165) [docs] fix wrongly named AsyncContextDecorator (pythonGH-23164) bpo-42262: Add Py_NewRef() and Py_XNewRef() (pythonGH-23152) bpo-42266: Handle monkey-patching descriptors in LOAD_ATTR cache (pythonGH-23157) bpo-40816 Add AsyncContextDecorator class (pythonGH-20516) bpo-42260: Add _PyInterpreterState_SetConfig() (pythonGH-23158) Disable peg generator tests when building with PGO (pythonGH-23141) bpo-1635741: _sqlite3 uses PyModule_AddObjectRef() (pythonGH-23148) bpo-1635741: Fix PyInit_pyexpat() error handling (pythonGH-22489) bpo-42260: Main init modify sys.flags in-place (pythonGH-23150) ...
@shihai1991: Status check is done, and it's a success ✅ . |
And there it is! Thank you for the effort, Hai Shi! |
Thanks for your guide, petr. Learned much in this PR ;) |
PyType_GetSlot() can now accept static types.
Co-Authored-By: Petr Viktorin encukou@gmail.com
https://bugs.python.org/issue41073
Automerge-Triggered-By: GH:encukou