Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3555)

#25794: __setattr__ does not always overload operators

Can't Edit
Can't Publish+Mail
Start Review
Created:
1 year, 6 months ago by dominikschmid93
Modified:
2 months ago
Reviewers:
berker.peksag, eryksun, storchaka+cpython
CC:
berkerpeksag, storchaka, eryksun, dominikschmid93_gmail.com, louielu
Visibility:
Public.

Patch Set 1 #

Patch Set 2 #

Total comments: 10
Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/test/test_class.py View 1 1 chunk +12 lines, -0 lines 5 comments Download
Objects/typeobject.c View 1 2 chunks +18 lines, -0 lines 5 comments Download

Messages

Total messages: 3
berkerpeksag
http://bugs.python.org/review/25794/diff/16104/Lib/test/test_class.py File Lib/test/test_class.py (right): http://bugs.python.org/review/25794/diff/16104/Lib/test/test_class.py#newcode572 Lib/test/test_class.py:572: ''' issue 25794: __setattr__ should intern the attribute name''' ...
1 year, 6 months ago #1
eryksun
http://bugs.python.org/review/25794/diff/16104/Objects/typeobject.c File Objects/typeobject.c (right): http://bugs.python.org/review/25794/diff/16104/Objects/typeobject.c#newcode5382 Objects/typeobject.c:5382: if (!PyUnicode_Check(name)) { I'd only call type.__setattr__ directly (or ...
1 year, 6 months ago #2
storchaka
2 months ago #3
https://bugs.python.org/review/25794/diff/16104/Lib/test/test_class.py
File Lib/test/test_class.py (right):

https://bugs.python.org/review/25794/diff/16104/Lib/test/test_class.py#newcod...
Lib/test/test_class.py:579: name = '__{}__'.format('add') # not interned
This may be interned after implementing the AST optimizer. str(b'__add__',
'ascii') shouldn't be optimized out. You can also add a special check:
self.assertNotIs(name, '__add__').

https://bugs.python.org/review/25794/diff/16104/Lib/test/test_class.py#newcod...
Lib/test/test_class.py:581: Test() + 1
On 2015/12/16 01:05:14, berkerpeksag wrote:
> Perhaps converting this to assertEqual would be better.

In that case it is better to replace the second 1 with something other.

https://bugs.python.org/review/25794/diff/16104/Objects/typeobject.c
File Objects/typeobject.c (right):

https://bugs.python.org/review/25794/diff/16104/Objects/typeobject.c#newcode5382
Objects/typeobject.c:5382: if (!PyUnicode_Check(name)) {
Would not be better to change just type_setattro?

An assert can be added in update_slot() instead of the comment "XXX assume name
is interned!".
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7