Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-35292: Avoid call mimetypes.init when http.server is imported #17822

Merged
merged 2 commits into from Jan 8, 2020

Conversation

@aisk
Copy link
Contributor

aisk commented Jan 4, 2020

Proxy the http.server.SimpleHTTPRequestHandler.guess_type to mimetypes.guess_type so the mimetypes.init is called lazily to avoid unnecessary costs when the file is imported.

The default extensions_map is checked before call mimetypes.guess_type, with default value in mimetypes.encodings_map, for don't let mimetypes.guess_type returns the mine type besides the encoding type.

This method is implemented as https://bugs.python.org/issue35292#msg331739 said @zooba

https://bugs.python.org/issue35292

@zooba

This comment has been minimized.

Copy link
Member

zooba commented Jan 6, 2020

SimpleHTTPRequestHandler.extensions_map is documented (presumably in Doc/library/http.server.rst), so let's also add a note there clarifying that it "contains custom overrides for the default system mappings". Also add a `.. versionchanged: 3.9 This dictionary is no longer filled with the default system mappings, but only contains overrides." (properly formatted)

I think this deserves a NEWS entry - the failed check's Details link will help you add it.

@aisk aisk force-pushed the aisk:bpo-35292 branch from 804fefd to 5587cd1 Jan 8, 2020
@aisk aisk force-pushed the aisk:bpo-35292 branch from 51fc4cb to 47d71b3 Jan 8, 2020
@aisk

This comment has been minimized.

Copy link
Contributor Author

aisk commented Jan 8, 2020

Hi @zooba updated.

@zooba

This comment has been minimized.

Copy link
Member

zooba commented Jan 8, 2020

Thanks! The macOS failure doesn't seem to be your fault, and Azure Pipelines passed it, so I'll merge.

@zooba zooba merged commit 5907e61 into python:master Jan 8, 2020
8 of 9 checks passed
8 of 9 checks passed
Docs
Details
Windows (x86)
Details
Windows (x64)
Details
macOS macOS
Details
Ubuntu
Details
Azure Pipelines PR #20200108.16 succeeded
Details
bedevere/issue-number Issue number 35292 found
Details
bedevere/news News entry found in Misc/NEWS.d
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@aisk aisk deleted the aisk:bpo-35292 branch Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.