-
-
Notifications
You must be signed in to change notification settings - Fork 43.9k
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
mimetypes can't get demo.js type #11396
Comments
@WHG555 I'm thinking this was fixed in newer versions of python3. You should check this doc: https://www.iana.org/assignments/media-types/media-types.xhtml I tried the guess_type function in python 3.8.2
output: 3.8.2 (default, Mar 13 2020, 10:14:16) |
I'm using version 3.12 and I'm still having this issue. It's on Windows, it will only appear. |
Windows 10 1903
ubuntu
.js is "text/plain" in Windows |
This is not the repo for Python; it's the Python section of a project called "The Algorithms". You can find the Python repo at: python/cpython That aside, I should note that
Having a quick glance over the source code, I notice two things. First, there seems to be different logic for the instance method import mimetypes
mt = mimetypes.MimeTypes()
mt.guess_all_extensions('text/plain')
# ['.txt', '.bat', '.c', '.h', '.ksh', '.pl', '.srt']
mt.guess_all_extensions('text/javascript')
# ['.js', '.mjs']
# Does this give you the MIME type you're expecting?
type, _ = mt.guess_type('example.js') As you can see, I get different results for Second, it appears that the MIME types are in some situations read from the Windows registry: 1 2 3 I would take that, combined with my differing results, to suggest that what you're experiencing an issue with your Windows configuration rather than Python itself. I confess I don't know how Windows populates its MIME type database, but hopefully that's a pointer for where you should look next. |
Closing because this has nothing to do with the Python Algorithms repo. |
Repository commit
none
Python version (python --version)
Python 3.12.3
Dependencies version (pip freeze)
none
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: