Alexandre Vassalotti added the comment:
It seems that we are missing support for nested globals:
def f():
... global C
... class C:
... class D:
... pass
...
f()
C.D.__qualname__
'f.locals.C.D'
--
status: closed - open
___
Python
Benjamin Peterson added the comment:
Oh, phoey.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19301
___
___
Python-bugs-list mailing list
Roundup Robot added the comment:
New changeset bb2affc1e317 by Benjamin Peterson in branch 'default':
cleanup the construction of __qualname__ (closes #19301 again)
http://hg.python.org/cpython/rev/bb2affc1e317
--
status: open - closed
___
Python
New submission from Alexandre Vassalotti:
The value of __qualname__ for globals declared in function scope doesn't seems
right to me:
def f():
...global C
...class C: pass
...return C.__qualname__
...
f()
'f.locals.C'
It would be much more useful to return 'C' in this case. In
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19301
___
Antoine Pitrou added the comment:
That's interesting. I suppose it requires some tweaking in the compiler to get
right.
--
nosy: +benjamin.peterson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19301
Benjamin Peterson added the comment:
I suppose it would also be desirable to have
def f():
C = None
def g():
nonlocal C
class C: pass
return g()
have a different qualname, too?
--
___
Python tracker
Alexandre Vassalotti added the comment:
Supporting nonlocal variables would be nice. However, unless it is easy to
implement, I don't think it is worth the effort since these variables can't be
accessed outside the enclosing function's scope.
--
Roundup Robot added the comment:
New changeset 35b384ed594b by Benjamin Peterson in branch 'default':
give explicitly global functions and classes a global __qualname__ (closes
#19301)
http://hg.python.org/cpython/rev/35b384ed594b
--
nosy: +python-dev
resolution: - fixed
stage: needs
Benjamin Peterson added the comment:
There you go. I could do nonlocal, but that's a more work for no real benefit
besides consistency.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19301
10 matches
Mail list logo