René's URL Explorer Experiment


Title: `isinstance` check against `collection.abc` classes fails if value has no `__class__` · Issue #153772 · python/cpython · GitHub

Open Graph Title: `isinstance` check against `collection.abc` classes fails if value has no `__class__` · Issue #153772 · python/cpython

X Title: `isinstance` check against `collection.abc` classes fails if value has no `__class__` · Issue #153772 · python/cpython

Description: Bug report Bug description: The problem can be reproduced with the following class. It succeeds when tested with isinstance() against base types like int, but fails when tested against collections.abc classes like Mapping. >>> from colle...

Open Graph Description: Bug report Bug description: The problem can be reproduced with the following class. It succeeds when tested with isinstance() against base types like int, but fails when tested against collections....

X Description: Bug report Bug description: The problem can be reproduced with the following class. It succeeds when tested with isinstance() against base types like int, but fails when tested against collections....

Opengraph URL: https://github.com/python/cpython/issues/153772

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`isinstance` check against `collection.abc` classes fails if value has no `__class__`","articleBody":"# Bug report\n\n### Bug description:\n\nThe problem can be reproduced with the following class. It succeeds when tested with `isinstance()` against base types like `int`, but fails when tested against `collections.abc` classes like `Mapping`.\n\n```python\n>>> from collections.abc import Mapping\n>>> \n>>> class NoClass:\n...     def __getattribute__(self, attr):\n...         if attr == \"__class__\":\n...             raise AttributeError(attr)\n...         return super().__getattribute__(attr)\n...         \n>>> \n>>> isinstance(NoClass(), int)\nFalse\n>>> isinstance(NoClass(), Mapping)\nTraceback (most recent call last):\n  File \"\u003cpython-input-4>\", line 1, in \u003cmodule>\n    isinstance(NoClass(), Mapping)\n    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^\n  File \"\u003cfrozen abc>\", line 119, in __instancecheck__\n  File \"\u003cpython-input-0>\", line 4, in __getattribute__\n    raise AttributeError(attr)\nAttributeError: __class__\n```\nThe example class is arguably broken, but it seems objects without `__class__` actually exist. For a real life example see https://github.com/robotframework/robotframework/issues/5699 where the problematic object apparently is a Qt widget.\n\nThis is a very annoying case, because handling these problematic objects requires changing all `isinstance` usages where the type can be `collections.abc` class from something like\n```\nif isinstance(value, Mapping):\n    ...\n```\nto\n```\ntry:\n    is_mapping = isinstance(value, Mapping)\nexcept AttributeError:\n    is_mapping = False\nif is_mapping:\n    ...\n```\nI'll do that in our code in cases where there problematic objects are likely to occur, but wrapping all `isinstance` usage isn't practical so I'm worried there still can be crashes.\n\nI hope `collections.abc` types would be fixed so that they return `False` with objects without `__class__` instead of failing with `AttributeError`. Alternatively, if objects without `__class__` are considered to be totally broken, the interpreter should fail/warn when they are instantiated and not only with `isinstance()`.\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-154149\n* gh-156541\n* gh-156542\n* gh-156543\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pekkaklarck","@type":"Person","name":"pekkaklarck"},"datePublished":"2026-07-15T15:06:23Z","url":"https://github.com/python/cpython/issues/153772"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b90c7bd0-42b7-4344-24eb-84af17963bf7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA794:17543D:610168:7AEBAF:6B020981
html-safe-nonce23a51c3c20f637353302d39e98c18a6e3de639329e26a6c0b20608e2886afcde
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzk0OjE3NTQzRDo2MTAxNjg6N0FFQkFGOjZCMDIwOTgxIiwidmlzaXRvcl9pZCI6Ijk0MDA2NjY5Mzg5ODcwMTE4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4cf62ed6353e77eaf9057e4d8c1110fc307bfdc90b468bd087706d761b160d17
hovercard-subject-tagissue:4893751133
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/153772/issue_layout
twitter:imagehttps://opengraph.githubassets.com/79c4699fdb3c9bef5e8dd164b73485af341c064bdbd48e694e94f78d31c879da/python/cpython/issues/153772
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/79c4699fdb3c9bef5e8dd164b73485af341c064bdbd48e694e94f78d31c879da/python/cpython/issues/153772
og:image:altBug report Bug description: The problem can be reproduced with the following class. It succeeds when tested with isinstance() against base types like int, but fails when tested against collections....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepekkaklarck
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/153772#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153772
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153772
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/153772
Reloadhttps://github.com/python/cpython/issues/153772
Reloadhttps://github.com/python/cpython/issues/153772
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153772
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153772
isinstance check against collection.abc classes fails if value has no __class__https://github.com/python/cpython/issues/153772#top
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/pekkaklarck
pekkaklarckhttps://github.com/pekkaklarck
on Jul 15, 2026https://github.com/python/cpython/issues/153772#issue-4893751133
robotframework/robotframework#5699https://github.com/robotframework/robotframework/issues/5699
gh-153772: Make abc isinstance() tolerate instances without __class__ #154149https://github.com/python/cpython/pull/154149
[3.15] gh-153772: Make abc isinstance() tolerate instances without __class__ (GH-154149) #156541https://github.com/python/cpython/pull/156541
[3.14] gh-153772: Make abc isinstance() tolerate instances without __class__ (GH-154149) #156542https://github.com/python/cpython/pull/156542
[3.13] gh-153772: Make abc isinstance() tolerate instances without __class__ (GH-154149) #156543https://github.com/python/cpython/pull/156543
pekkaklarckhttps://github.com/pekkaklarck
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Jul 15, 2026https://github.com/python/cpython/issues/153772#event-28022759671
pekkaklarckhttps://github.com/pekkaklarck
on Jul 15, 2026https://github.com/python/cpython/issues/153772#event-28022771738
pekkaklarckhttps://github.com/pekkaklarck
on Jul 15, 2026https://github.com/python/cpython/issues/153772#event-28027076053
Handle `isinstance()` raising `AttributeError`https://github.com/robotframework/robotframework/commit/64d7285899cddf5d9f3a02f45dfef6bd3c45b291
64d7285https://github.com/robotframework/robotframework/commit/64d7285899cddf5d9f3a02f45dfef6bd3c45b291
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Jul 15, 2026https://github.com/python/cpython/issues/153772#issuecomment-4983258890
docshttps://docs.python.org/3/reference/datamodel.html#object.__class__
@serhiy-storchakahttps://github.com/serhiy-storchaka
@JelleZijlstrahttps://github.com/JelleZijlstra
picnixzhttps://github.com/picnixz
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Jul 15, 2026https://github.com/python/cpython/issues/153772#event-28028198244
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Jul 15, 2026https://github.com/python/cpython/issues/153772#issuecomment-4985980693
cpython/Objects/typeobject.chttps://github.com/python/cpython/blob/b4662e8e3b60a264486130a171047c7381f993f0/Objects/typeobject.c#L8520-L8525
b4662e8https://github.com/python/cpython/commit/b4662e8e3b60a264486130a171047c7381f993f0
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Jul 15, 2026https://github.com/python/cpython/issues/153772#issuecomment-4986053316
#143811https://github.com/python/cpython/issues/143811
https://github.com/pekkaklarck
pekkaklarckhttps://github.com/pekkaklarck
on Jul 16, 2026https://github.com/python/cpython/issues/153772#issuecomment-4989242819
@picnixzhttps://github.com/picnixz
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Jul 17, 2026https://github.com/python/cpython/issues/153772#issuecomment-4998428764
@johnslavikhttps://github.com/johnslavik
picnixzhttps://github.com/picnixz
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
on Jul 19, 2026https://github.com/python/cpython/issues/153772#event-28181864117
https://github.com/pekkaklarck
pekkaklarckhttps://github.com/pekkaklarck
on Aug 13, 2026https://github.com/python/cpython/issues/153772#issuecomment-5280191477
#154149https://github.com/python/cpython/pull/154149
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Aug 13, 2026https://github.com/python/cpython/issues/153772#issuecomment-5280236986
JelleZijlstrahttps://github.com/JelleZijlstra
on Aug 29, 2026https://github.com/python/cpython/issues/153772#event-30198085616
gh-153772: Make abc isinstance() tolerate instances without __class__ (…https://github.com/python/cpython/commit/3e245faf34efc41c39bbe76071e6edb7a62692a8
gh-153772https://github.com/python/cpython/issues/153772
…https://github.com/python/cpython/pull/154149
3e245fahttps://github.com/python/cpython/commit/3e245faf34efc41c39bbe76071e6edb7a62692a8
[3.13] gh-153772: Make abc isinstance() tolerate instances without __…https://github.com/python/cpython/commit/44a46281a500449b8e576cc824671326ba49d68c
gh-153772https://github.com/python/cpython/issues/153772
44a4628https://github.com/python/cpython/commit/44a46281a500449b8e576cc824671326ba49d68c
[3.14] gh-153772: Make abc isinstance() tolerate instances without __…https://github.com/python/cpython/commit/94f8b864ee55b2915256e944e2bcff810c7eadb2
gh-153772https://github.com/python/cpython/issues/153772
94f8b86https://github.com/python/cpython/commit/94f8b864ee55b2915256e944e2bcff810c7eadb2
hugovkhttps://github.com/hugovk
on Aug 29, 2026https://github.com/python/cpython/issues/153772#event-30203248582
[3.15] gh-153772: Make abc isinstance() tolerate instances without __…https://github.com/python/cpython/commit/d122f3e434efc81981bec25e0eff35a4a3a30764
gh-153772https://github.com/python/cpython/issues/153772
d122f3ehttps://github.com/python/cpython/commit/d122f3e434efc81981bec25e0eff35a4a3a30764
hugovkhttps://github.com/hugovk
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 29, 2026https://github.com/python/cpython/issues/153772#event-30203258648
clin1234https://github.com/clin1234
on Sep 12, 2026https://github.com/python/cpython/issues/153772#event-31023910649
pythongh-153772: Make abc isinstance() tolerate instances without __c…https://github.com/clin1234/cpython/commit/a156073e924fc4333bdf66bf0e713f8118ce1eb1
pythongh-153772https://github.com/python/cpython/issues/153772
a156073https://github.com/clin1234/cpython/commit/a156073e924fc4333bdf66bf0e713f8118ce1eb1
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/153772
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/153772
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
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.