[issue32806] locally imported modules are unaccessible in lambdas in pdb

2018-02-09 Thread Yuri Kanivetsky

New submission from Yuri Kanivetsky <yuri.kanivet...@gmail.com>:

Consider the following script:

# import pdb; pdb.set_trace()
# import re
def f():
import re
print((lambda: re.findall('a', 'aaa'))())
import pdb; pdb.set_trace()
print('test')
f()

When you run it and try to evaluate `(lambda: re.findall('a', 'aaa'))()`, you 
get:

['a', 'a', 'a']
> /home/yuri/_/1.py(7)f()
-> print('test')
(Pdb) (lambda: re.findall('a', 'aaa'))()
*** NameError: name 're' is not defined
(Pdb) import re
(Pdb) (lambda: re.findall('a', 'aaa'))()
*** NameError: name 're' is not defined
(Pdb) 

With the commented out breakpoint it works:

> /home/yuri/_/a.py(3)()
-> def f():
(Pdb) import re
(Pdb) (lambda: re.findall('a', 'aaa'))()
['a', 'a', 'a']
(Pdb) 

Also it works with uncommented global import and second breakpoint:

['a', 'a', 'a']
> /srv/http/sl/makosh/a.py(7)f()
-> print('test')
(Pdb) (lambda: re.findall('a', 'aaa'))()
['a', 'a', 'a']
(Pdb) 

>From what I can see the issue occurs when there's no `re` in `globals` 
>argument here: https://github.com/python/cpython/blob/v3.6.4/Lib/pdb.py#L376

I've run into it when trying to grep some object's attribute names, like:

!list(filter(lambda x: re.search('class', x), dir(__name__)))

--
messages: 311871
nosy: Yuri Kanivetsky
priority: normal
severity: normal
status: open
title: locally imported modules are unaccessible in lambdas in pdb
type: behavior
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32806>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32450] non-descriptive variable name

2018-01-06 Thread Yuri Kanivetsky

Yuri Kanivetsky <yuri.kanivet...@gmail.com> added the comment:

Well, it's just that I was digging into Python's code. And it took me quite a 
while to figure out what the variable holds. Running into "ndots" name 
clarified that. That generally means that variable name doesn't describe its 
content well. But I'm new to Python's code, so it might not be the case. Feel 
free to close the issue.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32450>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32450] non-descriptive variable name

2017-12-29 Thread Yuri Kanivetsky

New submission from Yuri Kanivetsky <yuri.kanivet...@gmail.com>:

Not a big issue, really. At some point the code switches from "ndots" name:

https://github.com/python/cpython/blob/v3.7.0a3/Python/ast.c#L3385

to "level" name:

https://github.com/python/cpython/blob/v3.7.0a3/Python/Python-ast.c#L1671

Be it "ndots" everywhere, it could save me some time.

------
messages: 309212
nosy: Yuri Kanivetsky
priority: normal
severity: normal
status: open
title: non-descriptive variable name
type: enhancement
versions: Python 3.7

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32450>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com