René's URL Explorer Experiment


Title: Decide tp_new inheritance of static types at type initialization by youknowone · Pull Request #9386 · RustPython/RustPython · GitHub

Open Graph Title: Decide tp_new inheritance of static types at type initialization by youknowone · Pull Request #9386 · RustPython/RustPython

X Title: Decide tp_new inheritance of static types at type initialization by youknowone · Pull Request #9386 · RustPython/RustPython

Description: Summary A static type that defines no tp_new and whose base is object used to inherit object.__new__. Calling such a type created an instance whose class is the type but whose payload is a plain object: >>> type(iter(lambda: 0, 1))() # before: a callable_iterator with no iterator state >>> import re; re.Pattern() # before: succeeds >>> import collections; type(collections.OrderedDict().keys())() The reference interpreter rejects all of these with TypeError: cannot create '...' instances (type_ready_set_new). This PR makes PyType::set_new follow the same rule: A static type with no tp_new of its own whose base is object gets DISALLOW_INSTANTIATION and keeps tp_new unset. Such types no longer expose an inherited __new__ in their dict. Other types inherit the base's tp_new as before. A static type that inherits a non-NULL tp_new must have the same basicsize as that base, because the inherited function allocates the base payload; type initialization panics otherwise. Types flagged HEAPTYPE are exempt, like classes created at runtime. Types that the reference interpreter does allow to be instantiated keep working: _io._IOBase is a heap type there and inherits object.__new__; it is flagged HEAPTYPE here so it keeps doing so (object.__new__(C) for class C(_io._IOBase) still passes the staticbase check). _asyncio.FutureIter, TaskStepMethWrapper, _testinternalcapi hamt, InstructionSequence and itertools._grouper get constructors of their own, matching what the reference interpreter accepts. Test cargo fmt --all -- --check, cargo clippy --workspace --all-targets --features threading ... -D warnings, cargo test --workspace --features threading ..., (cd crates/capi && cargo test && cargo clippy --all-targets -- -D warnings), (cd crates/wasm && cargo check --target wasm32-unknown-unknown): pass. cargo run --release --features threading -- -m test on test_io, test_itertools, test_asyncio, test_descr, test_types, test_class, test_typing, test_collections, test_ordered_dict, test_re, test_exceptions, test_weakref, test_ctypes, test_inspect, test_builtin, test_functools, test_pickle, test_copy, test_pydoc, test_abc, test_dis, test_code, test_contextlib, test_unittest: all pass (2 Windows-only asyncio files skipped). wasm32-wasip1 wasm-release build with the CI feature set: all 187 extra_tests/snippets that the wasm-wasi job runs pass under wasmer. The expressions above, plus _io._IOBase(), type(len)(), type(iter([]))() and constructing itertools._grouper, print the same results on this build and on CPython 3.14. Not covered: test_sqlite3 (no _sqlite3 in my build), Linux/Windows-only code paths. 🤖 Generated with Claude Code Summary by CodeRabbit Bug Fixes Improved class instantiation behavior, including inherited constructors and types that cannot be instantiated. New Features Added support for creating default instances of additional built-in objects. Improved construction of iterator-grouping objects by accepting their parent iterator and target key.

Open Graph Description: Summary A static type that defines no tp_new and whose base is object used to inherit object.__new__. Calling such a type created an instance whose class is the type but whose payload is a plain ob...

X Description: Summary A static type that defines no tp_new and whose base is object used to inherit object.__new__. Calling such a type created an instance whose class is the type but whose payload is a plain ob...

Opengraph URL: https://github.com/RustPython/RustPython/pull/9386

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6f2bb207-8cf3-3591-384c-252ceba3aedc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD95E:19F84C:3A016EA:49B9126:6B01E6C7
html-safe-nonce5538d54fd8fe6bd8ac9d3c33372994a791c5d8f48bb64a40211dad35f5c21d30
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTVFOjE5Rjg0QzozQTAxNkVBOjQ5QjkxMjY6NkIwMUU2QzciLCJ2aXNpdG9yX2lkIjoiODEwMDQ0NzgxMzk5OTEyNjIxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5b700531d1b3a5c403317268bae168ee047ada824a35942cd6eefb30f380a21c
hovercard-subject-tagpull_request:5013032881
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/RustPython/RustPython/pull/9386/files
twitter:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
og:image:altSummary A static type that defines no tp_new and whose base is object used to inherit object.__new__. Calling such a type created an instance whose class is the type but whose payload is a plain ob...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/9386/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9386%2Ffiles
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%2FRustPython%2FRustPython%2Fpull%2F9386%2Ffiles
Sign uphttps://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=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/9386/files
Reloadhttps://github.com/RustPython/RustPython/pull/9386/files
Reloadhttps://github.com/RustPython/RustPython/pull/9386/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests133 (133)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
youknowone:static-type-tp-newhttps://github.com/youknowone/RustPython/tree/static-type-tp-new
Conversation 6 https://github.com/RustPython/RustPython/pull/9386
Commits 1 https://github.com/RustPython/RustPython/pull/9386/commits
Checks 27 https://github.com/RustPython/RustPython/pull/9386/checks
Files changed https://github.com/RustPython/RustPython/pull/9386/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9386/files
Decide tp_new inheritance of static types at type initialization https://github.com/RustPython/RustPython/pull/9386/files#top
Show all changes 1 commit https://github.com/RustPython/RustPython/pull/9386/files
81d6061 Decide tp_new inheritance of static types at type initialization youknowone Oct 13, 2026 https://github.com/RustPython/RustPython/pull/9386/commits/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597
Clear filters https://github.com/RustPython/RustPython/pull/9386/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9386/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9386/files
_asyncio.rs https://github.com/RustPython/RustPython/pull/9386/files#diff-b037b755b683da52a52725ec7a97d87b359ba95b4326e33d0673c8e11eb457a3
type.rs https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
class.rs https://github.com/RustPython/RustPython/pull/9386/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
_io.rs https://github.com/RustPython/RustPython/pull/9386/files#diff-90825edc73ec293e0ed3b2dbed7f0a492b1f8e51c25747326089a912267bdd3e
_testinternalcapi.rs https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
itertools.rs https://github.com/RustPython/RustPython/pull/9386/files#diff-327f924a0e1982a4aa3d49157129811604b589ade7716766a67653a16e0bf101
crates/stdlib/src/_asyncio.rshttps://github.com/RustPython/RustPython/pull/9386/files#diff-b037b755b683da52a52725ec7a97d87b359ba95b4326e33d0673c8e11eb457a3
View file https://github.com/youknowone/RustPython/blob/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597/crates/stdlib/src/_asyncio.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9386/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9386/files#diff-b037b755b683da52a52725ec7a97d87b359ba95b4326e33d0673c8e11eb457a3
https://github.com/RustPython/RustPython/pull/9386/files#diff-b037b755b683da52a52725ec7a97d87b359ba95b4326e33d0673c8e11eb457a3
https://github.com/RustPython/RustPython/pull/9386/files#diff-b037b755b683da52a52725ec7a97d87b359ba95b4326e33d0673c8e11eb457a3
https://github.com/RustPython/RustPython/pull/9386/files#diff-b037b755b683da52a52725ec7a97d87b359ba95b4326e33d0673c8e11eb457a3
crates/vm/src/builtins/type.rshttps://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
View file https://github.com/youknowone/RustPython/blob/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597/crates/vm/src/builtins/type.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9386/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/9386/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
crates/vm/src/class.rshttps://github.com/RustPython/RustPython/pull/9386/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
View file https://github.com/youknowone/RustPython/blob/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597/crates/vm/src/class.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9386/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9386/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
https://github.com/RustPython/RustPython/pull/9386/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
crates/vm/src/stdlib/_io.rshttps://github.com/RustPython/RustPython/pull/9386/files#diff-90825edc73ec293e0ed3b2dbed7f0a492b1f8e51c25747326089a912267bdd3e
View file https://github.com/youknowone/RustPython/blob/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597/crates/vm/src/stdlib/_io.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9386/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9386/files#diff-90825edc73ec293e0ed3b2dbed7f0a492b1f8e51c25747326089a912267bdd3e
https://github.com/RustPython/RustPython/pull/9386/files#diff-90825edc73ec293e0ed3b2dbed7f0a492b1f8e51c25747326089a912267bdd3e
crates/vm/src/stdlib/_testinternalcapi.rshttps://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
View file https://github.com/youknowone/RustPython/blob/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597/crates/vm/src/stdlib/_testinternalcapi.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9386/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
https://github.com/RustPython/RustPython/pull/9386/files#diff-696e7f5e9d8e7d68b319536976bd29f52b43c3e368850ce083ef75ae0bf9785b
crates/vm/src/stdlib/itertools.rshttps://github.com/RustPython/RustPython/pull/9386/files#diff-327f924a0e1982a4aa3d49157129811604b589ade7716766a67653a16e0bf101
View file https://github.com/youknowone/RustPython/blob/81d6061d3adf58b72b1cc33421cbd2c0ffa3a597/crates/vm/src/stdlib/itertools.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9386/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9386/files#diff-327f924a0e1982a4aa3d49157129811604b589ade7716766a67653a16e0bf101
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9386/files
https://github.com/RustPython/RustPython/pull/9386/files#diff-327f924a0e1982a4aa3d49157129811604b589ade7716766a67653a16e0bf101
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9386/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.