This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: platform._parse_release_file() can cause UnboundLocalError
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, benjamin.peterson, lemburg, meador.inge
Priority: normal Keywords: needs review, patch

Created on 2010-01-24 20:10 by Arfrever, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-fix_platform._parse_release_file.patch Arfrever, 2010-01-24 20:10 Avoid UnboundLocalError in platform._parse_release_file
issue-7773.patch meador.inge, 2010-01-25 02:22
Messages (8)
msg98250 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2010-01-24 20:10
When the release file doesn't contain some data, then platform._parse_release_file() causes UnboundLocalError. I'm attaching the patch to fix it.

$ python2.7 -c 'import platform; platform._parse_release_file("")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python2.7/platform.py", line 285, in _parse_release_file
    return '', version, id
UnboundLocalError: local variable 'version' referenced before assignment
msg98256 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-01-24 22:45
An accompanying test would be wonderful.
msg98262 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2010-01-25 02:22
Updated the patch to add a test case in 'test_platform'.  I also added a comment explaining the change and removed a redundant assignment.
msg98263 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-01-25 03:31
Thanks for the patch! Applied in r77735.
msg98276 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-01-25 09:24
Could you provide a dump of the (whole) release file ?

It's a bit strange to have an empty release file.

Thanks.
msg98278 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2010-01-25 11:28
My release file actually is correct (non-empty).
msg98279 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-01-25 11:35
Arfrever Frehtes Taifersar Arahesis wrote:
> 
> Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@GMail.Com> added the comment:
> 
> My release file actually is correct (non-empty).

Could you post it on the ticket, so that I can check what's
causing the problem ?!

Thanks,
-- 
Marc-Andre Lemburg
eGenix.com

________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
msg98280 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2010-01-25 11:41
A user of Portage had incorrect release file.
https://bugs.gentoo.org/show_bug.cgi?id=301848
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 52021
2010-01-25 11:41:51Arfreversetmessages: + msg98280
2010-01-25 11:35:06lemburgsetmessages: + msg98279
2010-01-25 11:28:52Arfreversetmessages: + msg98278
2010-01-25 09:24:39lemburgsetmessages: + msg98276
2010-01-25 03:31:33benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg98263
2010-01-25 02:59:07brian.curtinsetpriority: normal
keywords: + needs review
type: behavior
stage: patch review
2010-01-25 02:22:49meador.ingesetfiles: + issue-7773.patch
nosy: + meador.inge
messages: + msg98262

2010-01-24 22:45:56benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg98256
2010-01-24 20:11:30Arfreversetnosy: + lemburg
2010-01-24 20:10:06Arfrevercreate