Skip to content

Commit fcd7ca0

Browse files
committed
Use % formatting instead of f-strings in __del__
F-strings can fail during cleanup. Use % formatting like subprocess.Popen does for safer __del__ behavior. Signed-off-by: Osama Abdelkader <[email protected]>
1 parent c8ea776 commit fcd7ca0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/xml/etree/ElementTree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ def close(self):
12711271

12721272
def __del__(self, _warn=warnings.warn):
12731273
if close_source:
1274-
_warn(f"unclosed file {source!r}",
1274+
_warn("unclosed file %r" % (source,),
12751275
ResourceWarning, source=self)
12761276
source.close()
12771277

0 commit comments

Comments
 (0)