Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-129098: avoid using content of_pyrepl/__main__.py when reporting tracebacks#130721
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
_pyrepl/__main__.py when reporting tracebacks_pyrepl/__main__.py when reporting tracebacksI'm marking the PR as ready for review to know whether this is the correct alternative. |
Maybe something like this (that for unpatched version): diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.pyindex 3540d2a5a4..1d76121364 100644--- a/Lib/test/test_pyrepl/test_pyrepl.py+++ b/Lib/test/test_pyrepl/test_pyrepl.py@@ -1216,6 +1216,15 @@ def test_python_basic_repl(self): self.assertNotIn("Exception", output) self.assertNotIn("Traceback", output)+ @force_not_colorized+ def test_no_pyrepl_source_in_exc(self):+ env = os.environ.copy()+ commands = "eval(compile('spam', 'spam', 'eval'))\nexit()\n"+ env.pop("PYTHON_BASIC_REPL", None)+ output, exit_code = self.run_repl(commands, env=env)+ self.assertIn("Traceback", output)+ self.assertIn("# Important: don't add things to this module", output)+ @force_not_colorized def test_bad_sys_excepthook_doesnt_crash_pyrepl(self): env = os.environ.copy() |
@pablogsal@ambv Could you have a look at this one to see if we can use this fix? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
| self.assertTrue(os.path.exists(pyrepl_main_file),pyrepl_main_file) | ||
| withopen(pyrepl_main_file)asfp: | ||
| excluded_lines=fp.readlines() | ||
| excluded_lines=list(filter(None,map(str.strip,excluded_lines))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A bit nuclear and maybe fragile as the lines can be in other future test but I know this is thinking too far ahead. I think this is reasonable for now. Well done!
492e3e6 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Thanks@picnixz for the PR, and@pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…porting tracebacks (pythonGH-130721)(cherry picked from commit492e3e6)Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
GH-132755 is a backport of this pull request to the3.13 branch. |
… when reporting tracebacks (python#130721)"This reverts commit492e3e6.
Uh oh!
There was an error while loading.Please reload this page.
I don't know how to test this :)_pyrepl.__main__.py#129098