-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codecs.open leaks file descriptor when invalid encoding is passed #83152
Comments
codecs.open does |
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/formats/format.py#L498 |
Ah okay, thanks for the detail. Forgot there should be an open file handle to be returned by codecs.open |
Add
|
Any reason not to just defer opening the file until after the codec has been validated, so the resource acquisition comes last? |
Many reasons.
|
Just quickly pinging the thread as a friendly reminder that PR 17666 is open and potentially close to mergeable, as it's been through two review cycles already (thanks Serhiy). If someone has the bandwidth to take another look, it would be greatly appreciated. Thanks! |
It is too later for 2.7. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: