Title: Can't specify encoding with fileinput and inplace=True
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: lilydjwg, r.david.murray
Priority: normal Keywords:

Created on 2015-06-24 03:47 by lilydjwg, last changed 2015-06-24 13:38 by r.david.murray.

Messages (2)
msg245711 - (view) Author: lilydjwg (lilydjwg) Date: 2015-06-24 03:47
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".
msg245740 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-06-24 13:38
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 :).
Date User Action Args
2015-06-24 13:38:34r.david.murraysetversions: + Python 3.6, - Python 3.4
nosy: + r.david.murray

messages: + msg245740

type: enhancement
stage: needs patch
2015-06-24 03:47:29lilydjwgcreate