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

Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001. #51690

Closed
lieryan mannequin opened this issue Dec 5, 2009 · 4 comments
Closed

Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001. #51690

lieryan mannequin opened this issue Dec 5, 2009 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-windows topic-IO topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@lieryan
Copy link
Mannequin

lieryan mannequin commented Dec 5, 2009

BPO 7441
Nosy @vstinner, @florentx
Superseder
  • bpo-6501: Fatal error on startup with invalid PYTHONIOENCODING
  • 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-01-09.09:51:48.979>
    created_at = <Date 2009-12-05.10:40:56.645>
    labels = ['interpreter-core', 'expert-IO', 'expert-unicode', 'OS-windows', 'type-crash']
    title = 'Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.'
    updated_at = <Date 2011-10-26.23:49:44.453>
    user = 'https://bugs.python.org/lieryan'

    bugs.python.org fields:

    activity = <Date 2011-10-26.23:49:44.453>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-01-09.09:51:48.979>
    closer = 'georg.brandl'
    components = ['Interpreter Core', 'Unicode', 'Windows', 'IO']
    creation = <Date 2009-12-05.10:40:56.645>
    creator = 'lieryan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 7441
    keywords = []
    message_count = 4.0
    messages = ['95987', '95989', '96674', '146470']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'lieryan', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '6501'
    type = 'crash'
    url = 'https://bugs.python.org/issue7441'
    versions = ['Python 3.1']

    @lieryan
    Copy link
    Mannequin Author

    lieryan mannequin commented Dec 5, 2009

    maybe related to bpo-6501

    Vista 32-bit SP1, Python 3.1:
    """
    Microsoft Windows [Version 6.0.6000]
    Copyright (c) 2006 Microsoft Corporation. All rights reserved.
    D:\>chcp 65001
    Active code page: 65001

    D:\>python -c 'print("")'
    Fatal Python error: Py_Initialize: can't initialize sys standard streams
    LookupError: unknown encoding: cp65001

    This application has requested the Runtime to terminate it in an unusual
    way.
    Please contact the application's support team for more information.
    D:\>python
    Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
    (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.

    >>
    """

    Expected, either:

    1. print nothing (""), or
    2. python exception about unknown encoding, or
    3. python exception about cannot encode to the encoding

    cp65001 is supposed to be an alias for utf-8. Because of the error,
    there is AFAICT no way to set the command prompt to accept utf-8 output
    even for pipe redirection.

    A workaround is to use sys.stdout.buffer.write() to write raw byte
    strings, encoding manually. But this takes us back to python 2.

    @lieryan lieryan mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-unicode OS-windows topic-IO type-crash A hard crash of the interpreter, possibly with a core dump labels Dec 5, 2009
    @florentx
    Copy link
    Mannequin

    florentx mannequin commented Dec 5, 2009

    there's a patch proposed to add cp65001 alias: bpo-6058

    @florentx
    Copy link
    Mannequin

    florentx mannequin commented Dec 20, 2009

    Thank you for your report.
    See bpo-6501 about the Fatal Error
    See bpo-6058 for the feature request (cp65001 on windows).

    @vstinner
    Copy link
    Member

    I added a cp65001 codec to Python 3.3: see issue bpo-13216. So Python will not "crash" anymore if the console code page is set to cp65001.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-windows topic-IO topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants