diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2024-02-29 23:24:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 23:24:09 (GMT) |
commit | 40e9295a581f2908f2cdf09b1726822379ea7bd0 (patch) | |
tree | 7a5ac4f1ea747899652c70fcb882d58015e13e54 /Lib | |
parent | 8d865f19bd9d21ee3cce515742db25f44d167b0f (diff) | |
download | cpython-40e9295a581f2908f2cdf09b1726822379ea7bd0.zip cpython-40e9295a581f2908f2cdf09b1726822379ea7bd0.tar.gz cpython-40e9295a581f2908f2cdf09b1726822379ea7bd0.tar.bz2 |
[3.12] gh-87115: Set `__main__.__spec__` to `None` in pdb (GH-116141) (#116154)
* gh-87115: Set `__main__.__spec__` to `None` in pdb (#116141)
(cherry picked from commit ccfc042bbf31e53c44b8aae444afd8365b798422)
* [3.12] gh-87115: Set `__main__.__spec__` to `None` in pdb (GH-116141)
(cherry picked from commit ccfc042bbf31e53c44b8aae444afd8365b798422)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/pdb.py | 1 | ||||
-rw-r--r-- | Lib/test/test_pdb.py | 12 |
2 files changed, 13 insertions, 0 deletions
@@ -154,6 +154,7 @@ class _ScriptTarget(str): __name__='__main__', __file__=self, __builtins__=__builtins__, + __spec__=None, ) @property diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 51b8442..0e1b1c9 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -2013,6 +2013,18 @@ def bœr(): ('bœr', 1), ) + def test_spec(self): + # Test that __main__.__spec__ is set to None when running a script + script = """ + import __main__ + print(__main__.__spec__) + """ + + commands = "continue" + + stdout, _ = self.run_pdb_script(script, commands) + self.assertIn('None', stdout) + def test_issue7964(self): # open the file as binary so we can force \r\n newline with open(os_helper.TESTFN, 'wb') as f: |