René's URL Explorer Experiment


Title: `marshal.dumps()` raises `TypeError` for a set containing several complex NaNs · Issue #159184 · python/cpython · GitHub

Open Graph Title: `marshal.dumps()` raises `TypeError` for a set containing several complex NaNs · Issue #159184 · python/cpython

X Title: `marshal.dumps()` raises `TypeError` for a set containing several complex NaNs · Issue #159184 · python/cpython

Description: Bug report marshal writes the elements of a set in the order of a sort of (marshalled bytes, value) pairs. When two elements have the same marshalled bytes, the sort compares the values. Complex numbers are not orderable, so this fails: ...

Open Graph Description: Bug report marshal writes the elements of a set in the order of a sort of (marshalled bytes, value) pairs. When two elements have the same marshalled bytes, the sort compares the values. Complex nu...

X Description: Bug report marshal writes the elements of a set in the order of a sort of (marshalled bytes, value) pairs. When two elements have the same marshalled bytes, the sort compares the values. Complex nu...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`marshal.dumps()` raises `TypeError` for a set containing several complex NaNs","articleBody":"### Bug report\n\n`marshal` writes the elements of a set in the order of a sort of\n`(marshalled bytes, value)` pairs.  When two elements have the same\nmarshalled bytes, the sort compares the values.  Complex numbers are not\norderable, so this fails:\n\n```python\n>>> import marshal\n>>> marshal.dumps(frozenset({complex('nan'), complex('nan')}))\nTypeError: '\u003c' not supported between instances of 'complex' and 'complex'\n```\n\nTwo distinct elements only have the same bytes when they are NaNs that are\ndifferent objects (or containers of such NaNs).\n\nThe compiler can produce such a constant by folding, so the code object\ncannot be marshalled and no `.pyc` can be written for the module:\n\n```python\n>>> code = compile(\"x in {(1e999-1e999)*1j, (1e999-1e999)*2j}\", \"m.py\", \"exec\")\n>>> code.co_consts\n(inf, frozenset({(nan+nanj), (nan+nanj)}))\n>>> marshal.dumps(code)\nTypeError: '\u003c' not supported between instances of 'complex' and 'complex'\n```\n\nA related problem in the same code: float NaNs do compare, but neither way,\nso elements with equal bytes stay in set iteration order, which depends on\ntheir addresses.  If one of them is also referenced elsewhere in the dump,\nthe output differs for the same value:\n\n```python\nimport marshal\nnans = [float('nan') for _ in range(3)]\n# A list of a NaN and a set of three NaNs, one of which is that NaN.\nprint(len({marshal.dumps([n, set(nans)]) for n in nans}))   # 3, expected 1\n```\n\n### Proposed fix\n\nSort the elements on their marshalled bytes only and never compare the\nvalues.  That fixes the `TypeError` on its own.  Making the order of equal\nelements independent of addresses additionally needs the writer to know\nwhich objects it has already written; that part depends on the fix for gh-129724\n(coming).\n\n---\n\nDiscovered using Claude while doing a deep dive on pyc compilation determinism.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159196\n* gh-159197\n* gh-159205\n* gh-159206\n* gh-161276\n* gh-161286\n* gh-161287\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gpshead","@type":"Person","name":"gpshead"},"datePublished":"2026-10-11T17:32:31Z","url":"https://github.com/python/cpython/issues/159184"}

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:953cb0be-37d5-95ad-6b33-4bccff7b0a50
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB8F2:2E9D3B:2BC79B:36FDF3:6B020741
html-safe-nonceb4e763abe3731d0ec00cc66bf1046891adf6f7c0d7bb86c1a4631bec58d9be0d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEYyOjJFOUQzQjoyQkM3OUI6MzZGREYzOjZCMDIwNzQxIiwidmlzaXRvcl9pZCI6Ijg1MDI0MTI3ODEwMjk1NTgwODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac478b802f5dac2273c9f14a39392429a50908c0293ddeb5ce8abae1a46760907d
hovercard-subject-tagissue:5803459096
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/159184/issue_layout
twitter:imagehttps://opengraph.githubassets.com/35f1b44f12dd6596de54898323186409fc3224ab7bb225bc3efc39bf1b6ccdbc/python/cpython/issues/159184
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/35f1b44f12dd6596de54898323186409fc3224ab7bb225bc3efc39bf1b6ccdbc/python/cpython/issues/159184
og:image:altBug report marshal writes the elements of a set in the order of a sort of (marshalled bytes, value) pairs. When two elements have the same marshalled bytes, the sort compares the values. Complex nu...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegpshead
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/159184#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159184
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%2F159184
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/159184
Reloadhttps://github.com/python/cpython/issues/159184
Reloadhttps://github.com/python/cpython/issues/159184
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/159184
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159184
marshal.dumps() raises TypeError for a set containing several complex NaNshttps://github.com/python/cpython/issues/159184#top
https://github.com/gpshead
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/gpshead
gpsheadhttps://github.com/gpshead
on Oct 11, 2026https://github.com/python/cpython/issues/159184#issue-5803459096
gh-129724https://github.com/python/cpython/issues/129724
gh-159184: Do not compare set elements when marshalling a set #159196https://github.com/python/cpython/pull/159196
gh-159184: Make the marshal order of set elements with equal dumps stable #159197https://github.com/python/cpython/pull/159197
[3.15] gh-159184: Do not compare set elements when marshalling a set (GH-159196) #159205https://github.com/python/cpython/pull/159205
[3.14] gh-159184: Do not compare set elements when marshalling a set (GH-159196) #159206https://github.com/python/cpython/pull/159206
gh-159184: Do not intern NaN constants on the free-threaded build #161276https://github.com/python/cpython/pull/161276
[3.14] gh-159184: Do not intern NaN constants on the free-threaded build (GH-161276) #161286https://github.com/python/cpython/pull/161286
[3.15] gh-159184: Do not intern NaN constants on the free-threaded build (GH-161276) #161287https://github.com/python/cpython/pull/161287
gpsheadhttps://github.com/gpshead
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Oct 11, 2026https://github.com/python/cpython/issues/159184#event-32995985880
gpsheadhttps://github.com/gpshead
on Oct 11, 2026https://github.com/python/cpython/issues/159184#event-32996887863
StanFromIrelandhttps://github.com/StanFromIreland
stdlibStandard Library Python modules in the Lib/ directoryhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Oct 11, 2026https://github.com/python/cpython/issues/159184#event-32997207979
gpsheadhttps://github.com/gpshead
on Oct 11, 2026https://github.com/python/cpython/issues/159184#event-33005621840
pythongh-159184: Do not compare set elements when marshalling a sethttps://github.com/gpshead/cpython/commit/910690f4255203f7bbe71615b317819e875905d6
pythongh-159184https://github.com/python/cpython/issues/159184
910690fhttps://github.com/gpshead/cpython/commit/910690f4255203f7bbe71615b317819e875905d6
pythongh-159184: Do not compare set elements when marshalling a sethttps://github.com/gpshead/cpython/commit/544bf89a7972d4795a3936989f03abcc03872ebc
pythongh-159184https://github.com/python/cpython/issues/159184
544bf89https://github.com/gpshead/cpython/commit/544bf89a7972d4795a3936989f03abcc03872ebc
pythongh-159184: Make the marshal order of set elements with equal du…https://github.com/gpshead/cpython/commit/0e892229955b7418cd6424bd43a3f0d0a85f710a
pythongh-159184https://github.com/python/cpython/issues/159184
0e89222https://github.com/gpshead/cpython/commit/0e892229955b7418cd6424bd43a3f0d0a85f710a
gh-159184: Do not compare set elements when marshalling a set (GH-159196https://github.com/python/cpython/commit/1967a87ad395552dbd1e16fd3f13d3b4b2f694de
gh-159184https://github.com/python/cpython/issues/159184
GH-159196https://github.com/python/cpython/pull/159196
1967a87https://github.com/python/cpython/commit/1967a87ad395552dbd1e16fd3f13d3b4b2f694de
pythongh-159184: Make the marshal order of set elements with equal du…https://github.com/gpshead/cpython/commit/a4b8ab907bf5f06ae807a76e3bb3eb9d7607bd36
pythongh-159184https://github.com/python/cpython/issues/159184
a4b8ab9https://github.com/gpshead/cpython/commit/a4b8ab907bf5f06ae807a76e3bb3eb9d7607bd36
[3.14] gh-159184: Do not compare set elements when marshalling a set (G…https://github.com/python/cpython/commit/758278c2ebf4a77fc2a92a4d21f58c6a891391f4
gh-159184https://github.com/python/cpython/issues/159184
G…https://github.com/python/cpython/pull/159196
758278chttps://github.com/python/cpython/commit/758278c2ebf4a77fc2a92a4d21f58c6a891391f4
[3.15] gh-159184: Do not compare set elements when marshalling a set (G…https://github.com/python/cpython/commit/8c7ac5733ff69a120d3bc9f837d3e66bc9f1ad2a
gh-159184https://github.com/python/cpython/issues/159184
G…https://github.com/python/cpython/pull/159196
8c7ac57https://github.com/python/cpython/commit/8c7ac5733ff69a120d3bc9f837d3e66bc9f1ad2a
https://github.com/gpshead
gpsheadhttps://github.com/gpshead
on Oct 11, 2026https://github.com/python/cpython/issues/159184#issuecomment-6115249593
#159197https://github.com/python/cpython/pull/159197
#159192https://github.com/python/cpython/pull/159192
gpsheadhttps://github.com/gpshead
on Oct 13, 2026https://github.com/python/cpython/issues/159184#event-33101942875
pythongh-159184: Make the marshal order of set elements with equal du…https://github.com/gpshead/cpython/commit/b3dea86b74fba41bdf21da08c68cecc55d66f21b
pythongh-159184https://github.com/python/cpython/issues/159184
b3dea86https://github.com/gpshead/cpython/commit/b3dea86b74fba41bdf21da08c68cecc55d66f21b
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159184#event-33592157804
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/159184
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159184#event-33592177157
gpsheadhttps://github.com/gpshead
on Nov 1, 2026https://github.com/python/cpython/issues/159184#event-34811712160
gh-159184: Make the marshal order of set elements with equal dumps st…https://github.com/python/cpython/commit/3c23ebfdf7750cff757e50e6e8c753f89ce849c6
gh-159184https://github.com/python/cpython/issues/159184
3c23ebfhttps://github.com/python/cpython/commit/3c23ebfdf7750cff757e50e6e8c753f89ce849c6
hugovkhttps://github.com/hugovk
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 3, 2026https://github.com/python/cpython/issues/159184#event-35025747911
https://github.com/hugovk
hugovkhttps://github.com/hugovk
on Nov 3, 2026https://github.com/python/cpython/issues/159184#issuecomment-6605829177
https://buildbot.python.org/#/builders/1368/builds/6004https://buildbot.python.org/#/builders/1368/builds/6004
https://buildbot.python.org/#/builders/1610/builds/4264https://buildbot.python.org/#/builders/1610/builds/4264
hugovkhttps://github.com/hugovk
on Nov 3, 2026https://github.com/python/cpython/issues/159184#event-35026216393
pythonhttps://github.com/python
kadrqwerhttps://github.com/kadrqwer
on Nov 4, 2026https://github.com/python/cpython/issues/159184#event-35080530746
gpsheadhttps://github.com/gpshead
on Nov 4, 2026https://github.com/python/cpython/issues/159184#event-35080665218
gh-159184: Do not intern NaN constants on the free-threaded build (GH…https://github.com/python/cpython/commit/1db5966141a9ca736add1a9699dde926e8099b14
gh-159184https://github.com/python/cpython/issues/159184
GH…https://github.com/python/cpython/pull/161276
1db5966https://github.com/python/cpython/commit/1db5966141a9ca736add1a9699dde926e8099b14
https://github.com/gpshead
gpsheadhttps://github.com/gpshead
on Nov 4, 2026https://github.com/python/cpython/issues/159184#issuecomment-6619422322
#161276https://github.com/python/cpython/pull/161276
gpsheadhttps://github.com/gpshead
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 4, 2026https://github.com/python/cpython/issues/159184#event-35080705750
gpsheadhttps://github.com/gpshead
on Nov 5, 2026https://github.com/python/cpython/issues/159184#event-35291579517
[3.15] gh-159184: Do not intern NaN constants on the free-threaded bu…https://github.com/python/cpython/commit/476b725e461c43145b51700f080a58f302ed3dfb
gh-159184https://github.com/python/cpython/issues/159184
476b725https://github.com/python/cpython/commit/476b725e461c43145b51700f080a58f302ed3dfb
[3.14] gh-159184: Do not intern NaN constants on the free-threaded bu…https://github.com/python/cpython/commit/a2be2bf8535bf93fe6c0c28ca64f56df9ca4b80a
gh-159184https://github.com/python/cpython/issues/159184
a2be2bfhttps://github.com/python/cpython/commit/a2be2bf8535bf93fe6c0c28ca64f56df9ca4b80a
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/159184
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/159184
gpsheadhttps://github.com/gpshead
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.