René's URL Explorer Experiment


Title: utf-8-sig: UnicodeDecodeError offsets do not count the BOM · Issue #159071 · python/cpython · GitHub

Open Graph Title: utf-8-sig: UnicodeDecodeError offsets do not count the BOM · Issue #159071 · python/cpython

X Title: utf-8-sig: UnicodeDecodeError offsets do not count the BOM · Issue #159071 · python/cpython

Description: Bug report When the input starts with a BOM, the utf-8-sig codec reports UnicodeDecodeError offsets relative to the input without the BOM, i.e. error.start is off-by-3: data = b"\xef\xbb\xbf\xff" # Invalid byte at position 3 try: data.de...

Open Graph Description: Bug report When the input starts with a BOM, the utf-8-sig codec reports UnicodeDecodeError offsets relative to the input without the BOM, i.e. error.start is off-by-3: data = b"\xef\xbb\xbf\xff" #...

X Description: Bug report When the input starts with a BOM, the utf-8-sig codec reports UnicodeDecodeError offsets relative to the input without the BOM, i.e. error.start is off-by-3: data = b"\xef\xbb\xbf\x...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"utf-8-sig: UnicodeDecodeError offsets do not count the BOM","articleBody":"### Bug report\n\nWhen the input starts with a BOM, the utf-8-sig codec reports `UnicodeDecodeError` offsets relative to the input without the BOM, i.e. `error.start` is off-by-3:\n\n```python\ndata = b\"\\xef\\xbb\\xbf\\xff\"  # Invalid byte at position 3\ntry:\n    data.decode(\"utf-8-sig\")\nexcept UnicodeDecodeError as e:\n    print(e)  # 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte\n```\n\nThe input is being sliced in `utf_8_sig.py` to remove the BOM, but raised exceptions are not modified to correct the offsets and object attributes. This occurs in a few places, e.g. https://github.com/python/cpython/blob/5a22a62b96a68c2dd31784c5e3427ad7b365388a/Lib/encodings/utf_8_sig.py#L18-L24\n\nThe utf-16 and utf-32 codecs also remove the BOM, but it is included in the offsets and object attributes in their errors, so this looks like an oversight.\n\n### CPython versions tested on:\n\n3.14, 3.15rc2\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159081\n* gh-159082\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/alicederyn","@type":"Person","name":"alicederyn"},"datePublished":"2026-10-09T13:27:44Z","url":"https://github.com/python/cpython/issues/159071"}

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:424e01d9-50ca-513b-43b3-1ea311699590
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8A20:AB8A2:4A61F7:66B329:6AFDE57C
html-safe-noncef1b440cc4155ad7ae2acf32160657e6f49dd4ed176eaef76c0b23b1020129f40
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTIwOkFCOEEyOjRBNjFGNzo2NkIzMjk6NkFGREU1N0MiLCJ2aXNpdG9yX2lkIjoiMzQxNzMzMjI0MTcxNjM0MDA5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca67188837ff6731089eec380935e1ca7fddb95ad5905568da925cdda9a9a0f78
hovercard-subject-tagissue:5778883975
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/159071/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7e8aa987d9a1a84d533dd2cbc3bd0fccfce4d7328ae43d720d45ecd053578322/python/cpython/issues/159071
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7e8aa987d9a1a84d533dd2cbc3bd0fccfce4d7328ae43d720d45ecd053578322/python/cpython/issues/159071
og:image:altBug report When the input starts with a BOM, the utf-8-sig codec reports UnicodeDecodeError offsets relative to the input without the BOM, i.e. error.start is off-by-3: data = b"\xef\xbb\xbf\xff" #...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamealicederyn
hostnamegithub.com
expected-hostnamegithub.com
None91ef1a291a064ac31ac459ab3f75261dbdd924c41ea5bd027e591c5b46cc9ce7
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
released62bc98ce2346f4006e4a2810e9e22f37e7e6422
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/159071#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159071
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%2F159071
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/159071
Reloadhttps://github.com/python/cpython/issues/159071
Reloadhttps://github.com/python/cpython/issues/159071
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/159071
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159071
#159081https://github.com/python/cpython/pull/159081
utf-8-sig: UnicodeDecodeError offsets do not count the BOMhttps://github.com/python/cpython/issues/159071#top
#159081https://github.com/python/cpython/pull/159081
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/alicederyn
alicederynhttps://github.com/alicederyn
on Oct 9, 2026https://github.com/python/cpython/issues/159071#issue-5778883975
cpython/Lib/encodings/utf_8_sig.pyhttps://github.com/python/cpython/blob/5a22a62b96a68c2dd31784c5e3427ad7b365388a/Lib/encodings/utf_8_sig.py#L18-L24
5a22a62https://github.com/python/cpython/commit/5a22a62b96a68c2dd31784c5e3427ad7b365388a
gh-159071: Correct UnicodeDecodeError offsets in utf-8-sig codec when input starts with BOM #159081https://github.com/python/cpython/pull/159081
gh-159071: Fix utf-8-sig decode error offsets #159082https://github.com/python/cpython/pull/159082
alicederynhttps://github.com/alicederyn
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Oct 9, 2026https://github.com/python/cpython/issues/159071#event-32878607613
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 Oct 10, 2026https://github.com/python/cpython/issues/159071#event-32935787283
picnixzhttps://github.com/picnixz
Codecs and encodings issueshttps://github.com/orgs/python/projects/24
on Oct 10, 2026https://github.com/python/cpython/issues/159071#event-33006616499
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159071#event-33592155896
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/159071
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159071#event-33592175091
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/159071
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/159071
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
Codecs and encodings issueshttps://github.com/orgs/python/projects/24
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.