Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3282f5

Browse files
[3.11]gh-87115: Set__main__.__spec__ toNone in pdb (GH-116141) (#116155)
*gh-87115: Set `__main__.__spec__` to `None` in pdb (#116141)(cherry picked from commitccfc042)* [3.11]gh-87115: Set `__main__.__spec__` to `None` in pdb (GH-116141)(cherry picked from commitccfc042)Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
1 parentda34d55 commitd3282f5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

‎Lib/pdb.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def namespace(self):
153153
__name__='__main__',
154154
__file__=self,
155155
__builtins__=__builtins__,
156+
__spec__=None,
156157
)
157158

158159
@property

‎Lib/test/test_pdb.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,18 @@ def bœr():
18621862
('bœr',1),
18631863
)
18641864

1865+
deftest_spec(self):
1866+
# Test that __main__.__spec__ is set to None when running a script
1867+
script="""
1868+
import __main__
1869+
print(__main__.__spec__)
1870+
"""
1871+
1872+
commands="continue"
1873+
1874+
stdout,_=self.run_pdb_script(script,commands)
1875+
self.assertIn('None',stdout)
1876+
18651877
deftest_issue7964(self):
18661878
# open the file as binary so we can force \r\n newline
18671879
withopen(os_helper.TESTFN,'wb')asf:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Set ``__main__.__spec__`` to ``None`` when running a script with:mod:`pdb`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp