[issue13672] Add co_qualname attribute in code objects

2021-12-29 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> Propagate qualname from the compiler unit to code objects for 
finer grained profiling data

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2020-02-19 Thread Alex Hall


Alex Hall  added the comment:

I think this would be very useful in tracebacks. If a traceback line had a more 
useful name like `MyClass.__init__` instead of just `__init__` or 
`my_decorator..wrapper` instead of just `wrapper` it would provide 
useful context to the frame.

--
nosy: +alexmojaki

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2014-07-03 Thread Berker Peksag

Changes by Berker Peksag :


--
versions: +Python 3.5 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2013-04-13 Thread James Pye

James Pye added the comment:

Considering the API changes necessary for adding qualname, perhaps a better 
solution would be to just start using the qualname instead of the function's 
"basename"--co_name is the qualname. This would offer an automatic improvement 
to the readability of coverage/profiling tool reports. Admittedly, not sure 
what kind of breakage might ensue... =\

--
nosy: +James.Pye

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2012-06-25 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

PyCode_New and PyCode_NewEmpty are documented public APIs, so you can't change 
their signatures like that.

--
nosy: +georg.brandl
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2012-06-25 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis  added the comment:

Could this patch be included in Python 3.3?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2012-01-24 Thread Meador Inge

Meador Inge  added the comment:

This seems to be a useful feature to me.  Another area where it can help
is with fixing function types.  Currently the qualname can be lost:

>>> def f():
...def g():
...   pass
...return g
... 
>>> g = f()
>>> g
.g at 0x7f1dac4d8ba0>
>>> types.FunctionType(f.__code__, {})

>>> types.FunctionType(g.__code__, {})

There is no way to specify a qualname when constructing a
'FunctionType'.  The name is derived from the code object.  The
qualname could be too if we fix this issue.  I will open another issue
for the 'FunctionType' problem.

I have attached a WIP patch.  It passes the full test suite.  I am 
somewhat unsure about the CAPI changes, though.  They are a breaking API
change.  Do we need a *_QualName version instead like we did for
'PyFunction_NewWithQualName'?  I think probably so.  I will add doc
updates to the patch once the API stuff gets worked out.

--
keywords: +patch
Added file: http://bugs.python.org/file24317/issue13672-v0.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2012-01-24 Thread Meador Inge

Meador Inge  added the comment:

On Wed, Dec 28, 2011 at 3:11 PM, Eric Snow  wrote:

> One sticky point is that there isn't a guarantee of one-to-one between 
> function object and code object.  A code object could be bound to several
> different functions as happens with function definitions (particularly 
> lambdas) inside comprehensions.
>
> Also, if a code object is not associated with a function, i.e. one generated 
> by exec, what should the qualname for the code object be?  How
> about, in CPython, the code objects created for classes and modules?

We already these issues with 'co_name', though.  These cases can be
treated the same as they are for 'co_name':

''
>>> compile('[i for i in [1, 2]]', '', 'exec').co_consts[0].co_qualname
''
>>> compile('class T: pass', '', 'exec').co_consts[0].co_qualname
'T'
>>> compile('class T: pass', '', 'exec').co_consts[0].co_name
'T'
>>> compile('a = 12', '', 'exec').co_name
''
>>> compile('a = 12', '', 'exec').co_qualname
''
>>> compile('lambda x: x', '', 'exec').co_consts[0].co_qualname
''
>>> compile('lambda x: x', '', 'exec').co_consts[0].co_name
''

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Meador Inge

Changes by Meador Inge :


--
nosy: +meador.inge
stage:  -> needs patch
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Eric Snow

Eric Snow  added the comment:

True.  I wonder, though if perhaps a co_func (as a weak ref) or co_orig_func 
would be better, since co_qualname would be built from the original function 
anyway.  Then you could call "code.co_func.func_qualname".

One sticky point is that there isn't a guarantee of one-to-one between function 
object and code object.  A code object could be bound to several different 
functions as happens with function definitions (particularly lambdas) inside 
comprehensions.

Also, if a code object is not associated with a function, i.e. one generated by 
exec, what should the qualname for the code object be?  How about, in CPython, 
the code objects created for classes and modules?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis  added the comment:

co_qualname could still be useful if somebody has code object without frame 
object.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Eric Snow

Eric Snow  added the comment:

with f_func (see #12857) you would get that for free:

>>> frame.f_func.__qualname__
'A.f1'

--
nosy: +eric.snow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2011-12-28 Thread Arfrever Frehtes Taifersar Arahesis

New submission from Arfrever Frehtes Taifersar Arahesis 
:

PEP 3155 added qualified name as __qualname__ attribute in classes and 
functions. It would be useful if qualified name was also available as 
co_qualname attribute of code objects.

>>> import sys
>>> class A:
... def f1():
... return B.f2()
... 
>>> class B:
... def f2():
... return sys._getframe(1)
...
>>> A.f1.__name__
'f1'
>>> A.f1.__qualname__
'A.f1'
>>> B.f2.__name__
'f2'
>>> B.f2.__qualname__
'B.f2'
>>> frame = A.f1()
>>> frame

>>> frame.f_code
", line 2>
>>> frame.f_code.co_name
'f1'
>>> frame.f_code.co_qualname
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'code' object has no attribute 'co_qualname'


Suggested behavior:
>>> frame.f_code.co_qualname
'A.f1'

--
components: Interpreter Core
messages: 150312
nosy: Arfrever, pitrou
priority: normal
severity: normal
status: open
title: Add co_qualname attribute in code objects
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com