Skip to content
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

Local variables shadowed by global variables #35

Closed
jamesls opened this issue Mar 26, 2012 · 1 comment
Closed

Local variables shadowed by global variables #35

jamesls opened this issue Mar 26, 2012 · 1 comment

Comments

@jamesls
Copy link

jamesls commented Mar 26, 2012

Just started using pudb, and I ran into this issue and couldn't figure out what was going on:

If I have a test script like this:

i = None
def test(l):
    j = -1
    for i in range(len(l)):
        print l[i]
        print l[j]
test(range(10))

And then I:

  1. Run the script: python -m pudb.run test.py
  2. Set a break point on line 5 (print l[i])
  3. Continue until that break point is hit
  4. Create an interactive shell with '!'

I get this behavior:

>>> print l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> print j
-1
>>> print i
None
>>> print l[i]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: list indices must be integers, not NoneType

Or in other words the value of i is None, which is the value in the global scope, not the local scope. I would expect this value to be be 0. All the other local variables (j and l) display the values I would expect.

@inducer
Copy link
Owner

inducer commented Mar 26, 2012

Fixed in 4a090bf.

Thanks for the report.

@inducer inducer closed this as completed Mar 26, 2012
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

No branches or pull requests

2 participants