[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1d700e1aff33 by Benjamin Peterson in branch '3.3':
don't shadow the __qualname__ descriptor with __qualname__ in the class's 
__dict__ (closes #16271)
http://hg.python.org/cpython/rev/1d700e1aff33

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Here's a patch for 3.4. __qualname__ ought to have been implemented this way in 
the first place. I'll have to think about what can be done about 3.3. Maybe 
just the same fix without the removal of PyHeapType.ht_qualname. We can hope no 
one has written extensions relying on its value actually being correct.

--
keywords: +patch
nosy: +benjamin.peterson
Added file: http://bugs.python.org/file27721/qualname-in-dict.patch

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-26 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'm not sure why this would be the correct way to do it. First you are removing 
the unicode check, which looks wrong to me. Second, if ht_name works, perhaps 
ht_qualname can be made to work as well?

--

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Was does qualname need to be on the struct?

--

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

s/Was/Why/

--

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Here's the other option.

--
Added file: http://bugs.python.org/file27734/qualname2.patch

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-25 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti, pitrou
type:  - behavior
versions: +Python 3.4

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



[issue16271] weird dual behavior with changing __qualname__; different values observed through attribute and descriptor

2012-10-17 Thread Christopher the Magnificent

New submission from Christopher the Magnificent:

The output below is NOT typed at the Python interactive interpeter.  The   
shows what is being evaluated and the line below it shows what the result it.

The output gets generated here:  (lines 418-449 of the attached file)

def name_globalize_class(name, second=None):
def decorator(cls):

def printval(source, value=None):
print(  + source)
if value is not None:
print(repr(value))
print(in decorator: new name is:, repr(name))
print()
printval(cls, cls)
printval(cls.__name__, cls.__name__)
printval(cls.__qualname__, cls.__qualname__)
printval('type.__dict__[__qualname__].__get__(cls)',
 type.__dict__[__qualname__].__get__(cls))
print()

cls.__name__ = name
cls.__qualname__ = name

stuff =  cls.__name__ = {0}\n cls.__qualname__ = {0}\n
print(stuff.format(repr(name)))

printval(cls.__name__, cls.__name__)
printval(cls.__qualname__, cls.__qualname__)
printval('type.__dict__[__qualname__].__get__(cls)',
 type.__dict__[__qualname__].__get__(cls))
printval(cls, cls)
print()
globals()[name] = cls
pdb.set_trace()
return cls
return decorator

HERE IS THE OUTPUT:

 cls
class '__main__._maketokensnodes.locals._TokenClass'
 cls.__name__
'_TokenClass'
 cls.__qualname__
'_maketokensnodes.locals._TokenClass'
 type.__dict__[__qualname__].__get__(cls)
'_maketokensnodes.locals._TokenClass'

 cls.__name__ = 'KEYWORD'
 cls.__qualname__ = 'KEYWORD'

 cls.__name__
'KEYWORD'
 cls.__qualname__
'KEYWORD'
 type.__dict__[__qualname__].__get__(cls)
'_maketokensnodes.locals._TokenClass'
 cls
class '__main__._maketokensnodes.locals._TokenClass'

END OF OUTPUT

Note how after assigning to cls.__qualname__ it looks like the class's 
dictionary object has been assigned into, masking the class's C-level type 
attribute-level ht_qualname!

My gut feeling is that this has to be some kind of a bug.  Let me know if it is.

--
components: Interpreter Core
files: parser_BUGGY2.py
messages: 173217
nosy: christopherthemagnificent
priority: normal
severity: normal
status: open
title: weird dual behavior with changing __qualname__; different values 
observed through attribute and descriptor
versions: Python 3.3
Added file: http://bugs.python.org/file27604/parser_BUGGY2.py

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