René's URL Explorer Experiment


Title: gh-142418 Enhance markcoroutinefunction to support functools.partial by chaope · Pull Request #142505 · python/cpython · GitHub

Open Graph Title: gh-142418 Enhance markcoroutinefunction to support functools.partial by chaope · Pull Request #142505 · python/cpython

X Title: gh-142418 Enhance markcoroutinefunction to support functools.partial by chaope · Pull Request #142505 · python/cpython

Description: Enhance markcoroutinefunction to support functools.partial and added test to cover the corner case. Based on the PR (#99247) that added markcoroutinefunction, the purpose is to be able to continue to identify sync functions returning awaitables, without calling them to see that. Given that, I think this issue indeed reports a bug. The root cause is that markcoroutinefunction sets the mark on partial function object (joke), while iscoroutinefunction looks at the underlying function object of partial function object (manufacturer_of_jokes). The deeper issue is that markcoroutinefunction and iscoroutinefunction uses different code path to find the function object it operates on. In order to fix this bug, we can do it in two ways: fix the problem with minimum change or fix it more thoroughly, but riskier. minimum change: add functools._unwrap_partial to markcoroutinefunction This PR implements minimum change. fix it more thoroughly: move the logic in _has_code_flag to a separate function and reuse it in markcoroutinefunction and _has_coroutine_mark I do think if not (isfunction(f) or _signature_is_functionlike(f)): is appropriate to be applied to markcoroutinefunction and iscoroutinefunction as well, if the check fails, we raise a ValueError, but it may break user's code, open for discussion. If we do want to check isfunction in iscoroutinefunction, then we don't need #120214 def _find_underlying_function(f): f = functools._unwrap_partialmethod(f) while ismethod(f): f = f.__func__ f = functools._unwrap_partial(f) return f def _has_code_flag(f, flag): f = _find_underlying_function(f) if not (isfunction(f) or _signature_is_functionlike(f)): return False return bool(f.__code__.co_flags & flag) def markcoroutinefunction(f): f = _find_underlying_function(f) f._is_coroutine_marker = _is_coroutine_mark return f def _has_coroutine_mark(f): f = _find_underlying_function(f) return getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark Issue: gh-142418

Open Graph Description: Enhance markcoroutinefunction to support functools.partial and added test to cover the corner case. Based on the PR (#99247) that added markcoroutinefunction, the purpose is to be able to continue...

X Description: Enhance markcoroutinefunction to support functools.partial and added test to cover the corner case. Based on the PR (#99247) that added markcoroutinefunction, the purpose is to be able to continue...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:9ebbfede-d0f2-f08a-57ab-5163a6115a9b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE356:AA1C4:48C566:5DFDEA:696982D1
html-safe-nonce65a1d713199721e440b74f90b705d6296e9a422d1387e382734c62621d086ae6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzU2OkFBMUM0OjQ4QzU2Njo1REZERUE6Njk2OTgyRDEiLCJ2aXNpdG9yX2lkIjoiNDExNTcwOTY2NTA3NDU3ODEyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9eae6fb07b9dffa6141d81754c77e05d24cd6989ca409a614a526e78a4ec9bde
hovercard-subject-tagpull_request:3088301786
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/142505/files
twitter:imagehttps://avatars.githubusercontent.com/u/13768674?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/13768674?s=400&v=4
og:image:altEnhance markcoroutinefunction to support functools.partial and added test to cover the corner case. Based on the PR (#99247) that added markcoroutinefunction, the purpose is to be able to continue...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonef33e4b94c8824ab2b434d82a94139432fb5ebee9df4b75304140ad22508c4a77
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
release48f380098b30acbb700b04f1724481ca10d574fc
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/142505/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F142505%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://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F142505%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/142505/files
Reloadhttps://github.com/python/cpython/pull/142505/files
Reloadhttps://github.com/python/cpython/pull/142505/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k 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.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
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 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
chaopehttps://github.com/chaope
python:mainhttps://github.com/python/cpython/tree/main
chaope:fix-issue-142418https://github.com/chaope/cpython/tree/fix-issue-142418
Conversation 13 https://github.com/python/cpython/pull/142505
Commits 1 https://github.com/python/cpython/pull/142505/commits
Checks 42 https://github.com/python/cpython/pull/142505/checks
Files changed https://github.com/python/cpython/pull/142505/files
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
gh-142418 Enhance markcoroutinefunction to support functools.partial https://github.com/python/cpython/pull/142505/files#top
Show all changes 1 commit https://github.com/python/cpython/pull/142505/files
56c6527 Enhance markcoroutinefunction to support functools.partial chaope Dec 10, 2025 https://github.com/python/cpython/pull/142505/commits/56c6527810f943ecdb52cef6f9c007e30a1df3c0
Clear filters https://github.com/python/cpython/pull/142505/files
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
inspect.py https://github.com/python/cpython/pull/142505/files#diff-b89cd06e4637abacb73f2500301ff979a67ad7ecbfa7cf151c7243715898d7ea
test_inspect.py https://github.com/python/cpython/pull/142505/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
2025-12-10-02-31-08.gh-issue-142418.XLGNh3.rst https://github.com/python/cpython/pull/142505/files#diff-ed839b0735280871875c3cb6371a580c315dfa1b7ccbd83fe2d265db2a5a8b11
Lib/inspect.pyhttps://github.com/python/cpython/pull/142505/files#diff-b89cd06e4637abacb73f2500301ff979a67ad7ecbfa7cf151c7243715898d7ea
View file https://github.com/chaope/cpython/blob/56c6527810f943ecdb52cef6f9c007e30a1df3c0/Lib/inspect.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/142505/{{ revealButtonHref }}
https://github.com/python/cpython/pull/142505/files#diff-b89cd06e4637abacb73f2500301ff979a67ad7ecbfa7cf151c7243715898d7ea
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605554058
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
chaopehttps://github.com/chaope
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605601884
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605618379
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
chaopehttps://github.com/chaope
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605633410
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605643962
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605671911
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605734176
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
the typeshed annotationshttps://github.com/python/typeshed/blob/e8ba06f710d5fe4f9219fafd77abd79a6e3414f4/stdlib/inspect.pyi#L226-L233
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
chaopehttps://github.com/chaope
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605754896
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605803468
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
the parallel PRhttps://github.com/python/cpython/pull/142503
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
x42005e1fhttps://github.com/x42005e1f
Dec 10, 2025https://github.com/python/cpython/pull/142505/files#r2605832861
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
https://github.com/python/cpython/pull/142505/files#diff-b89cd06e4637abacb73f2500301ff979a67ad7ecbfa7cf151c7243715898d7ea
Lib/test/test_inspect/test_inspect.pyhttps://github.com/python/cpython/pull/142505/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
View file https://github.com/chaope/cpython/blob/56c6527810f943ecdb52cef6f9c007e30a1df3c0/Lib/test/test_inspect/test_inspect.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/142505/{{ revealButtonHref }}
https://github.com/python/cpython/pull/142505/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
https://github.com/python/cpython/pull/142505/files#diff-92d8ecc68ed9e7ce3b31a764d5b0368db1514365c2a6433bbe3bad5c3210cea0
Misc/NEWS.d/next/Library/2025-12-10-02-31-08.gh-issue-142418.XLGNh3.rsthttps://github.com/python/cpython/pull/142505/files#diff-ed839b0735280871875c3cb6371a580c315dfa1b7ccbd83fe2d265db2a5a8b11
View file https://github.com/chaope/cpython/blob/56c6527810f943ecdb52cef6f9c007e30a1df3c0/Misc/NEWS.d/next/Library/2025-12-10-02-31-08.gh-issue-142418.XLGNh3.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/142505/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/142505/files
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.