Skip to content

Change filename encoding to FS encoding in PyErr_WarnExplicit() #54988

Closed

Description

@vstinner
BPO 10779
Nosy @vstinner
Files
  • warnexplicit_fsencoding.patch
  • 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 = <Date 2010-12-27.20:10:53.341>
    created_at = <Date 2010-12-27.02:05:46.019>
    labels = ['interpreter-core', 'expert-unicode']
    title = 'Change filename encoding to FS encoding in PyErr_WarnExplicit()'
    updated_at = <Date 2010-12-27.20:10:53.340>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2010-12-27.20:10:53.340>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-12-27.20:10:53.341>
    closer = 'vstinner'
    components = ['Interpreter Core', 'Unicode']
    creation = <Date 2010-12-27.02:05:46.019>
    creator = 'vstinner'
    dependencies = []
    files = ['20170']
    hgrepos = []
    issue_num = 10779
    keywords = ['patch']
    message_count = 2.0
    messages = ['124694', '124728']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue10779'
    versions = ['Python 3.2']

    Activity

    1. vstinner commented on Dec 27, 2010

      @vstinner
      MemberAuthor

      PyErr_WarnExplicit() expects a filename encoded to UTF-8. This function is only called twice in the Python interpreter: compiler_assert() (with "assertion is always true, perhaps remove parentheses?") and symtable_warn() (eg. with "name 'xxx' is assigned to before global declaration"), and both functions pass a filename encoded to the filesystem encoding.

      PyErr_WarnExplicit() should use the filesystem encoding instead of UTF-8 to decode the filename. I already did the same change in issue bpo-9713 and bpo-10114 (r85569).

      Attached patch fixes this issue.

      See also issue bpo-10778 (decoding_fgets() (tokenizer.c) decodes the filename from the wrong encoding).

    2. vstinner commented on Dec 27, 2010

      @vstinner
      MemberAuthor

      Fixed by r87517.

    3. transferred this issue fromon Apr 10, 2022
    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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions