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

pyrepl should provide full traceback if possible to help debug possible buggy failures. #127442

Open
AraHaan opened this issue Nov 30, 2024 · 0 comments
Labels
topic-repl Related to the interactive shell type-feature A feature request or enhancement

Comments

@AraHaan
Copy link
Contributor

AraHaan commented Nov 30, 2024

Bug report

Bug description:

Currently pyrepl has the following bug that is hard to debug:

config.site_import is value: '0'
config.user_site_directory is value: '0'
config.site_import is value: '0'
config.user_site_directory is value: '0'
Python 3.14.0a2+ (heads/main-dirty:49f15d8667e, Nov 29 2024, 21:28:03) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
C:\Users\user\AppData\Roaming\Python\Python314\site-packages\easy-install.pth
warning: can't use pyrepl: 'NoneType' object does not support the context manager protocol (missed __exit__ method)
>>> 

This bug then results in site.py getting imported anyways despite my setting config.site_import AND config.user_site_directory in my own version of Py_Initialize in my C program that embeds the interpreter on Windows (exe). This results in the incorrect appending of the user site-packages folder at the end of sys.path that I did NOT OPT into at all. I did NOT want the interpreter to go about trying to open any pth file for which my own OpenCodeHook successfully captured and printed to my console to let me know that site.py was imported when it should not have been imported at all.

As such if tracebacks were printed whenever it would print the warning that pyrepl cannot be used it would help all possible situations where pyrepl cannot be used and give the user more information into fixing the root problem itself (even if it means pull requesting this repository with a fix for pyrepl itself).

Long story short EXTRA information is better than NOT ENOUGH information to debug and fix problems with pyrepl on embedded interpreters. Likewise site.py and the user site packages folder should be optional and not a hard requirement to using pyrepl either. Basically any and all places in this repository that imports site.py without checking if both config.site_import and config.user_site_directory should be made to check them first before attempting to import it, even if pyrepl cannot be used.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

Windows

@AraHaan AraHaan added the type-bug An unexpected behavior, bug, or error label Nov 30, 2024
@picnixz picnixz added the topic-repl Related to the interactive shell label Nov 30, 2024
@ZeroIntensity ZeroIntensity added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants