[Python-Dev] close() questions

Serhiy Storchaka storchaka at gmail.com
Thu Jun 12 15:16:38 CEST 2014


11.06.14 05:28, Antoine Pitrou написав(ла):
> close() should indeed be idempotent on all bundled IO class
> implementations (otherwise it's a bug), and so should it preferably on
> third-party IO class implementations.

There are some questions about close().

1. If object owns several resources, should close() try to clean up all 
them if error is happened during cleaning up some resource. E.g. should 
BufferedRWPair.close() close reader if closing writer failed?

2. If close() raises an exception, should repeated call of close() raise 
an exception or do nothing? E.g. if GzipFile.close() fails during 
writing gzip tail (CRC and size), should repeated call of it try to 
write this tail again?

3. If close() raises an exception, should the closed attribute (if 
exists) be True or False?



More information about the Python-Dev mailing list