mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
Issue #18644: Fix a ResourceWarning in formatter.test().
Patch by Vajrasky Kok.
This commit is contained in:
commit
81da286f3b
@ -436,11 +436,15 @@ def test(file = None):
|
||||
fp = open(sys.argv[1])
|
||||
else:
|
||||
fp = sys.stdin
|
||||
for line in fp:
|
||||
if line == '\n':
|
||||
f.end_paragraph(1)
|
||||
else:
|
||||
f.add_flowing_data(line)
|
||||
try:
|
||||
for line in fp:
|
||||
if line == '\n':
|
||||
f.end_paragraph(1)
|
||||
else:
|
||||
f.add_flowing_data(line)
|
||||
finally:
|
||||
if fp is not sys.stdin:
|
||||
fp.close()
|
||||
f.end_paragraph(0)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user