Skip to content

Reading history file fails with non-latin chars on Windows #55

Open

Description

@ankostis

On Windows and Python 3-6, reading history file that contains non-Latin chars fails with this error:

$ python
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site.py", line 418, in register_readline
    readline.read_history_file(history)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, 'rt'):
  File "D:\Apps\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\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 0x8f in position 1818: character maps to <undefined>

Activity

  1. added a commit that references this issue on Jun 9, 2017
  2. jackz314 commented on Jan 27, 2021

    @jackz314

    I don't think this repo is still being maintained, it's also sad that relevant bugs reported to Python point back to this issue from years ago.

  3. added a commit that references this issue on Jan 23, 2022
  4. eabase commented on Jan 24, 2022

    @eabase

    @ankostis
    What is io doing differently?
    Please consider adding fixes to new pyreadline3 from #76

  5. ankostis commented on Jan 24, 2022

    @ankostis
    Author

    I guess it is from the Python-2.7 era, when open() did not support the encoding argument.
    If readline3 is Python-3 only, then plain open() suffices.

  6. added 14 commits that reference this issue on Jan 24, 2022
  7. added a commit that references this issue on Sep 21, 2023
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions