mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-87115: Set __main__.__spec__
to None
in pdb (#116141)
This commit is contained in:
parent
556749c3e3
commit
ccfc042bbf
3 changed files with 14 additions and 0 deletions
|
@ -188,6 +188,7 @@ class _ScriptTarget(str):
|
|||
__name__='__main__',
|
||||
__file__=self,
|
||||
__builtins__=__builtins__,
|
||||
__spec__=None,
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -2695,6 +2695,18 @@ def bœr():
|
|||
('bœr', 2),
|
||||
)
|
||||
|
||||
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_find_function_first_executable_line(self):
|
||||
code = textwrap.dedent("""\
|
||||
def foo(): pass
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Set ``__main__.__spec__`` to ``None`` when running a script with :mod:`pdb`
|
Loading…
Add table
Add a link
Reference in a new issue