Skip to content

gh-87115: Set __main__.__spec__ to None in pdb #116141

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

Merged
merged 2 commits into from
Feb 29, 2024

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Feb 29, 2024

__main__.__spec__ should be None when running a script, but pdb does not set it in the namespace. This breaks some code that relies on it (that __spec__ exists in __main__).

@gaogaotiantian
Copy link
Member Author

Hey @iritkatriel could you take a quick look at this? This is a trivial fix - just to set __spec__ to None for script targets. This is a bug fix so it probably should be backported.

@gaogaotiantian gaogaotiantian added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 29, 2024
@iritkatriel iritkatriel enabled auto-merge (squash) February 29, 2024 21:36
@iritkatriel iritkatriel merged commit ccfc042 into python:main Feb 29, 2024
@miss-islington-app
Copy link

Thanks @gaogaotiantian for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @gaogaotiantian and @iritkatriel, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ccfc042bbf31e53c44b8aae444afd8365b798422 3.12

@miss-islington-app
Copy link

Sorry, @gaogaotiantian and @iritkatriel, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ccfc042bbf31e53c44b8aae444afd8365b798422 3.11

@gaogaotiantian
Copy link
Member Author

I'll work on the cp. I thought the fix is trivial enough so there should not be any conflicts.

@gaogaotiantian gaogaotiantian deleted the fix-pdb-spec branch February 29, 2024 21:41
gaogaotiantian added a commit to gaogaotiantian/cpython that referenced this pull request Feb 29, 2024
gaogaotiantian added a commit to gaogaotiantian/cpython that referenced this pull request Feb 29, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 29, 2024

GH-116154 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 29, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 29, 2024

GH-116155 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 29, 2024
gaogaotiantian added a commit to gaogaotiantian/cpython that referenced this pull request Feb 29, 2024
gaogaotiantian added a commit to gaogaotiantian/cpython that referenced this pull request Feb 29, 2024
iritkatriel pushed a commit that referenced this pull request Feb 29, 2024
…#116154)

* gh-87115: Set `__main__.__spec__` to `None` in pdb (#116141)

(cherry picked from commit ccfc042)

* [3.12] gh-87115: Set `__main__.__spec__` to `None` in pdb (GH-116141)
(cherry picked from commit ccfc042)

Co-authored-by: Tian Gao <[email protected]>
iritkatriel pushed a commit that referenced this pull request Feb 29, 2024
…#116155)

* gh-87115: Set `__main__.__spec__` to `None` in pdb (#116141)

(cherry picked from commit ccfc042)

* [3.11] gh-87115: Set `__main__.__spec__` to `None` in pdb (GH-116141)
(cherry picked from commit ccfc042)

Co-authored-by: Tian Gao <[email protected]>
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants