Closed niclasborlin closed 2 years ago
Forgot to add:
$ python3 --version
Python 3.8.5
thanks, good catch!
I guess in theory would be nice if it was iterative (presumably then loadi
would have to be under with
block as well). However seems that readline
always converts to a list anyway, so this change is OK!
Consider the attached files
testorgparse.py
andtest.org
.The file
testorgparse.py
is a simple test oforgparse.load()
on an external text filetest.org
usingunittest
. It contains the following:The file
test.org
is a simple, one-line org file and should reside in the same directory astestorgparse.py
. Then, the call below generates a ResourceWarning due to an unclosed file inloadparse.load()
:The pushed code fixes the warning by enclosing
codecs.open()
by awith
statement.This is the output with the modified code:
test_load.zip