[Python-checkins] r85776 - in python/branches/release27-maint: Lib/mimetypes.py Misc/NEWS
brian.curtin
python-checkins at python.org
Thu Oct 21 16:48:23 CEST 2010
Author: brian.curtin
Date: Thu Oct 21 16:48:22 2010
New Revision: 85776
Log:
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.
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Lib/mimetypes.py
python/branches/release27-maint/Misc/NEWS
Modified: python/branches/release27-maint/Lib/mimetypes.py
==============================================================================
--- python/branches/release27-maint/Lib/mimetypes.py (original)
+++ python/branches/release27-maint/Lib/mimetypes.py Thu Oct 21 16:48:22 2010
@@ -257,18 +257,19 @@
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):
Modified: python/branches/release27-maint/Misc/NEWS
==============================================================================
--- python/branches/release27-maint/Misc/NEWS (original)
+++ python/branches/release27-maint/Misc/NEWS Thu Oct 21 16:48:22 2010
@@ -60,6 +60,9 @@
Library
-------
+- Issue #10163: Skip unreadable registry keys during mimetypes
+ initialization.
+
- Issue #5117: Fixed root directory related issue on posixpath.relpath() and
ntpath.relpath().
More information about the Python-checkins
mailing list