[Python-Dev] problems building python2.7

R. David Murray rdmurray at bitdance.com
Fri Nov 9 17:07:13 CET 2012


On 2012年11月09日 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.
--David


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /