Skip to content

CLI error when .python_history contains unicode characters #79722

Closed

Description

@armandas
mannequin
BPO 35541
Nosy @pfmoore, @tjguk, @zware, @eryksun, @zooba

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 2018-12-20.07:09:07.046>
created_at = <Date 2018-12-20.06:06:01.584>
labels = ['3.7', 'type-bug', 'library', 'OS-windows']
title = 'CLI error when .python_history contains unicode characters'
updated_at = <Date 2018-12-20.07:12:16.585>
user = 'https://bugs.python.org/armandas'

bugs.python.org fields:

activity = <Date 2018-12-20.07:12:16.585>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2018-12-20.07:09:07.046>
closer = 'eryksun'
components = ['Library (Lib)', 'Windows']
creation = <Date 2018-12-20.06:06:01.584>
creator = 'armandas'
dependencies = []
files = []
hgrepos = []
issue_num = 35541
keywords = []
message_count = 2.0
messages = ['332179', '332185']
nosy_count = 6.0
nosy_names = ['paul.moore', 'tim.golden', 'armandas', 'zach.ware', 'eryksun', 'steve.dower']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue35541'
versions = ['Python 3.7']

Activity

  1. armandas commented on Dec 20, 2018

    armandasmannequin
    MannequinAuthor

    OS: Windows 10
    Python version: Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32

    Traceback:
    Failed calling sys.__interactivehook__
    Traceback (most recent call last):
      File "C:\Users\owner\AppData\Local\Programs\Python\Python37-32\lib\site.py", line 439, in register_readline
        readline.read_history_file(history)
      File "C:\Users\owner\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
        self.mode._history.read_history_file(filename)
      File "C:\Users\owner\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
        for line in open(filename, 'r'):
      File "C:\Users\owner\AppData\Local\Programs\Python\Python37-32\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 2: character maps to <undefined>

    How to reproduce:
    On a Windows machine, add the following line to your .python_history:

    "あ".isalpha()

    I believe the issue stems from the fact that the history file is opened with the "default" encoding, which on windows is cp1252.

  2. added
    3.7 (EOL)
    stdlib
    type-bug
    on Dec 20, 2018
  3. eryksun commented on Dec 20, 2018

    @eryksun
    Contributor

    pyreadline is a third-party package. Refer to issue 55 at its GitHub repo:

    pyreadline/pyreadline#55

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

    3.7 (EOL)OS-windowsstdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions