You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't specify encoding with fileinput and inplace=True #68682
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:
assignee=Noneclosed_at=Nonecreated_at=<Date2015-06-24.03:47:29.040>labels= ['type-feature', 'library']
title="Can't specify encoding with fileinput and inplace=True"updated_at=<Date2015-06-24.13:38:34.413>user='https://github.com/lilydjwg'
I want to use fileinput to modify files, but find no way to specify the file encoding. I tried to use "hook_encoded", but it says "FileInput cannot use an opening hook in inplace mode".
I presume this is because openhook could be anything, including something where the inplace code couldn't even find the file to rename. On the other hand, Python is a "consenting adults" language, so we can assume you know what you are doing if you specify both. I think this restriction could be relaxed, and am willing to review a patch proposal to so, if it comes with tests :).
Activity
lilydjwg commentedon Jun 24, 2015
I want to use fileinput to modify files, but find no way to specify the file encoding. I tried to use "hook_encoded", but it says "FileInput cannot use an opening hook in inplace mode".
bitdancer commentedon Jun 24, 2015
I presume this is because openhook could be anything, including something where the inplace code couldn't even find the file to rename. On the other hand, Python is a "consenting adults" language, so we can assume you know what you are doing if you specify both. I think this restriction could be relaxed, and am willing to review a patch proposal to so, if it comes with tests :).
smheidrich commentedon Apr 13, 2023
Since 3.10 added the
encodingparameter toinputandFileInput, can this be closed as no longer needed?The docs for the
hook_encodedconvenience function now mention:So I think the same thing applies across the board to encoding-via-hook functionality such as what this ticket requests, doesn't it?
arhadthedev commentedon Apr 13, 2023
Can confirm, gh-25272 added the parameter into both places.