Skip to content
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

Can't specify encoding with fileinput and inplace=True #68682

Closed
lilydjwg mannequin opened this issue Jun 24, 2015 · 4 comments
Closed

Can't specify encoding with fileinput and inplace=True #68682

lilydjwg mannequin opened this issue Jun 24, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@lilydjwg
Copy link
Mannequin

lilydjwg mannequin commented Jun 24, 2015

BPO 24494
Nosy @bitdancer, @lilydjwg

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 = None
closed_at = None
created_at = <Date 2015-06-24.03:47:29.040>
labels = ['type-feature', 'library']
title = "Can't specify encoding with fileinput and inplace=True"
updated_at = <Date 2015-06-24.13:38:34.413>
user = 'https://github.com/lilydjwg'

bugs.python.org fields:

activity = <Date 2015-06-24.13:38:34.413>
actor = 'r.david.murray'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2015-06-24.03:47:29.040>
creator = 'lilydjwg'
dependencies = []
files = []
hgrepos = []
issue_num = 24494
keywords = []
message_count = 2.0
messages = ['245711', '245740']
nosy_count = 2.0
nosy_names = ['r.david.murray', 'lilydjwg']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue24494'
versions = ['Python 3.6']

@lilydjwg
Copy link
Mannequin Author

lilydjwg mannequin commented 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".

@lilydjwg lilydjwg mannequin added the stdlib Python modules in the Lib dir label Jun 24, 2015
@bitdancer
Copy link
Member

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 :).

@bitdancer bitdancer added the type-feature A feature request or enhancement label Jun 24, 2015
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@smheidrich
Copy link
Contributor

Since 3.10 added the encoding parameter to input and FileInput, can this be closed as no longer needed?

The docs for the hook_encoded convenience function now mention:

Deprecated since version 3.10: This function is deprecated since fileinput.input() and FileInput now have encoding and errors parameters.

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
Copy link
Member

Can confirm, gh-25272 added the parameter into both places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants