Skip to content

Windows: use (mbcs in) strict mode to encode/decode filenames, and enable os.fsencode() #53215

Closed

Description

@vstinner
BPO 8969
Nosy @malemburg, @loewis, @vstinner
Files
  • fsencode_mbcs.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-06-13.21:16:11.142>
    created_at = <Date 2010-06-11.00:33:06.884>
    labels = ['interpreter-core', 'library', 'expert-unicode', 'OS-windows']
    title = 'Windows: use (mbcs in) strict mode to encode/decode filenames, and enable os.fsencode()'
    updated_at = <Date 2010-06-13.21:16:11.141>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2010-06-13.21:16:11.141>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-06-13.21:16:11.142>
    closer = 'vstinner'
    components = ['Interpreter Core', 'Library (Lib)', 'Unicode', 'Windows']
    creation = <Date 2010-06-11.00:33:06.884>
    creator = 'vstinner'
    dependencies = []
    files = ['17616']
    hgrepos = []
    issue_num = 8969
    keywords = ['patch']
    message_count = 2.0
    messages = ['107510', '107610']
    nosy_count = 3.0
    nosy_names = ['lemburg', 'loewis', 'vstinner']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue8969'
    versions = ['Python 3.2']

    Activity

    1. vstinner commented on Jun 11, 2010

      @vstinner
      MemberAuthor

      mbcs encoding doesn't support surrogateescape (see bpo-850997), and mbcs should only be used in strict mode to encode/decode filenames.

      os.fsencode() should also be enabled on Windows. First I tried to disable this function on Windows to avoid the evil mbcs encoding, but mbcs encoding *is* used by some modules written in C (functions using PyUnicode_FSConverter(): encode the filename to bytes with mbcs encoding on Windows). Eg. _ssl module use PyUnicode_FSConverter() to get filenames because the underlying library, OpenSSL, requires bytes for the filenames (C type: char*). Enable os.fsencode() on Windows helps some tests (eg. fix test_ssl).

      Use "strict" error handler, instead of "surrogateescape", to encode/decode filenames with mbcs encoding, does nothing yet because mbcs codec ignore the errors argument. These changes prepare the work on mbcs codec: see bpo-850997.

      Note: os.fsencode() was introduced by bpo-8514.

    2. vstinner commented on Jun 11, 2010

      @vstinner
      MemberAuthor

      Patch commited as r81927 (3.2).

    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

      OS-windowsinterpreter-core(Objects, Python, Grammar, and Parser dirs)stdlibStandard Library Python modules in the Lib/ directorytopic-unicode

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions