]> granicus.if.org Git - python/commitdiff
Merged revisions 77735 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Mon, 25 Jan 2010 03:37:42 +0000 (03:37 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 25 Jan 2010 03:37:42 +0000 (03:37 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77735 | benjamin.peterson | 2010-01-24 21:31:13 -0600 (Sun, 24 Jan 2010) | 1 line

  fix an UnboundLocalError when the release file is empty #7773
........

Lib/platform.py
Lib/test/test_platform.py
Misc/ACKS
Misc/NEWS

index 0a525871a851cd173f76feb47c2552085769f73a..570f327a8067b7ae5ffc0bbc298a873e32d3d0c8 100755 (executable)
@@ -261,6 +261,12 @@ _supported_dists = (
 
 def _parse_release_file(firstline):
 
+    # Default to empty 'version' and 'id' strings.  Both defaults are used
+    # when 'firstline' is empty.  'id' defaults to empty when an id can not
+    # be deduced.
+    version = ''
+    id = ''
+
     # Parse the first line
     m = _lsb_release_version.match(firstline)
     if m is not None:
@@ -278,8 +284,6 @@ def _parse_release_file(firstline):
         version = l[0]
         if len(l) > 1:
             id = l[1]
-        else:
-            id = ''
     return '', version, id
 
 def linux_distribution(distname='', version='', id='',
index 9b752343aecc22bd40d9d3d4caf632c8d20811b1..af37185686256a827b2d488e6251fa0da838bdd6 100644 (file)
@@ -191,6 +191,7 @@ class PlatformTest(unittest.TestCase):
             ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')),
             ('CentOS release 4', ('CentOS', '4', None)),
             ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')),
+            ('', ('', '', '')), # If there's nothing there.
             ):
             self.assertEqual(platform._parse_release_file(input), output)
 
index f0c667a57c885643c963374fea3ba74dd9f9b84a..27348e907d96ec43117adfd2151fbd002089d3ba 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -357,6 +357,7 @@ Jeremy Hylton
 Gerhard Häring
 Mihai Ibanescu
 Lars Immisch
+Meador Inge
 Tony Ingraldi
 John Interrante
 Bob Ippolito
index f5275b8cc4d55e6089478edcc4b5ed640472310e..da9cf121a94786aefda099861c358d135de1f871 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -229,6 +229,9 @@ C-API
 Library
 -------
 
+- Issue #7773: Fix an UnboundLocalError in platform.linux_distribution() when
+  the release file is empty.
+
 - Issue #7561: Fix crashes when using bytearray objects with the posix
   module.