[issue38971] codecs.open leaks file descriptor when invalid encoding is passed

2019-12-04 Thread Brock Mendel
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

[issue38971] codecs.open leaks file descriptor when invalid encoding is passed

2019-12-04 Thread Brock Mendel
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