This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: mimetypes initialization fails on Windows because of TypeError
Type: behavior Stage: resolved
Components: Windows Versions: Python 2.7
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 2022-04-11 14:58 by admin. 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 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:

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: 
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 "", line 18, in <module>
    exec(, command_ns)
  File "<string>", line 11, in <module>
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\", line 11, in <module>
    from setuptools.extension import Extension
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\", line 8, in <module>
    from .dist import _get_unpatched
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\", line 16, in <module>
    from setuptools.depends import Require
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\", line 6, in <module>
    from setuptools import compat
  File "c:\users\sl\appdata\local\temp\tmpoaaddk\setuptools-12.0.5\setuptools\", line 19, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "C:\Python27\lib\", line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "C:\Python27\lib\", line 214, in SimpleHTTPRequestHandler
    mimetypes.init() # try to read system mime.types
  File "C:\Python27\lib\", line 351, in init
  File "C:\Python27\lib\", 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.


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 <>
> <>
> _______________________________________
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).
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67560
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