René's URL Explorer Experiment


Title: bpo-26868: Fix example usage of PyModule_AddObject. by brandtbucher · Pull Request #15725 · python/cpython · GitHub

Open Graph Title: bpo-26868: Fix example usage of PyModule_AddObject. by brandtbucher · Pull Request #15725 · python/cpython

X Title: bpo-26868: Fix example usage of PyModule_AddObject. by brandtbucher · Pull Request #15725 · python/cpython

Description: Unlike other APIs that steal references, PyModule_AddObject only does it on success. However, most calls throughout the codebase don't manually Py_DECREF on failure as required by the implementation, which leads contributors to believe that it is not necessary. This PR fixes example usage and adds a note on this behavior in the documentation only. There are over 200 bad calls throughout the codebase that are not addressed by this patch. Because there are so many bugs, fixing them all will likely require more care and likely several PRs (or a possible deprecation period and behavior change... it appears incorrect usage is actually more common than correct usage). I'm willing to do the work, but some direction on this would be nice. https://bugs.python.org/issue26868

Open Graph Description: Unlike other APIs that steal references, PyModule_AddObject only does it on success. However, most calls throughout the codebase don't manually Py_DECREF on failure as required by the implement...

X Description: Unlike other APIs that steal references, PyModule_AddObject only does it on success. However, most calls throughout the codebase don't manually Py_DECREF on failure as required by the imple...

Opengraph URL: https://github.com/python/cpython/pull/15725

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:01cd8076-b6e2-245d-41d1-4d5252686537
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8EC6:3367C0:4101F:5BDE6:6A548C9B
html-safe-noncee95fdf83483f0ab8b9acd74c461a70f0377b3bfc07349be2fd4e6f93af97ef4a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUM2OjMzNjdDMDo0MTAxRjo1QkRFNjo2QTU0OEM5QiIsInZpc2l0b3JfaWQiOiI5MTk3MjE2NTY4Mjc0MzU3NDAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac46e3c1761a1eb796f8e8521bcef73a5ae8a9de9e79cd4646e4f7d7de8b54f48e
hovercard-subject-tagpull_request:315205555
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/15725/files
twitter:imagehttps://avatars.githubusercontent.com/u/40968415?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40968415?s=400&v=4
og:image:altUnlike other APIs that steal references, PyModule_AddObject only does it on success. However, most calls throughout the codebase don't manually Py_DECREF on failure as required by the implement...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release03ccb116376fd46e8ba2a4cdc541e35f13f70734
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/15725/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F15725%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F15725%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/15725/files
Reloadhttps://github.com/python/cpython/pull/15725/files
Reloadhttps://github.com/python/cpython/pull/15725/files
Please reload this pagehttps://github.com/python/cpython/pull/15725/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/15725/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
matrixisehttps://github.com/matrixise
python:masterhttps://github.com/python/cpython/tree/master
brandtbucher:safe-add-objecthttps://github.com/brandtbucher/cpython/tree/safe-add-object
Conversation 28 https://github.com/python/cpython/pull/15725
Commits 7 https://github.com/python/cpython/pull/15725/commits
Checks 0 https://github.com/python/cpython/pull/15725/checks
Files changed https://github.com/python/cpython/pull/15725/files
Please reload this pagehttps://github.com/python/cpython/pull/15725/files
bpo-26868: Fix example usage of PyModule_AddObject. https://github.com/python/cpython/pull/15725/files#top
Show all changes 7 commits https://github.com/python/cpython/pull/15725/files
90ae263 Add a note to the PyModule_AddObject docs. brandtbucher Sep 7, 2019 https://github.com/python/cpython/pull/15725/commits/90ae263033c616efa907b5eafdb5814ae4e2060a
4b08887 Correct example usages of PyModule_AddObject. brandtbucher Sep 7, 2019 https://github.com/python/cpython/pull/15725/commits/4b08887dac35a9afaf135de2f55d845547be1e7f
aef02b8 Whitespace. brandtbucher Sep 7, 2019 https://github.com/python/cpython/pull/15725/commits/aef02b877a552f8b4d7a7f87f5b531f2c920aeb7
474a266 Clean up wording. brandtbucher Sep 7, 2019 https://github.com/python/cpython/pull/15725/commits/474a266df3a4c6ae69d4aecb549d6feac0113b5f
a005823 📜🤖 Added by blurb_it. blurb-it[bot] Sep 7, 2019 https://github.com/python/cpython/pull/15725/commits/a0058237c63ccdb522bb9f4b2f8f8f1b7646828c
bb345d9 First code review. brandtbucher Sep 9, 2019 https://github.com/python/cpython/pull/15725/commits/bb345d994148c7626ad19dd045045ce1469882b0
37b6b37 Add < 0 in the tests with PyModule_AddObject matrixise Sep 12, 2019 https://github.com/python/cpython/pull/15725/commits/37b6b37e6cab098c42cd461241fc491d7df7589e
Clear filters https://github.com/python/cpython/pull/15725/files
Please reload this pagehttps://github.com/python/cpython/pull/15725/files
Please reload this pagehttps://github.com/python/cpython/pull/15725/files
module.rst https://github.com/python/cpython/pull/15725/files#diff-31dfed5b80337a659e56d1d58ddd7f02cb92bd1ae845ae655bec8dd20f5674c8
extending.rst https://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
newtypes_tutorial.rst https://github.com/python/cpython/pull/15725/files#diff-9c878c16f54b6d3bc875b4edf60bdd4f26a2c5ee4b773dded4ae57dd3a80e3ae
custom.c https://github.com/python/cpython/pull/15725/files#diff-5ab47b3bf39fac130be5e5855e0b3f82a0341055a3579e793a1ac4ca4f20d57b
custom2.c https://github.com/python/cpython/pull/15725/files#diff-205fa8c16a258a2116b12e38bfc69b88b8cf2c6412ce0cc256f5d3e48cb165cf
custom3.c https://github.com/python/cpython/pull/15725/files#diff-3ee128974bffae61ed301477efba310dd1b4a1a646fe24acdb08a5ff3a03ddc0
custom4.c https://github.com/python/cpython/pull/15725/files#diff-40da1923100408b1114041ee458362ce4e301ba5bb6fa7e84a3ba2ad5668129b
sublist.c https://github.com/python/cpython/pull/15725/files#diff-4fa9c4b5aebaf7ff463e7170e32fcb89f0dd1ef03a87fbd61710f2f4cf0dc0b3
2019-09-07-15-55-46.bpo-26868.Raw0Gd.rst https://github.com/python/cpython/pull/15725/files#diff-07044fe246559d13b53570febabc5a61ba676fdb79d569a1423c234c4ab7c477
Doc/c-api/module.rsthttps://github.com/python/cpython/pull/15725/files#diff-31dfed5b80337a659e56d1d58ddd7f02cb92bd1ae845ae655bec8dd20f5674c8
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/c-api/module.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-31dfed5b80337a659e56d1d58ddd7f02cb92bd1ae845ae655bec8dd20f5674c8
https://github.com/python/cpython/pull/15725/files#diff-31dfed5b80337a659e56d1d58ddd7f02cb92bd1ae845ae655bec8dd20f5674c8
Doc/extending/extending.rsthttps://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/extending/extending.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
https://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
https://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
https://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
https://github.com/python/cpython/pull/15725/files#diff-c8029375131ddc13f3113a9eb67810de9dcf954277b4bf193d4220d6834741b3
Doc/extending/newtypes_tutorial.rsthttps://github.com/python/cpython/pull/15725/files#diff-9c878c16f54b6d3bc875b4edf60bdd4f26a2c5ee4b773dded4ae57dd3a80e3ae
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/extending/newtypes_tutorial.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-9c878c16f54b6d3bc875b4edf60bdd4f26a2c5ee4b773dded4ae57dd3a80e3ae
https://github.com/python/cpython/pull/15725/files#diff-9c878c16f54b6d3bc875b4edf60bdd4f26a2c5ee4b773dded4ae57dd3a80e3ae
https://github.com/python/cpython/pull/15725/files#diff-9c878c16f54b6d3bc875b4edf60bdd4f26a2c5ee4b773dded4ae57dd3a80e3ae
https://github.com/python/cpython/pull/15725/files#diff-9c878c16f54b6d3bc875b4edf60bdd4f26a2c5ee4b773dded4ae57dd3a80e3ae
Doc/includes/custom.chttps://github.com/python/cpython/pull/15725/files#diff-5ab47b3bf39fac130be5e5855e0b3f82a0341055a3579e793a1ac4ca4f20d57b
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/includes/custom.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-5ab47b3bf39fac130be5e5855e0b3f82a0341055a3579e793a1ac4ca4f20d57b
Doc/includes/custom2.chttps://github.com/python/cpython/pull/15725/files#diff-205fa8c16a258a2116b12e38bfc69b88b8cf2c6412ce0cc256f5d3e48cb165cf
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/includes/custom2.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-205fa8c16a258a2116b12e38bfc69b88b8cf2c6412ce0cc256f5d3e48cb165cf
Doc/includes/custom3.chttps://github.com/python/cpython/pull/15725/files#diff-3ee128974bffae61ed301477efba310dd1b4a1a646fe24acdb08a5ff3a03ddc0
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/includes/custom3.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-3ee128974bffae61ed301477efba310dd1b4a1a646fe24acdb08a5ff3a03ddc0
Doc/includes/custom4.chttps://github.com/python/cpython/pull/15725/files#diff-40da1923100408b1114041ee458362ce4e301ba5bb6fa7e84a3ba2ad5668129b
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/includes/custom4.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-40da1923100408b1114041ee458362ce4e301ba5bb6fa7e84a3ba2ad5668129b
Doc/includes/sublist.chttps://github.com/python/cpython/pull/15725/files#diff-4fa9c4b5aebaf7ff463e7170e32fcb89f0dd1ef03a87fbd61710f2f4cf0dc0b3
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Doc/includes/sublist.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com/python/cpython/pull/15725/files#diff-4fa9c4b5aebaf7ff463e7170e32fcb89f0dd1ef03a87fbd61710f2f4cf0dc0b3
Misc/NEWS.d/next/Documentation/2019-09-07-15-55-46.bpo-26868.Raw0Gd.rsthttps://github.com/python/cpython/pull/15725/files#diff-07044fe246559d13b53570febabc5a61ba676fdb79d569a1423c234c4ab7c477
View file https://github.com/brandtbucher/cpython/blob/37b6b37e6cab098c42cd461241fc491d7df7589e/Misc/NEWS.d/next/Documentation/2019-09-07-15-55-46.bpo-26868.Raw0Gd.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/15725/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.