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

Empty PYTHONIOENCODING is not the same as nonexistent #63018

Closed
serhiy-storchaka opened this issue Aug 23, 2013 · 9 comments
Closed

Empty PYTHONIOENCODING is not the same as nonexistent #63018

serhiy-storchaka opened this issue Aug 23, 2013 · 9 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 18818
Nosy @ncoghlan, @vstinner, @serhiy-storchaka
Files
  • empty_pythonioencoding.patch
  • empty_pythonioencoding_2.patch
  • empty_pythonioencoding_3.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 2013-09-13.08:48:41.769>
    created_at = <Date 2013-08-23.06:45:48.549>
    labels = ['interpreter-core', 'type-feature']
    title = 'Empty PYTHONIOENCODING is not the same as nonexistent'
    updated_at = <Date 2014-02-25.15:55:52.592>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2014-02-25.15:55:52.592>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-09-13.08:48:41.769>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2013-08-23.06:45:48.549>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['31433', '31435', '31447']
    hgrepos = []
    issue_num = 18818
    keywords = ['patch', 'needs review']
    message_count = 9.0
    messages = ['195946', '195947', '195950', '195951', '196007', '197501', '197560', '197561', '212186']
    nosy_count = 5.0
    nosy_names = ['ncoghlan', 'vstinner', 'Arfrever', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue18818'
    versions = ['Python 3.4']

    @serhiy-storchaka
    Copy link
    Member Author

    $ PYTHONIOENCODING= ./python
    Fatal Python error: Py_Initialize: can't initialize sys standard streams
    LookupError: unknown encoding: 
    Aborted (core dumped)

    As a consequence we can't set only the error handler.

    $ PYTHONIOENCODING=:surrogateescape ./python
    Fatal Python error: Py_Initialize: can't initialize sys standard streams
    LookupError: unknown encoding: 
    Aborted (core dumped)

    Here is a patch which allows accepting empty encoding as default encoding.

    @serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 23, 2013
    @ncoghlan
    Copy link
    Contributor

    Patch looks good to me.

    @vstinner
    Copy link
    Member

    Patch looks good to me, but you have to update Doc/using/cmdline.rst,
    at least to add a versionchanged section.

    Tests would also be nice :-)

    I really like the the "PYTHONIOENCODING=:surrogateescape" use case!

    @serhiy-storchaka
    Copy link
    Member Author

    Second variant of the patch also supports empty error handler as the default error handler (i.e. strict).

    $ PYTHONIOENCODING=ascii: ./python
    Python 3.4.0a1+ (default:5b5ef012cd4e+, Aug 23 2013, 10:18:51) 
    [GCC 4.6.3] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print('\xbd')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    UnicodeEncodeError: 'ascii' codec can't encode character '\xbd' in position 0: ordinal not in range(128)

    Without it different error is raised:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    LookupError: unknown error handler name ''

    @serhiy-storchaka
    Copy link
    Member Author

    Here is a patch with tests and documentation. For the documentation I hope on your help.

    @serhiy-storchaka
    Copy link
    Member Author

    Nick, could you help me with documentation? I'm sure my wording needs improving.

    And there is one question left. Is this change appropriate for 2.7 and 3.3, or only for 3.4?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 13, 2013

    New changeset c7fdb0637d0b by Serhiy Storchaka in branch 'default':
    Issue bpo-18818: The "encodingname" part of PYTHONIOENCODING is now optional.
    http://hg.python.org/cpython/rev/c7fdb0637d0b

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you Ezio and Vajrasky for the review.

    @serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Sep 13, 2013
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 25, 2014

    New changeset 8ac9c3754d33 by R David Murray in branch 'default':
    whatsnew: encoding is now optional in PYTHONIOENCODING (bpo-18818)
    http://hg.python.org/cpython/rev/8ac9c3754d33

    @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) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants