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

IndexError in sys.__interactivehook__ with pyreadline installed #64610

Closed
jaraco opened this issue Jan 27, 2014 · 6 comments
Closed

IndexError in sys.__interactivehook__ with pyreadline installed #64610

jaraco opened this issue Jan 27, 2014 · 6 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jaraco
Copy link
Member

jaraco commented Jan 27, 2014

BPO 20411
Nosy @jaraco, @pitrou

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 2014-01-28.14:19:58.533>
created_at = <Date 2014-01-27.20:12:12.468>
labels = ['type-bug', 'library']
title = 'IndexError in sys.__interactivehook__ with pyreadline installed'
updated_at = <Date 2014-01-28.14:19:58.532>
user = 'https://github.com/jaraco'

bugs.python.org fields:

activity = <Date 2014-01-28.14:19:58.532>
actor = 'jaraco'
assignee = 'none'
closed = True
closed_date = <Date 2014-01-28.14:19:58.533>
closer = 'jaraco'
components = ['Library (Lib)']
creation = <Date 2014-01-27.20:12:12.468>
creator = 'jaraco'
dependencies = []
files = []
hgrepos = []
issue_num = 20411
keywords = []
message_count = 6.0
messages = ['209471', '209478', '209480', '209483', '209550', '209551']
nosy_count = 4.0
nosy_names = ['jaraco', 'pitrou', 'tshepang', 'python-dev']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue20411'
versions = ['Python 3.4']

@jaraco
Copy link
Member Author

jaraco commented Jan 27, 2014

Following the blame history, this appears to be new issue following bpo-5845.

I'm using Python 3.4b2 64-bit on Windows. I've installed pyreadline 2.0 using Setuptools 2.1. Now, when I start the interactive interpreter, I get this output:

> python
Python 3.4.0b2 (v3.4.0b2:ba32913eb13e, Jan  5 2014, 16:13:26) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "c:\python\lib\site.py", line 412, in register_readline
    if readline.get_history_item(1) is None:
  File "c:\python\lib\site-packages\pyreadline-2.0-py3.4-win-amd64.egg\pyreadline\rlmain.py", line 154, in get_history_item
  File "c:\python\lib\site-packages\pyreadline-2.0-py3.4-win-amd64.egg\pyreadline\lineeditor\history.py", line 52, in get_history_item
IndexError: list index out of range

It seems I don't yet have any history, and it seems that site.py is expecting get_history_item() to return None when no history is present, but the pyreadline 2.0 implementation does no such thing, but instead tries to index the history array directly, causing the IndexError.

@jaraco jaraco added the stdlib Python modules in the Lib dir label Jan 27, 2014
@pitrou
Copy link
Member

pitrou commented Jan 27, 2014

Sounds reasonably easy to fix. Can you write a patch?

@pitrou pitrou added the type-bug An unexpected behavior, bug, or error label Jan 27, 2014
@jaraco
Copy link
Member Author

jaraco commented Jan 27, 2014

Is the proper fix to address the issue in site.py? Does this issue reveal anything else of concern about the implementation?

Assuming Yes and No, then yes, I can put together a fix.

@pitrou
Copy link
Member

pitrou commented Jan 27, 2014

Is the proper fix to address the issue in site.py? Does this issue
reveal anything else of concern about the implementation?

I don't know, but it's a regression, so we'd better add a "fix" or
"workaround" in site.py anyway.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jan 28, 2014

New changeset ca6efeedfc0e by Jason R. Coombs in branch 'default':
Issue bpo-20411: Use readline.get_current_history_length to check for the presence of a history, rather than get_history_item, which assumes a history is present.
http://hg.python.org/cpython/rev/ca6efeedfc0e

@jaraco
Copy link
Member Author

jaraco commented Jan 28, 2014

After further consideration and investigation, I believe the fix is to simply use the API as exposed by pyreadline to check the length of the history to detect the presence of an existing history. I've tested that fix locally and it seems to be working suitably. Please review and suggest corrections as appropriate.

@jaraco jaraco closed this as completed Jan 28, 2014
@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
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants