classification
Title: mimetypes initialization fails on Windows because of TypeError
Type: behavior Stage: resolved
Components: Windows Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Python 3.4.1 Installer ended prematurely (Windows msi)
View: 22028
Assigned To: Nosy List: Slion, berker.peksag, r.david.murray, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2015-02-01 15:58 by Slion, last changed 2016-04-02 06:26 by berker.peksag. This issue is now closed.

Messages (6)
msg235179 - (view) Author: Stéphane Lenclud (Slion) Date: 2015-02-01 15:58
On my Windows 7 installation mimetypes.py in read_windows_registry _winreg.OpenKey can throw a TypeError exception which is not handled and interrupts the execution.

To fix it I added:
except TypeError:
    continue

To reproduce it I just need to run te following:
c:\python27\python -c "import mimetypes; mimetypes.init()"

This error is obviously due to the content of my registry.
The subkeyname causing issues have names like: 
{hexid-hexid-hexid-hexid-hexid}
msg235186 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-02-01 17:33
Is this a duplicate of issue 9291?
msg235188 - (view) Author: Stéphane Lenclud (Slion) Date: 2015-02-01 18:13
I don't think so.
Here is the traceback btw:
  File "setup.py", line 18, in <module>
    exec(init_file.read(), command_ns)
  File "<string>", line 11, in <module>
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\__init__.py", line 11, in <module>
    from setuptools.extension import Extension
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\extension.py", line 8, in <module>
    from .dist import _get_unpatched
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\dist.py", line 16, in <module>
    from setuptools.depends import Require
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\depends.py", line 6, in <module>
    from setuptools import compat
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\compat.py", line 19, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "C:\Python27\lib\SimpleHTTPServer.py", line 214, in SimpleHTTPRequestHandler
    mimetypes.init() # try to read system mime.types
  File "C:\Python27\lib\mimetypes.py", line 351, in init
    db.read_windows_registry()
  File "C:\Python27\lib\mimetypes.py", line 254, in read_windows_registry
    with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: must be string without null bytes or None, not str
Something went wrong during the installation.
msg235198 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-02-01 19:10
Definitely a dup, though I don't have the number handy. There's a patch on the other issue waiting for a mimetypes maintainer to step up.
msg235199 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2015-02-01 19:22
It's right there on my to-do list which is, unfortunately, not getting 
any shorter.

TJG

On 01/02/2015 19:10, Steve Dower wrote:
>
> Steve Dower added the comment:
>
> Definitely a dup, though I don't have the number handy. There's a patch on the other issue waiting for a mimetypes maintainer to step up.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue23371>
> _______________________________________
>
msg262790 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-04-02 06:26
This is a duplicate of issue 22028 (fixed in 2.7 in 7c4c4e43c452).
History
Date User Action Args
2016-04-02 06:26:18berker.peksagsetstatus: open -> closed

superseder: Python 3.4.1 Installer ended prematurely (Windows msi)

nosy: + berker.peksag
messages: + msg262790
resolution: duplicate
stage: resolved
2015-02-01 19:22:39tim.goldensetmessages: + msg235199
2015-02-01 19:10:20steve.dowersetmessages: + msg235198
2015-02-01 18:13:27Slionsetmessages: + msg235188
2015-02-01 17:33:46r.david.murraysetnosy: + r.david.murray
messages: + msg235186
2015-02-01 15:58:40Slioncreate