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

mimetypes.py under windows - bad exception catch #58114

Closed
mclander mannequin opened this issue Jan 29, 2012 · 2 comments
Closed

mimetypes.py under windows - bad exception catch #58114

mclander mannequin opened this issue Jan 29, 2012 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@mclander
Copy link
Mannequin

mclander mannequin commented Jan 29, 2012

BPO 13906
Nosy @bitdancer
Superseder
  • bpo-9291: mimetypes initialization fails on Windows because of non-Latin characters in registry
  • 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:

    assignee = None
    closed_at = <Date 2012-01-29.22:27:56.409>
    created_at = <Date 2012-01-29.22:18:06.809>
    labels = ['type-bug', 'library']
    title = 'mimetypes.py under windows - bad exception catch'
    updated_at = <Date 2012-01-29.22:27:56.407>
    user = 'https://bugs.python.org/mclander'

    bugs.python.org fields:

    activity = <Date 2012-01-29.22:27:56.407>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-01-29.22:27:56.409>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2012-01-29.22:18:06.809>
    creator = 'mclander'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 13906
    keywords = []
    message_count = 2.0
    messages = ['152267', '152268']
    nosy_count = 2.0
    nosy_names = ['r.david.murray', 'mclander']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '9291'
    type = 'behavior'
    url = 'https://bugs.python.org/issue13906'
    versions = ['Python 2.7']

    @mclander
    Copy link
    Mannequin Author

    mclander mannequin commented Jan 29, 2012

    mimetypes.py(249) expectts Unicode*En*codeError, but Unicode*De*codeError happens when registry has non latin symbols (Vista Home 64).

    I just change cathc jn next line to UnicodeDecodeError and all now works fine. But may be error not here, but on encode method which raise "negative" exception

    F:\>c:\python27\python -m SimpleHTTPServer
    Traceback (most recent call last):
      File "test.py", line 2, in <module>
        import SimpleHTTPServer
      File "c:\python27\lib\SimpleHTTPServer.py", line 27, in <module>
        class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
      File "c:\python27\lib\SimpleHTTPServer.py", line 204, in SimpleHTTPRequestHandler
        mimetypes.init() # try to read system mime.types
      File "c:\python27\lib\mimetypes.py", line 355, in init
        db.read_windows_registry()
      File "c:\python27\lib\mimetypes.py", line 259, in read_windows_registry
        for ctype in enum_types(mimedb):
      File "c:\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 0xe0 in position 0: ordinal not in range(128)

    ---------- here after changes -----------------

    F:\>c:\python27\python -m SimpleHTTPServer
    Serving HTTP on 0.0.0.0 port 8000 ...
    mc-quad - - [30/Jan/2012 02:02:18] "GET / HTTP/1.1" 200 -
    mc-quad - - [30/Jan/2012 02:02:18] code 404, message File not found
    mc-quad - - [30/Jan/2012 02:02:18] "GET /favicon.ico HTTP/1.1" 404 -

    @mclander mclander mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 29, 2012
    @bitdancer
    Copy link
    Member

    This is a duplicate of bpo-9291.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant