[Python-Dev] [Python-checkins] cpython (3.2): don't use a slot wrapper from a different special method (closes #14658) (original) (raw)
Mark Shannon mark at hotpy.org
Tue Apr 24 17:36:31 CEST 2012
- Previous message: [Python-Dev] [Python-checkins] cpython (3.2): don't use a slot wrapper from a different special method (closes #14658)
- Next message: [Python-Dev] [Python-checkins] cpython (3.2): don't use a slot wrapper from a different special method (closes #14658)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Benjamin Peterson wrote:
2012/4/24 Mark Shannon <mark at hotpy.org>:
I'm not happy with this fix. It's not perfect, but it's an improvement.
Admittedly code like:
class S(str): getattr_ = str._add s = S('a') print(S.b)
My typo, should be: print(s.b) (Instance not class) This doesn't work.
is a little weird. But I think it should work (ie print 'ab') properly. This works without the patch. class S(str): getattribute_ = str._add s = S('a') print(S.b)
Same typo, this does work (with correct spelling :) )
Does it? $ cat > x.py class S(str): getattribute_ = str._add s = S('a') print(S.b)
$ python3 x.py Traceback (most recent call last): File "x.py", line 4, in print(S.b) AttributeError: type object 'S' has no attribute 'b'
(Prints 'ab')
Also "slot wrapper" is a low-level implementation detail and shouldn't impact the language semantics. dict.getitem is a slot wrapper; dict.getitem is not. str.getitem is a slot wrapper; list.getitem is not. If any of these change then the semantics of the language changes.
- Previous message: [Python-Dev] [Python-checkins] cpython (3.2): don't use a slot wrapper from a different special method (closes #14658)
- Next message: [Python-Dev] [Python-checkins] cpython (3.2): don't use a slot wrapper from a different special method (closes #14658)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]