]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
test_both(): I believe this was a typo: m is only defined if no
authorBarry Warsaw <barry@python.org>
Wed, 11 Sep 2002 02:56:42 +0000 (02:56 +0000)
committerBarry Warsaw <barry@python.org>
Wed, 11 Sep 2002 02:56:42 +0000 (02:56 +0000)
exception occurred so it should only be closed in the else clause.
Without this change we can an UnboundLocalError on Linux:

Traceback (most recent call last):
  File "Lib/test/test_mmap.py", line 304, in ?
    test_both()
  File "Lib/test/test_mmap.py", line 208, in test_both
    m.close()
UnboundLocalError: local variable 'm' referenced before assignment

Lib/test/test_mmap.py

index ea9c4eed4c68523e3fa6d98b56f2f7fd17c363eb..417080f0055efe1ac05b9a264a0204571482ab4d 100644 (file)
@@ -205,7 +205,7 @@ def test_both():
             # we expect a ValueError on Unix, but not on Windows
             if not sys.platform.startswith('win'):
                 verify(0, "Opening mmap with size+1 should raise ValueError.")
-        m.close()
+            m.close()
         f.close()
         if sys.platform.startswith('win'):
             # Repair damage from the resizing test.