You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I updated from Python 3.13.0b2 to b3 and started the REPL for the first time, pressing arrow up showed the history.
Upon exiting and starting again, there is no more history when I press arrow up. I noticed it is also missing from my other Python REPLs. ~/.python_history is empty.
$ python3.12
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 'Save this'
'Save this'
>>> ^D
$ cat ~/.python_history
'Save this'
$ python3.13
Python 3.13.0b3 (main, Jun 28 2024, 00:00:00) [GCC 13.3.1 20240522 (Red Hat 13.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> [arrow up]'Save this'
'Save this'
>>> ^D
$ cat ~/.python_history
(empty)
$ python3.12
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> [arrow up]
(empty)
... The first time Python 3.13 runs the history is there, but after exiting and running again the history has gone. Running an older Python populates the history with new entries but they're lost the next time Python 3.13 exits.
Git bisect tracked the issue to 38cfa92. The actual issue is in site.py, where it tries to import CAN_USE_PYREPL from __main__, which it's no longer located in as of that commit.
# _pyrepl.__main__ is executed as the __main__ module
from__main__importCAN_USE_PYREPL
exceptImportError:
CAN_USE_PYREPL=False
Changing this to from _pyrepl.main import CAN_USE_PYREPL or adding from .main import CAN_USE_PYREPL to the top of _pyrepl.__main__.py seems to fix it. (I couldn't make it work reliably at first but I think that was me forgetting that site.py is frozen)
Activity
hroncok commentedon Jul 1, 2024
This is always reproducible:
hroncok commentedon Jul 1, 2024
@domdfcoding wrote:
hroncok commentedon Jul 1, 2024
Moreover, I believe that even if the code in site.py "cannot use pyrepl", it should never ever write empty history.
pythongh-121245: Amend 38cfa92 (correct import)
skirpichev commentedon Jul 2, 2024
PR is ready: #121255
hroncok commentedon Jul 2, 2024
Suggestion: Let's merge #121255 as is but do not close this issue yet. I think there are multiple improvements possible:
skirpichev commentedon Jul 2, 2024
Yep, I'll work on this in second pr.
00430: pythongh-121245: Amend d611c4c (correct import)
gh-121245: Amend d611c4c (correct import) (#121255)
00430: pythongh-121245: Amend d611c4c (correct import) (python#121255)
Refactor register_readline()
13 remaining items
pythongh-121245: a regression test for site.register_readline() (pyth…
pythongh-121245: Refactor site.register_readline()
pythongh-121245: Refactor site.register_readline()
skirpichev commentedon Jul 13, 2024
PR is ready for review: #121659
gh-121245: Refactor site.register_readline() (GH-121659)
pythongh-121245: Refactor site.register_readline() (pythonGH-121659)
[3.13] gh-121245: Refactor site.register_readline() (GH-121659) (GH-1…
skirpichev commentedon Jul 17, 2024
@ambv, probably this also could be closed.
pythongh-121245: Amend d611c4c (correct import) (python#121255)
pythongh-121245: a regression test for site.register_readline() (pyth…
pythongh-121245: Refactor site.register_readline() (pythonGH-121659)
picnixz commentedon Sep 26, 2025
As this is not directly related to
make testin particular, I'll actually keep #139352 instead. Sorry for the noise.