summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-10-21 14:48:22 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-10-21 14:48:22 (GMT)
commit4cc5403527e255bb4942b3ef8bca1b7f65781c29 (patch)
treef1d12a195f411e3c60dda91346e0f8e0eaf979a4
parent045bbcdc8e1c745e49d3f4b0d79ca8182375bce0 (diff)
downloadcpython-4cc5403527e255bb4942b3ef8bca1b7f65781c29.zip
cpython-4cc5403527e255bb4942b3ef8bca1b7f65781c29.tar.gz
cpython-4cc5403527e255bb4942b3ef8bca1b7f65781c29.tar.bz2
Merged revisions 85774 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85774 | brian.curtin | 2010-10-21 09:11:48 -0500 (Thu, 21 Oct 2010) | 7 lines Fix #10162: Add try/except around _winreg.OpenKey for keys that are unreadable by all users, e.g., Flash, Silverlight, and Java keys were causing errors. We don't currently have a way to grant/deny permissions for a key via winreg so there are no tests for this. ........
-rw-r--r--Lib/mimetypes.py25
-rw-r--r--Misc/NEWS3
2 files changed, 16 insertions, 12 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 816f6cd..4c054c9 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -257,18 +257,19 @@ class MimeTypes:
with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
r'MIME\Database\Content Type') as mimedb:
for ctype in enum_types(mimedb):
- with _winreg.OpenKey(mimedb, ctype) as key:
- try:
- suffix, datatype = _winreg.QueryValueEx(key, 'Extension')
- except EnvironmentError:
- continue
- if datatype != _winreg.REG_SZ:
- continue
- try:
- suffix = suffix.encode(default_encoding) # omit in 3.x!
- except UnicodeEncodeError:
- continue
- self.add_type(ctype, suffix, strict)
+ try:
+ with _winreg.OpenKey(mimedb, ctype) as key:
+ suffix, datatype = _winreg.QueryValueEx(key,
+ 'Extension')
+ except EnvironmentError:
+ continue
+ if datatype != _winreg.REG_SZ:
+ continue
+ try:
+ suffix = suffix.encode(default_encoding) # omit in 3.x!
+ except UnicodeEncodeError:
+ continue
+ self.add_type(ctype, suffix, strict)
def guess_type(url, strict=True):
diff --git a/Misc/NEWS b/Misc/NEWS
index f25664a..d25e25e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,9 @@ Core and Builtins
Library
-------
+- Issue #10163: Skip unreadable registry keys during mimetypes
+ initialization.
+
- Issue #5117: Fixed root directory related issue on posixpath.relpath() and
ntpath.relpath().