summaryrefslogtreecommitdiffstats
path: root/Lib/uuid.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-11-05 14:52:43 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-11-05 14:52:43 (GMT)
commit18716a3a2384edbdbb40d4592dc3936eadaf0c9d (patch)
tree215d6a9de75aedd57776d3dab52b8f7d8b82fd4e /Lib/uuid.py
parenteae40ba6f71f55e7e597c2663454a7e164a767fe (diff)
downloadcpython-18716a3a2384edbdbb40d4592dc3936eadaf0c9d.zip
cpython-18716a3a2384edbdbb40d4592dc3936eadaf0c9d.tar.gz
cpython-18716a3a2384edbdbb40d4592dc3936eadaf0c9d.tar.bz2
Merged revisions 86192 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86192 | brian.curtin | 2010-11-05 09:48:35 -0500 (Fri, 05 Nov 2010) | 3 lines Shift the pipe-using code into an else block, then close the pipe in finally. Removes two ResourceWarnings. ........
Diffstat (limited to 'Lib/uuid.py')
-rw-r--r--Lib/uuid.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index df51464..5684ad7 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -373,10 +373,13 @@ def _ipconfig_getnode():
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
except IOError:
continue
- 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)
+ else:
+ 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.