[Python-Dev] problems building python2.7
Hans Mulder
hansmu at xs4all.nl
Sat Nov 10 15:46:47 CET 2012
On 9/11/12 17:07:13, R. David Murray wrote:
> On Fri, 09 Nov 2012 16:44:00 +0100, Hans Mulder <hansmu at xs4all.nl> wrote:
>> I looked into it, and the problem is this bit of code (line 230-235):
>>
>> try:
>> self.assertTrue(os.path.exists(tmp_file))
>> fp = urllib.urlopen(tmp_fileurl)
>> finally:
>> os.close(fd)
>> fp.close()
>>
>> Due to a misconfiguration, urllib.thishost() raises an IOError on my
>> laptop. This causes urllib.urlopen to raise an exception, and the
>> name fp is never bound, so that the fp.close() in the finally clause
>> raises an UnboundLocalError, masking the problem in urlopen.
>>
>> A quick fix would be:
>>
>> try:
>> self.assertTrue(os.path.exists(tmp_file))
>> fp = urllib.urlopen(tmp_fileurl)
>> fp.close()
>> finally:
>> os.close(fd)
>>
>> That way, the .close is only attempted if the open succeeds.
>
> Could you open an issue for this on the tracker, please? That
> way we won't forget to fix it.
Done: issue 16450.
-- HansM
More information about the Python-Dev
mailing list