René's URL Explorer Experiment


Title: `structseq_repr` mislabels unnamed `PyStructSequence` fields (e.g. `os.stat_result` slots 7–9) · Issue #154387 · python/cpython · GitHub

Open Graph Title: `structseq_repr` mislabels unnamed `PyStructSequence` fields (e.g. `os.stat_result` slots 7–9) · Issue #154387 · python/cpython

X Title: `structseq_repr` mislabels unnamed `PyStructSequence` fields (e.g. `os.stat_result` slots 7–9) · Issue #154387 · python/cpython

Description: Bug report Bug description: structseq_repr() indexes tp_members by visible sequence position, but tp_members is built with every PyStructSequence_UnnamedField entry skipped (packed). As a result, every visible slot at or after the first ...

Open Graph Description: Bug report Bug description: structseq_repr() indexes tp_members by visible sequence position, but tp_members is built with every PyStructSequence_UnnamedField entry skipped (packed). As a result, e...

X Description: Bug report Bug description: structseq_repr() indexes tp_members by visible sequence position, but tp_members is built with every PyStructSequence_UnnamedField entry skipped (packed). As a result, e...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`structseq_repr` mislabels unnamed `PyStructSequence` fields (e.g. `os.stat_result` slots 7–9)","articleBody":"# Bug report\n\n### Bug description:\n\n`structseq_repr()` indexes `tp_members` by visible sequence position, but `tp_members` is built with every `PyStructSequence_UnnamedField` entry skipped (packed). As a result, every visible slot at or after the first unnamed field is labeled with the name of a later (hidden) field. For `os.stat_result`, the unnamed integer time slots 7–9 borrow the names of the hidden `st_atime`/`st_mtime`/`st_ctime` **float** fields.\n\n---\n\nReal-world case — a plain `os.stat()`. The repr prints `st_atime=\u003cinteger seconds>`, but the `st_atime` *attribute* is the float with sub-second precision — they are different fields:\n\n```python\n>>> import os\n>>> st = os.stat(os.curdir)\n>>> st\nos.stat_result(st_mode=16877, st_ino=1367263, st_dev=16777232, st_nlink=43,\n               st_uid=501, st_gid=20, st_size=1376,\n               st_atime=1784619363, st_mtime=1784619363, st_ctime=1784619363)\n>>> st[7]           # sequence slot 7 — the integer atime\n1784619363\n>>> st.st_atime     # the .st_atime attribute — a different, hidden float field\n1784619363.4590902\n```\n\nSynthetic case, isolating the mechanism with distinct values per field:\n\n```python\n>>> # The repr always labels sequence slot 7 \"st_atime\", printing slot 7's value:\n>>> st = os.stat_result(range(22))\n>>> st\nos.stat_result(st_mode=0, st_ino=1, st_dev=2, st_nlink=3, st_uid=4, st_gid=5,\n               st_size=6, st_atime=7, st_mtime=8, st_ctime=9)\n>>> st[7]\n7\n\n>>> # But the .st_atime ATTRIBUTE is the hidden field at index 10:\n>>> st.st_atime  # field 10 supplied  -> 10\n10  # surprise! differs from the repr above\n\n>>> os.stat_result(range(11)).st_atime  # field 10 supplied  -> 10\n10\n>>> os.stat_result(range(10)).st_atime  # field 10 NOT supplied -> falls back to slot 7 -> 7\n7  # surprise! # **UPDATE**: this is an intentional behavior in overrided `statresult_new`\n\n>>> os.stat_result.n_sequence_fields, os.stat_result.n_unnamed_fields\n(10, 3)\n>>> os.stat_result.__match_args__       # correctly excludes the 3 unnamed slots\n('st_mode', 'st_ino', 'st_dev', 'st_nlink', 'st_uid', 'st_gid', 'st_size')\n```\n\nThe mislabel is easy to miss: when only the 10 sequence fields are supplied (`range(10)`), the hidden float `st_atime` (index 10) is unset and derives from the integer slot 7, so the repr and the attribute coincidentally agree. Supplying field 10 (`range(11)` or more, or a real `os.stat()`) makes them disagree.\n\n### CPython versions tested on:\n\n3.14\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-154434\n* gh-154684\n* gh-154687\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/XuehaiPan","@type":"Person","name":"XuehaiPan"},"datePublished":"2026-07-21T16:28:02Z","url":"https://github.com/python/cpython/issues/154387"}

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:8d9eecae-9330-088d-d6c3-3b92c65e3b7d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEB6E:3A73AA:356ACCB:43B0855:6B021B37
html-safe-nonce4c9cd0cc95ab310ad431200f0e3377da66f189ee063cb375399745dbdef0c612
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjZFOjNBNzNBQTozNTZBQ0NCOjQzQjA4NTU6NkIwMjFCMzciLCJ2aXNpdG9yX2lkIjoiNzQ1MDI2NDE0MTMzMzQwNDQ3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb03b1b2a4d3959fdcae73054024b9515210199b7651955f9025c54280946d7fc
hovercard-subject-tagissue:4940987476
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/154387/issue_layout
twitter:imagehttps://opengraph.githubassets.com/04a68b128070d37f88683e39739464b78691eff5b7fe3996b71908ec0df421bd/python/cpython/issues/154387
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/04a68b128070d37f88683e39739464b78691eff5b7fe3996b71908ec0df421bd/python/cpython/issues/154387
og:image:altBug report Bug description: structseq_repr() indexes tp_members by visible sequence position, but tp_members is built with every PyStructSequence_UnnamedField entry skipped (packed). As a result, e...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameXuehaiPan
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/154387#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F154387
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%2F154387
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/154387
Reloadhttps://github.com/python/cpython/issues/154387
Reloadhttps://github.com/python/cpython/issues/154387
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/154387
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/154387
#154687https://github.com/python/cpython/pull/154687
structseq_repr mislabels unnamed PyStructSequence fields (e.g. os.stat_result slots 7–9)https://github.com/python/cpython/issues/154387#top
#154687https://github.com/python/cpython/pull/154687
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Jul 21, 2026https://github.com/python/cpython/issues/154387#issue-4940987476
gh-154387: Fix structseq_repr mislabeling of unnamed PyStructSequence fields #154434https://github.com/python/cpython/pull/154434
gh-154387: validate PyStructSequence_Desc field invariants #154684https://github.com/python/cpython/pull/154684
gh-154387: fix structseq_repr by labeling unnamed fields in repr as  #154687https://github.com/python/cpython/pull/154687
XuehaiPanhttps://github.com/XuehaiPan
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Jul 21, 2026https://github.com/python/cpython/issues/154387#event-28280544036
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Jul 21, 2026https://github.com/python/cpython/issues/154387#issuecomment-5037403141
@vstinnerhttps://github.com/vstinner
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
on Jul 21, 2026https://github.com/python/cpython/issues/154387#event-28285471969
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Jul 21, 2026https://github.com/python/cpython/issues/154387#issuecomment-5037970050
Enhance Object/structseq.c to match namedtuple and tuple api #46145 (comment)https://github.com/python/cpython/issues/46145#issuecomment-2481251218
https://github.com/pranavchoudhary-tech
pranavchoudhary-techhttps://github.com/pranavchoudhary-tech
on Jul 22, 2026https://github.com/python/cpython/issues/154387#issuecomment-5042966372
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Jul 22, 2026https://github.com/python/cpython/issues/154387#issuecomment-5044370880
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Jul 22, 2026https://github.com/python/cpython/issues/154387#issuecomment-5044492616
#46145 (comment)https://github.com/python/cpython/issues/46145#issuecomment-2481045347
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Jul 22, 2026https://github.com/python/cpython/issues/154387#issuecomment-5044512976
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Jul 25, 2026https://github.com/python/cpython/issues/154387#issuecomment-5077119987
XuehaiPanhttps://github.com/XuehaiPan
on Jul 25, 2026https://github.com/python/cpython/issues/154387#event-28469268505
fix(pymacros): resolve undefined PyStructSequence_UnnamedField symbol…https://github.com/XuehaiPan/optree/commit/7c150aeb17fec2f5f3c1d35b274e33b0a65bc3d3
7c150aehttps://github.com/XuehaiPan/optree/commit/7c150aeb17fec2f5f3c1d35b274e33b0a65bc3d3
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Jul 25, 2026https://github.com/python/cpython/issues/154387#issuecomment-5077661390
@encukouhttps://github.com/encukou
@vstinnerhttps://github.com/vstinner
@serhiy-storchakahttps://github.com/serhiy-storchaka
@sobolevnhttps://github.com/sobolevn
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Jul 25, 2026https://github.com/python/cpython/issues/154387#issuecomment-5079376099
gh-154387: validate PyStructSequence_Desc field invariants #154684https://github.com/python/cpython/pull/154684
gh-154387: fix structseq_repr by labeling unnamed fields in repr as  #154687https://github.com/python/cpython/pull/154687
https://github.com/TeamSpen210
TeamSpen210https://github.com/TeamSpen210
on Jul 26, 2026https://github.com/python/cpython/issues/154387#issuecomment-5085487465
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Jul 29, 2026https://github.com/python/cpython/issues/154387#issuecomment-5118985181
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Jul 29, 2026https://github.com/python/cpython/issues/154387#issuecomment-5120830755
@serhiy-storchakahttps://github.com/serhiy-storchaka
PyStructSequence_UnnamedFieldhttps://docs.python.org/3/c-api/tuple.html#c.PyStructSequence_UnnamedField
#154687https://github.com/python/cpython/pull/154687
gh-154387: fix structseq_repr by labeling unnamed fields in repr as  #154687 (comment)https://github.com/python/cpython/pull/154687#issue-4975321299
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Aug 7, 2026https://github.com/python/cpython/issues/154387#issuecomment-5218819897
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Aug 7, 2026https://github.com/python/cpython/issues/154387#issuecomment-5220836383
discussionhttps://discuss.python.org/t/deprecate-the-tuple-api-object-index-of-structseq-objects-like-os-stat-result/108464/2
issuehttps://github.com/python/cpython/issues/155358
pull request (draft)https://github.com/python/cpython/pull/155359
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Aug 9, 2026https://github.com/python/cpython/issues/154387#issuecomment-5230449778
#154387 (comment)https://github.com/python/cpython/issues/154387#issuecomment-5037970050
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Sep 3, 2026https://github.com/python/cpython/issues/154387#issuecomment-5526371316
discussionhttps://discuss.python.org/t/deprecate-the-tuple-api-object-index-of-structseq-objects-like-os-stat-result/108464/2
issuehttps://github.com/python/cpython/issues/155358
pull request (draft)https://github.com/python/cpython/pull/155359
gh-154387: validate PyStructSequence_Desc field invariants #154684https://github.com/python/cpython/pull/154684
gh-154387: fix structseq_repr by labeling unnamed fields in repr as  #154687https://github.com/python/cpython/pull/154687
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Oct 10, 2026https://github.com/python/cpython/issues/154387#issuecomment-6097479723
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/154387#event-33592122032
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/154387
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/154387
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/154387#event-33592173138
https://github.com/XuehaiPan
XuehaiPanhttps://github.com/XuehaiPan
on Nov 3, 2026https://github.com/python/cpython/issues/154387#issuecomment-6597843268
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/154387
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/154387
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%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.