]> granicus.if.org Git - python/commitdiff
Issue #22131: Fixed a bug in handling an error occured during reading from
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 6 Sep 2014 19:17:06 +0000 (22:17 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 6 Sep 2014 19:17:06 +0000 (22:17 +0300)
a pipe in _ipconfig_getnode().

Lib/uuid.py

index 63cb3aed28070d3a9ddbe70504410b188ad46457..7b9b37330e8db70b224768766a395533e110f684 100644 (file)
@@ -366,13 +366,11 @@ def _ipconfig_getnode():
             pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
         except IOError:
             continue
-        else:
+        with pipe:
             for line in pipe:
                 value = line.split(':')[-1].strip().lower()
                 if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
                     return int(value.replace('-', ''), 16)
-        finally:
-            pipe.close()
 
 def _netbios_getnode():
     """Get the hardware address on Windows using NetBIOS calls.