Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 590fe02

Browse files
committed
CommandTests.testgetoutput():
Make sure we aren't masking any errors raised in tempfile.mkdtemp() by referencing the (then) unbound local 'dir'.
1 parent 49754af commit 590fe02

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/test/test_commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ def test_getoutput(self):
2727
# we use mkdtemp in the next line to create an empty directory
2828
# under our exclusive control; from that, we can invent a pathname
2929
# that we _know_ won't exist. This is guaranteed to fail.
30+
dir = None
3031
try:
3132
dir = tempfile.mkdtemp()
3233
name = os.path.join(dir, "foo")
3334

3435
status, output = getstatusoutput('cat ' + name)
3536
self.assertNotEquals(status, 0)
3637
finally:
37-
os.rmdir(dir)
38+
if dir is not None:
39+
os.rmdir(dir)
3840

3941
def test_getstatus(self):
4042
# This pattern should match 'ls -ld /.' on any posix

0 commit comments

Comments
 (0)