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.MimeType UnicodeDecodeError #65337
Comments
when new a mimetypes.MimeType instance in a my Windows, whose default coding is mbcs, UnicdeDecodeError occurred. Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mimetypes import MimeTypes
>>> mt = MimeTypes()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python27\lib\mimetypes.py", line 66, in __init__
init()
File "D:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "D:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "D:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position 8: ordinal
not in range(128) i think this error was caused by the code in mimetypes.py's line 256 default_encoding = sys.getdefaultencoding()
if change this line to:
default_encoding = sys.getfilesystemencoding() such error will be resolved |
tanbro
mannequin
added
stdlib
Python modules in the Lib dir
type-bug
An unexpected behavior, bug, or error
labels
Apr 3, 2014
and in line 249, changes: if isinstance(ctype, unicode):
ctype = ctype.encode(default_encoding) # omit in 3.x! |
The unlinked push message was for bpo-21139. |
This looks like a duplicate of bpo-9291; could you test the latest patch over there, please? |
Fixed by bpo-9291 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: