On 9/11/12 17:07:13, R. David Murray wrote: > On Fri, 09 Nov 2012 16:44:00 +0100, Hans Mulder <han...@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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com