[Python-checkins] cpython (2.7): Issue #22131: Fixed a bug in handling an error occured during reading from

serhiy.storchaka python-checkins at python.org
Sat Sep 6 21:21:27 CEST 2014


http://hg.python.org/cpython/rev/d8c6b15a2ae3
changeset:   92369:d8c6b15a2ae3
branch:      2.7
parent:      92357:322f77ee6d5a
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sat Sep 06 22:17:06 2014 +0300
summary:
  Issue #22131: Fixed a bug in handling an error occured during reading from
a pipe in _ipconfig_getnode().

files:
  Lib/uuid.py |  4 +---
  1 files changed, 1 insertions(+), 3 deletions(-)


diff --git a/Lib/uuid.py b/Lib/uuid.py
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -366,13 +366,11 @@
             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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list