[Python-checkins] cpython (3.4): 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:28 CEST 2014


http://hg.python.org/cpython/rev/8a61a287776d
changeset:   92370:8a61a287776d
branch:      3.4
parent:      92366:c1fb19907cc4
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sat Sep 06 22:17:24 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
@@ -383,13 +383,11 @@
             pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
         except OSError:
             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