prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.23k stars 281 forks source link

Fix handling of 'config file does not exist' when embedding ptpython. #563

Closed jonathanslenders closed 11 months ago

tony commented 11 months ago

Recreation

Originally discovered by @orhanhenrik in https://github.com/prompt-toolkit/ptpython/pull/551#issuecomment-1853783799:

Traceback (most recent call last):
  File ".../ptpython/ptpython/repl.py", line 445, in run_config
    with open(config_file, "rb") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '~/.config/ptpython/config.py'

Press ENTER to continue...
>>>

With PR (no config)

No error! Buttery smooth!

With PR (with configuration)

Also works!

tony commented 11 months ago

ptpython 3.0.25 (PyPI, tag, release) launches smoothly with ./manage.py shell_plus with and without config.