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

Skip to content

Commit 2595e76

Browse files
committed
Ensure cleanup does not reference variables that don't yet exist.
1 parent 64018ae commit 2595e76

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/test/test_fileinput.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class BufferSizesTests(unittest.TestCase):
3434
def test_buffer_sizes(self):
3535
# First, run the tests with default and teeny buffer size.
3636
for round, bs in (0, 0), (1, 30):
37+
t1 = t2 = t3 = t4 = None
3738
try:
3839
t1 = writeTmp(1, ["Line %s of file 1\n" % (i+1) for i in range(15)])
3940
t2 = writeTmp(2, ["Line %s of file 2\n" % (i+1) for i in range(10)])
@@ -122,6 +123,7 @@ def buffer_size_test(self, t1, t2, t3, t4, bs=0, round=0):
122123

123124
class FileInputTests(unittest.TestCase):
124125
def test_zero_byte_files(self):
126+
t1 = t2 = t3 = t4 = None
125127
try:
126128
t1 = writeTmp(1, [""])
127129
t2 = writeTmp(2, [""])
@@ -145,6 +147,7 @@ def test_zero_byte_files(self):
145147
remove_tempfiles(t1, t2, t3, t4)
146148

147149
def test_files_that_dont_end_with_newline(self):
150+
t1 = t2 = None
148151
try:
149152
t1 = writeTmp(1, ["A\nB\nC"])
150153
t2 = writeTmp(2, ["D\nE\nF"])
@@ -171,6 +174,7 @@ def test_files_that_dont_end_with_newline(self):
171174
## remove_tempfiles(t1)
172175

173176
def test_fileno(self):
177+
t1 = t2 = None
174178
try:
175179
t1 = writeTmp(1, ["A\nB"])
176180
t2 = writeTmp(2, ["C\nD"])

0 commit comments

Comments
 (0)