New submission from Brock Mendel :
xref https://github.com/pandas-dev/pandas/pull/30034
codecs.open does `file = open(...)` before validating the encoding kwarg,
leaving the open file behind if that validation raises.
--
messages: 357811
nosy: Brock Mendel
priority: normal
severity
Brock Mendel added the comment:
> Does using with block similar to https://bugs.python.org/issue22831 solve
> this problem?
The motivating use case uses `with codecs.open(buf, "w", encoding=encoding) as
f:`
https://github.com/pandas-dev/pandas/blob/master/pandas/io/format