summaryrefslogtreecommitdiffstats
path: root/Lib/mimetypes.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/mimetypes.py')
-rw-r--r--Lib/mimetypes.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index d5d0fc3..9e7cbe8 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -253,14 +253,16 @@ 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
- self.add_type(ctype, suffix, strict)
+ try:
+ with _winreg.OpenKey(mimedb, ctype) as key:
+ try:
+ suffix, datatype = _winreg.QueryValueEx(key,
+ 'Extension')
+ except EnvironmentError:
+ continue
+ if datatype != _winreg.REG_SZ:
+ continue
+ self.add_type(ctype, suffix, strict)
def guess_type(url, strict=True):