Skip to content

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

Closed

Description

@lilydjwg
mannequin
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']

Activity

  1. lilydjwg commented on Jun 24, 2015

    lilydjwgmannequin
    MannequinAuthor

    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".

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jun 24, 2015
  3. bitdancer commented on Jun 24, 2015

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

  4. transferred this issue fromon Apr 10, 2022
  5. smheidrich commented on Apr 13, 2023

    @smheidrich
    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?

  6. arhadthedev commented on Apr 13, 2023

    @arhadthedev
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions