René's URL Explorer Experiment


Title: Regression on initialization and new non-deterministic behavior issue in mimetypes · Issue #93417 · python/cpython · GitHub

Open Graph Title: Regression on initialization and new non-deterministic behavior issue in mimetypes · Issue #93417 · python/cpython

X Title: Regression on initialization and new non-deterministic behavior issue in mimetypes · Issue #93417 · python/cpython

Description: Bug report Mimetypes should NOT include defaults when initialized with file(s) This is a follow up from https://bugs.python.org/issue4963 that led to this merged PR by @davidkhess #3062 I reported the issue in https://bugs.python.org/iss...

Open Graph Description: Bug report Mimetypes should NOT include defaults when initialized with file(s) This is a follow up from https://bugs.python.org/issue4963 that led to this merged PR by @davidkhess #3062 I reported ...

X Description: Bug report Mimetypes should NOT include defaults when initialized with file(s) This is a follow up from https://bugs.python.org/issue4963 that led to this merged PR by @davidkhess #3062 I reported ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression on initialization and new non-deterministic behavior issue in mimetypes","articleBody":"**Bug report**\r\n\r\nMimetypes should NOT include defaults when initialized with file(s) \r\n\r\nThis is a follow up from https://bugs.python.org/issue4963 that led to this merged PR by @davidkhess https://github.com/python/cpython/pull/3062\r\n\r\nI reported the issue in https://bugs.python.org/issue4963#msg384730 : \r\n\r\n> \r\n> \r\n> The changes introduced by this ticket in https://github.com/python/cpython/commit/9fc720e5e4f772598013ea48a3f0d22b2b6b04fa#r45794801 are problematic.\r\n> \r\n> I discovered this from having tests failing when testing on Python 3.7 and up\r\n> \r\n> The bug is that calling mimetypes.init(files) will NOT use my files, but instead use both my files and knownfiles.\r\n> This was not the case before as knownfiles would be ignored as expected when I provide my own files list.\r\n> \r\n> This is a breaking API change IMHO and  introduces a buggy instability : even if I want to ignore knownfiles by providing my list of of files, knownfiles will always be added and this results in erratic and buggy behaviour as the content of \"knownfiles\" is completely random based on the OS version and else. \r\n> \r\n> The code I am using is here https://github.com/nexB/typecode/blob/ba07c04d23441d3469dc5de911376d408514ebd8/src/typecode/contenttype.py#L308\r\n> \r\n> I think we should reopen to fix (or create a new ticket)\r\n> \r\n> Actually this is problematic on multiples counts:\r\n> 1. the behaviour changes and this is a regression\r\n> 2. even if that new buggy behaviour was the one to use, it should not give preference to knownfiles over init-provided files, but at least take the provided files first and knownfiles second.\r\n\r\n\r\nSee also this thread https://github.com/python/cpython/commit/9fc720e5e4f772598013ea48a3f0d22b2b6b04fa#r45794801\r\n\r\n@pombredanne\r\npombredanne on Jan 9, 2021 Contributor\r\n> \r\n> This introduces a buggy unstability starting with Python 3.7: even if I want to ignore knownfiles by providing my list of of files, knownfiles will always be added and this results in erratic and buggy behaviour as the content of \"knownfiles\" is completely random based on the OS version and else.\r\n> \r\n@adeadman\r\nadeadman 2 hours ago\r\n> \r\n> @davidkhess this has resulted in an undocumented change to the behaviour of calling mimetypes.init(files=[\"mimetype_list\"]) as now the defaults are included where they weren't before Python 3.7.\r\n> \r\n> I'm not sure how this can be fixed without breaking compatibility or principle of least surprise somewhere - perhaps by adding a new kwarg to init() that ignores knownfiles?\r\n> \r\n\r\n@pombredanne\r\npombredanne 1 hour ago Contributor\r\n> \r\n> @adeadman re:\r\n> \r\n>>   I'm not sure how this can be fixed without breaking compatibility or principle of least surprise somewhere - perhaps by adding a new kwarg to init() that ignores knownfiles?\r\n> \r\n> IMHO the current un-documented behaviour is a bug so fixing this would not be an API breakage.\r\n> Also the changelog is lying:\r\n> \r\n>>  Fixed non-deterministic behavior related to mimetypes extension mapping and module reinitialization.\r\n> \r\n> The behaviour used to be mostly deterministic and is now non-deterministic.\r\n> \r\n\r\nAnd  @adeadman also posted in https://github.com/python/cpython/pull/3062#issuecomment-1143694827\r\n\r\n> This change has resulted in a difference in behaviour from previous versions of Python in that even when specifying files as a parameter to init(), the known files are loaded, which is not the case in previous versions. This causes problems when an application wishes to use the mimetypes database with an internal-only mapping of mimetypes, to work around inconsistencies with mimetypes in the known files list (which can vary between systems).\r\n> \r\n> Unfortunately this change wasn't documented in the changelog either, nor in the docstring comments, so it can only be found by examining the commit history for the code in cpython.\r\n> \r\n> Would it be appropriate to add another kwarg to init() indicating that knownfiles are to be ignored/excluded from the DB initialization?\r\n\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-141393\n* gh-150725\n* gh-150733\n* gh-153748\n* gh-153749\n* gh-153750\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pombredanne","@type":"Person","name":"pombredanne"},"datePublished":"2022-06-01T16:30:35Z","url":"https://github.com/python/cpython/issues/93417"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8bd3e996-363a-9812-dfd3-d38cd8ee48fe
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDF4A:3F90DC:384FA2:4D479A:6AECC9DF
html-safe-nonce514389c348593bb7255b636d08df2dfdbaae4aa92810ec2fa0cb53aefe3e49f3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjRBOjNGOTBEQzozODRGQTI6NEQ0NzlBOjZBRUNDOURGIiwidmlzaXRvcl9pZCI6IjQyNzY5MzAwODAxMjMxNzc0MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0507d00567fdb0c6c7f7f27531decea7657440a2d34e36c64072de16a0f5fb07
hovercard-subject-tagissue:1256440056
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/93417/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5ba20932545c92ff928ad087bf764d987f989494bb9d660a761f23ed06f5e785/python/cpython/issues/93417
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5ba20932545c92ff928ad087bf764d987f989494bb9d660a761f23ed06f5e785/python/cpython/issues/93417
og:image:altBug report Mimetypes should NOT include defaults when initialized with file(s) This is a follow up from https://bugs.python.org/issue4963 that led to this merged PR by @davidkhess #3062 I reported ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepombredanne
hostnamegithub.com
expected-hostnamegithub.com
Nonedc0b519c5798dc1150b88dc4c06a8b9634d0069218dc04e469970e76aad74016
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
releasedb139f0bf57b59bf9a8c4abb0849924d6c6ca559
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/93417#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F93417
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%2F93417
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/93417
Reloadhttps://github.com/python/cpython/issues/93417
Reloadhttps://github.com/python/cpython/issues/93417
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.3k (2.3k)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/pulse
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/93417
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/93417
Regression on initialization and new non-deterministic behavior issue in mimetypeshttps://github.com/python/cpython/issues/93417#top
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
topic-emailhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-email%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/pombredanne
pombredannehttps://github.com/pombredanne
on Jun 1, 2022https://github.com/python/cpython/issues/93417#issue-1256440056
https://bugs.python.org/issue4963https://bugs.python.org/issue4963
@davidkhesshttps://github.com/davidkhess
#3062https://github.com/python/cpython/pull/3062
https://bugs.python.org/issue4963#msg384730https://bugs.python.org/issue4963#msg384730
9fc720e#r45794801https://github.com/python/cpython/commit/9fc720e5e4f772598013ea48a3f0d22b2b6b04fa#r45794801
https://github.com/nexB/typecode/blob/ba07c04d23441d3469dc5de911376d408514ebd8/src/typecode/contenttype.py#L308https://github.com/nexB/typecode/blob/ba07c04d23441d3469dc5de911376d408514ebd8/src/typecode/contenttype.py#L308
9fc720e#r45794801https://github.com/python/cpython/commit/9fc720e5e4f772598013ea48a3f0d22b2b6b04fa#r45794801
@pombredannehttps://github.com/pombredanne
@adeadmanhttps://github.com/adeadman
@davidkhesshttps://github.com/davidkhess
@pombredannehttps://github.com/pombredanne
@adeadmanhttps://github.com/adeadman
@adeadmanhttps://github.com/adeadman
#3062 (comment)https://github.com/python/cpython/pull/3062#issuecomment-1143694827
gh-93417: Update mimetypes.init() doc to match the code #141393https://github.com/python/cpython/pull/141393
gh-93417: Improve test_mimetypes #150725https://github.com/python/cpython/pull/150725
gh-93417: Add use_system_defaults option for mimetypes #150733https://github.com/python/cpython/pull/150733
[3.15] gh-93417: Improve test_mimetypes (GH-150725) #153748https://github.com/python/cpython/pull/153748
[3.14] gh-93417: Improve test_mimetypes (GH-150725) #153749https://github.com/python/cpython/pull/153749
[3.13] gh-93417: Improve test_mimetypes (GH-150725) #153750https://github.com/python/cpython/pull/153750
pombredannehttps://github.com/pombredanne
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Jun 1, 2022https://github.com/python/cpython/issues/93417#event-6720813990
https://github.com/davidkhess
davidkhesshttps://github.com/davidkhess
on Jun 1, 2022https://github.com/python/cpython/issues/93417#issuecomment-1143871733
https://bugs.python.org/issue4963https://bugs.python.org/issue4963
https://bugs.python.org/issue4963#msg108934https://bugs.python.org/issue4963#msg108934
davidkhesshttps://github.com/davidkhess
on Jun 1, 2022https://github.com/python/cpython/issues/93417#event-6721057000
bpo-4963: Fix for initialization and non-deterministic behavior issue…https://github.com/python/cpython/commit/9fc720e5e4f772598013ea48a3f0d22b2b6b04fa
bpo-4963https://bugs.python.org/issue?@action=redirect&bpo=4963
9fc720ehttps://github.com/python/cpython/commit/9fc720e5e4f772598013ea48a3f0d22b2b6b04fa
https://github.com/adeadman
adeadmanhttps://github.com/adeadman
on Jun 1, 2022https://github.com/python/cpython/issues/93417#issuecomment-1143986107
@davidkhesshttps://github.com/davidkhess
@pombredannehttps://github.com/pombredanne
AA-Turnerhttps://github.com/AA-Turner
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.10 (EOL)end of lifehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.10%20(EOL)%22
topic-emailhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-email%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
on Jun 1, 2022https://github.com/python/cpython/issues/93417#event-6723547855
https://github.com/bebound
beboundhttps://github.com/bebound
on Nov 11, 2025https://github.com/python/cpython/issues/93417#issuecomment-3515679843
[CVE-2024-3220] Default mimetype known files writeable on Windowshttps://mail.python.org/archives/list/security-announce@python.org/thread/CDXW34ND2LSAOYAR5N6UNONP4ZBX4D6R/
#141393https://github.com/python/cpython/pull/141393
serhiy-storchakahttps://github.com/serhiy-storchaka
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.10 (EOL)end of lifehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.10%20(EOL)%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
on Jun 1, 2026https://github.com/python/cpython/issues/93417#event-26175545109
serhiy-storchakahttps://github.com/serhiy-storchaka
on Jun 1, 2026https://github.com/python/cpython/issues/93417#event-26198123137
pythongh-93417: Improve test_mimetypeshttps://github.com/serhiy-storchaka/cpython/commit/e51580105c2eaae81c6da3b2785fec0690de6ae7
pythongh-93417https://github.com/python/cpython/issues/93417
e515801https://github.com/serhiy-storchaka/cpython/commit/e51580105c2eaae81c6da3b2785fec0690de6ae7
gh-93417: Improve test_mimetypes (GH-150725)https://github.com/python/cpython/commit/b23646adf1f484d6ee61ea04529b48443508715a
gh-93417https://github.com/python/cpython/issues/93417
GH-150725https://github.com/python/cpython/pull/150725
b23646ahttps://github.com/python/cpython/commit/b23646adf1f484d6ee61ea04529b48443508715a
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Jun 1, 2026https://github.com/python/cpython/issues/93417#issuecomment-4596174532
#150733https://github.com/python/cpython/pull/150733
serhiy-storchakahttps://github.com/serhiy-storchaka
on Jul 15, 2026https://github.com/python/cpython/issues/93417#event-28006990326
[3.13] gh-93417: Improve test_mimetypes (GH-150725) (GH-153750)https://github.com/python/cpython/commit/824df7fe7a38cfa1326f242031c19475cc26fdf4
gh-93417https://github.com/python/cpython/issues/93417
GH-150725https://github.com/python/cpython/pull/150725
GH-153750https://github.com/python/cpython/pull/153750
824df7fhttps://github.com/python/cpython/commit/824df7fe7a38cfa1326f242031c19475cc26fdf4
[3.14] gh-93417: Improve test_mimetypes (GH-150725) (GH-153749)https://github.com/python/cpython/commit/d4e7a842ce81a18aa5e2e7d071768f0a9892d97b
gh-93417https://github.com/python/cpython/issues/93417
GH-150725https://github.com/python/cpython/pull/150725
GH-153749https://github.com/python/cpython/pull/153749
d4e7a84https://github.com/python/cpython/commit/d4e7a842ce81a18aa5e2e7d071768f0a9892d97b
[3.15] gh-93417: Improve test_mimetypes (GH-150725) (GH-153748)https://github.com/python/cpython/commit/22eff887f7565d24b6ba54bc147672d3ecdd8cf7
gh-93417https://github.com/python/cpython/issues/93417
GH-150725https://github.com/python/cpython/pull/150725
GH-153748https://github.com/python/cpython/pull/153748
22eff88https://github.com/python/cpython/commit/22eff887f7565d24b6ba54bc147672d3ecdd8cf7
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/93417
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/93417
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
topic-emailhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-email%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.