-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
docs: fix dangling tp_alloc [bug] in extending/newtypes_tutorial
#24283
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
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
|
This PR is stale because it has been open for 30 days with no activity. |
|
Ping |
|
This PR is stale because it has been open for 30 days with no activity. |
|
@vstinner @serhiy-storchaka maybe you could take a look? |
Please elaborate. I don't understand which problem you are trying to solve. |
|
The CPython API docs currently effectively suggest |
tp_alloc(type, 0) doesn't call malloc(). The default allocator function is PyType_GenericAlloc() which uses: which is defined as: tp_alloc(type, 0) allocates types->tp_basicsize. In the tutorial, tp_basicsize is defined as: In short, IMO the current code is correct, and your change wastes memory. |
|
Hmm |
- `tp_alloc(T, n)` should allocation `n + 1` items python/cpython#24283 (comment)
Open an issue at https://bugs.python.org/ in this case. In the meanwhile, I close your PR. |
- `tp_alloc(T, n)` should allocate `n + 1` items python/cpython#24283 (comment)
Fixes a pretty major malloc error in the docs.