[Python-checkins] r77735 - in python/trunk: Lib/platform.py Lib/test/test_platform.py Misc/ACKS Misc/NEWS

benjamin.peterson python-checkins at python.org
Mon Jan 25 04:31:13 CET 2010


Author: benjamin.peterson
Date: Mon Jan 25 04:31:13 2010
New Revision: 77735

Log:
fix an UnboundLocalError when the release file is empty #7773

Modified:
   python/trunk/Lib/platform.py
   python/trunk/Lib/test/test_platform.py
   python/trunk/Misc/ACKS
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/platform.py
==============================================================================
--- python/trunk/Lib/platform.py	(original)
+++ python/trunk/Lib/platform.py	Mon Jan 25 04:31:13 2010
@@ -263,6 +263,12 @@
 
 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:
@@ -280,8 +286,6 @@
         version = l[0]
         if len(l) > 1:
             id = l[1]
-        else:
-            id = ''
     return '', version, id
 
 def linux_distribution(distname='', version='', id='',

Modified: python/trunk/Lib/test/test_platform.py
==============================================================================
--- python/trunk/Lib/test/test_platform.py	(original)
+++ python/trunk/Lib/test/test_platform.py	Mon Jan 25 04:31:13 2010
@@ -198,6 +198,7 @@
             ('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)
 

Modified: python/trunk/Misc/ACKS
==============================================================================
--- python/trunk/Misc/ACKS	(original)
+++ python/trunk/Misc/ACKS	Mon Jan 25 04:31:13 2010
@@ -357,6 +357,7 @@
 Gerhard Häring
 Mihai Ibanescu
 Lars Immisch
+Meador Inge
 Tony Ingraldi
 John Interrante
 Bob Ippolito

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Mon Jan 25 04:31:13 2010
@@ -42,6 +42,9 @@
 Library
 -------
 
+- Issue #7773: Fix an UnboundLocalError in platform.linux_distribution() when
+  the release file is empty.
+
 - Issue #7748: Since unicode values are supported for some metadata options
   in Distutils, the DistributionMetadata get_* methods will now return an utf-8
   encoded string for them. This ensure that the upload and register commands


More information about the Python-checkins mailing list