Skip to content

Conversation

@Carreau
Copy link
Contributor

@Carreau Carreau commented Oct 30, 2025

Initialize lineno, stack, curindex, curframe,
currentbp, and _user_requested_quit attributes in
Pdb.__init__ instead of at first use. This ensures these attributes are always defined and allows
removal of defensive getattr/hasattr checks
throughout the codebase.

In particular for a custom PDB subclass in
IPython, the need to use a getattr has performance implications, and while we could set it our __init__ it was easy to send a more global patch to CPython.

Should fix gh-140790

@python-cla-bot
Copy link

python-cla-bot bot commented Oct 30, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Carreau and others added 4 commits November 5, 2025 18:59
Initialize lineno, stack, curindex, curframe,
currentbp, and _user_requested_quit attributes in
`Pdb.__init__`` instead of at first use. This ensures
these attributes are always defined and allows
removal of defensive getattr/hasattr checks
throughout the codebase.

In particular for a custom PDB subclass in
IPython, the need to use a getattr has performance
implications, and while we could set it  our `__init__`
it was easy to send a more global patch to CPython.

Should fix pythongh-140790
@gaogaotiantian gaogaotiantian merged commit 4885ecf into python:main Nov 14, 2025
50 checks passed
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 CentOS9 NoGIL Refleaks 3.x (tier-1) has failed when building commit 4885ecf.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1610/builds/2417) and take a look at the build logs.
  4. Check if the failure is related to this commit (4885ecf) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1610/builds/2417

Failed tests:

  • test_free_threading

Test leaking resources:

  • test_free_threading: file descriptors

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 9, done.        
remote: Counting objects:  12% (1/8)        
remote: Counting objects:  25% (2/8)        
remote: Counting objects:  37% (3/8)        
remote: Counting objects:  50% (4/8)        
remote: Counting objects:  62% (5/8)        
remote: Counting objects:  75% (6/8)        
remote: Counting objects:  87% (7/8)        
remote: Counting objects: 100% (8/8)        
remote: Counting objects: 100% (8/8), done.        
remote: Compressing objects:  12% (1/8)        
remote: Compressing objects:  25% (2/8)        
remote: Compressing objects:  37% (3/8)        
remote: Compressing objects:  50% (4/8)        
remote: Compressing objects:  62% (5/8)        
remote: Compressing objects:  75% (6/8)        
remote: Compressing objects:  87% (7/8)        
remote: Compressing objects: 100% (8/8)        
remote: Compressing objects: 100% (8/8), done.        
remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 1 (from 1)        
From https://github.com/python/cpython
 * branch                    main       -> FETCH_HEAD
Note: switching to '4885ecfbda4cc792691e5d488ef6cb09727eb417'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 4885ecfbda4 gh-140790: pdb: Initialize instance variables in Pdb.__init__ (#140791)
Switched to and reset branch 'main'

configure: WARNING: no system libmpdec found; falling back to pure-Python version for the decimal module

make: *** [Makefile:2493: buildbottest] Error 2

@gaogaotiantian
Copy link
Member

The buildbot alert seems to be irrelevant.

@Carreau
Copy link
Contributor Author

Carreau commented Nov 14, 2025

Thank you for the review and the merge!

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
…ython#140791)

Initialize lineno, stack, curindex, curframe, currentbp, and _user_requested_quit attributes in `Pdb.__init__``.
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.

Define all Pdb's instance variable in __init__

3 participants