[issue19301] Globals declared in function scope have wrong __qualname__
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 tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
Benjamin Peterson added the comment: Oh, phoey. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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 tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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 my case, fixing this would help me write cleaner unit tests for pickle, since it would allow me to keep test classes with their test code. -- assignee: alexandre.vassalotti messages: 200453 nosy: alexandre.vassalotti, pitrou priority: high severity: normal stage: needs patch status: open title: Globals declared in function scope have wrong __qualname__ type: behavior versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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 rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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 patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19301 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19301] Globals declared in function scope have wrong __qualname__
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 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com