René's URL Explorer Experiment


Title: added 'construct_custodian_for' and test by ukoethe · Pull Request #8 · boostorg/python · GitHub

Open Graph Title: added 'construct_custodian_for' and test by ukoethe · Pull Request #8 · boostorg/python

X Title: added 'construct_custodian_for' and test by ukoethe · Pull Request #8 · boostorg/python

Description: (note: I will update the documentation as well when this pull request gets accepted) This pull request proposes a fix for the long-standing problem that with_custodian_and_ward_postcall doesn't work in connection with make_constructor (see e.g. https://mail.python.org/pipermail/cplusplus-sig/2007-June/012145.html). Consider the following class definitions: struct A { int i_; A(int i) : i_(i) {} }; struct B { A * a_; B(A * a) : a_(a) {} int a_content() { return a_ == 0 ? 0 : a_->i_; } }; B * create_B(A * a) { return new B(a); } and the corresponding boost::python glue code BOOST_PYTHON_MODULE(test_custodian_and_ward) { class_("A", no_init) .def(init()) // #1 .def("create_B", &create_B, with_custodian_and_ward_postcall<0,1, return_value_policy >()) ; class_("B1", no_init) // #2 .def(init()[with_custodian_and_ward_postcall<1,2>()]) .def("a_content", &B::a_content) ; class_("B2", no_init) // #3 .def("__init__", make_constructor(&create_B, with_custodian_and_ward_postcall<1,2>())) .def("a_content", &B::a_content) ; class_("B3", no_init) // #4 .def("__init__", make_constructor(&create_B, with_custodian_and_ward_postcall<0,1>())) .def("a_content", &B::a_content) ; } In this code #1 works as desired #2 works, but is a bit counter-intuitive because indexing suddenly starts at 1 #3 causes an "argument index out of range" error #4 runs, but fails to establish the desired custodian-and-ward relationship (i.e. B3.a_content() may crash because the containd A instance can be deleted prematurely) The pull request introduces a new policy construct_custodian_for which solves problems #2-4. It is used like this: BOOST_PYTHON_MODULE(test_custodian_and_ward) { ... class_("B1", no_init) .def(init()[construct_custodian_for<1>()]) .def("a_content", &B::a_content) ; class_("B2", no_init) .def("__init__", make_constructor(&create_B, construct_custodian_for<1>())) .def("a_content", &B::a_content) ; }

Open Graph Description: (note: I will update the documentation as well when this pull request gets accepted) This pull request proposes a fix for the long-standing problem that with_custodian_and_ward_postcall doesn't...

X Description: (note: I will update the documentation as well when this pull request gets accepted) This pull request proposes a fix for the long-standing problem that with_custodian_and_ward_postcall doesn&#...

Opengraph URL: https://github.com/boostorg/python/pull/8

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a618e81a-f6ee-5c2b-4d3e-ca64f2004b8f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id93C6:1C7DFD:591F127:737F4B5:697546F3
html-safe-noncec3bb83e5f6095f7eef8bc1ab52868c6aeb414a255804f6b9c8bb9b0d1d76c5c3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0M2OjFDN0RGRDo1OTFGMTI3OjczN0Y0QjU6Njk3NTQ2RjMiLCJ2aXNpdG9yX2lkIjoiMjg5ODg5ODg1NTQ5MzE5MTQxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfe6190c0bf15e90760cac2843efa349bab3350034cbf860d5b958047ddbd3efc
hovercard-subject-tagpull_request:15741897
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/boostorg/python/pull/8/files
twitter:imagehttps://avatars.githubusercontent.com/u/897680?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/897680?s=400&v=4
og:image:alt(note: I will update the documentation as well when this pull request gets accepted) This pull request proposes a fix for the long-standing problem that with_custodian_and_ward_postcall doesn't...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/boostorg/python git https://github.com/boostorg/python.git
octolytics-dimension-user_id3170529
octolytics-dimension-user_loginboostorg
octolytics-dimension-repository_id7589968
octolytics-dimension-repository_nwoboostorg/python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7589968
octolytics-dimension-repository_network_root_nwoboostorg/python
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
release488b30e96dfd057fbbe44c6665ccbc030b729dde
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fboostorg%2Fpython%2Fpull%2F8%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fboostorg%2Fpython%2Fpull%2F8%2Ffiles
Sign up https://patch-diff.githubusercontent.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=boostorg%2Fpython
Reloadhttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
Reloadhttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
Reloadhttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
boostorg https://patch-diff.githubusercontent.com/boostorg
pythonhttps://patch-diff.githubusercontent.com/boostorg/python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fboostorg%2Fpython
Fork 221 https://patch-diff.githubusercontent.com/login?return_to=%2Fboostorg%2Fpython
Star 518 https://patch-diff.githubusercontent.com/login?return_to=%2Fboostorg%2Fpython
Code https://patch-diff.githubusercontent.com/boostorg/python
Issues 169 https://patch-diff.githubusercontent.com/boostorg/python/issues
Pull requests 37 https://patch-diff.githubusercontent.com/boostorg/python/pulls
Actions https://patch-diff.githubusercontent.com/boostorg/python/actions
Projects 0 https://patch-diff.githubusercontent.com/boostorg/python/projects
Wiki https://patch-diff.githubusercontent.com/boostorg/python/wiki
Security 0 https://patch-diff.githubusercontent.com/boostorg/python/security
Insights https://patch-diff.githubusercontent.com/boostorg/python/pulse
Code https://patch-diff.githubusercontent.com/boostorg/python
Issues https://patch-diff.githubusercontent.com/boostorg/python/issues
Pull requests https://patch-diff.githubusercontent.com/boostorg/python/pulls
Actions https://patch-diff.githubusercontent.com/boostorg/python/actions
Projects https://patch-diff.githubusercontent.com/boostorg/python/projects
Wiki https://patch-diff.githubusercontent.com/boostorg/python/wiki
Security https://patch-diff.githubusercontent.com/boostorg/python/security
Insights https://patch-diff.githubusercontent.com/boostorg/python/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fboostorg%2Fpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fboostorg%2Fpython%2Fissues%2Fnew%2Fchoose
ukoethehttps://patch-diff.githubusercontent.com/ukoethe
boostorg:masterhttps://patch-diff.githubusercontent.com/boostorg/python/tree/master
ukoethe:masterhttps://patch-diff.githubusercontent.com/ukoethe/python/tree/master
Conversation 5 https://patch-diff.githubusercontent.com/boostorg/python/pull/8
Commits 1 https://patch-diff.githubusercontent.com/boostorg/python/pull/8/commits
Checks 0 https://patch-diff.githubusercontent.com/boostorg/python/pull/8/checks
Files changed https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
Please reload this pagehttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
added 'construct_custodian_for' and test https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#top
Show all changes 1 commit https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
fe6c6bf added 'construct_custodian_for' and test ukoethe May 11, 2014 https://patch-diff.githubusercontent.com/boostorg/python/pull/8/commits/fe6c6bf8c71ce8b7b2bacc5a373a2ee7a16bd5e6
Clear filters https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
Please reload this pagehttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
Please reload this pagehttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files
init.hpp https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-68a56cb3bc541e7968a88e606f313035b92d1092577d2873a9fd092223545493
with_custodian_and_ward.hpp https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-8b2ba71dccbadd9f54367369bad088e13aa438c37cdb3b435ac211294a1611c8
test_pointer_adoption.cpp https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
test_pointer_adoption.py https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-01261aaf119f875badfad2b15503a499d9fdba48ce02317ddc0e6417d522e44f
include/boost/python/init.hpphttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-68a56cb3bc541e7968a88e606f313035b92d1092577d2873a9fd092223545493
View file https://patch-diff.githubusercontent.com/boostorg/python/blob/fe6c6bf8c71ce8b7b2bacc5a373a2ee7a16bd5e6/include/boost/python/init.hpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-68a56cb3bc541e7968a88e606f313035b92d1092577d2873a9fd092223545493
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-68a56cb3bc541e7968a88e606f313035b92d1092577d2873a9fd092223545493
include/boost/python/with_custodian_and_ward.hpphttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-8b2ba71dccbadd9f54367369bad088e13aa438c37cdb3b435ac211294a1611c8
View file https://patch-diff.githubusercontent.com/boostorg/python/blob/fe6c6bf8c71ce8b7b2bacc5a373a2ee7a16bd5e6/include/boost/python/with_custodian_and_ward.hpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-8b2ba71dccbadd9f54367369bad088e13aa438c37cdb3b435ac211294a1611c8
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-8b2ba71dccbadd9f54367369bad088e13aa438c37cdb3b435ac211294a1611c8
test/test_pointer_adoption.cpphttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
View file https://patch-diff.githubusercontent.com/boostorg/python/blob/fe6c6bf8c71ce8b7b2bacc5a373a2ee7a16bd5e6/test/test_pointer_adoption.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-cc74ebea913cdaaee38926fc9daf8b430b532f83d12e480c8d44788b32920d8b
test/test_pointer_adoption.pyhttps://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-01261aaf119f875badfad2b15503a499d9fdba48ce02317ddc0e6417d522e44f
View file https://patch-diff.githubusercontent.com/boostorg/python/blob/fe6c6bf8c71ce8b7b2bacc5a373a2ee7a16bd5e6/test/test_pointer_adoption.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-01261aaf119f875badfad2b15503a499d9fdba48ce02317ddc0e6417d522e44f
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-01261aaf119f875badfad2b15503a499d9fdba48ce02317ddc0e6417d522e44f
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-01261aaf119f875badfad2b15503a499d9fdba48ce02317ddc0e6417d522e44f
https://patch-diff.githubusercontent.com/boostorg/python/pull/8/files#diff-01261aaf119f875badfad2b15503a499d9fdba48ce02317ddc0e6417d522e44f
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.