[Python-Dev] About raising NotPortableWarning for CPython specific code

Terry Reedy tjreedy at udel.edu
Sat Mar 12 22:25:24 CET 2011


On 3/12/2011 8:33 AM, Laura Creighton wrote:

> The thread with the whole gory details begins here:
> http://codespeak.net/pipermail/pypy-dev/2011q1/006958.html

The second, multiplication issue does appears to be the same issue.
Augmenting my previous test:

class C(object):
     def __iter__(self):
         yield 'yes!'
     def __radd__(self, other):
         other.append('bug!')
         return other
     def __rmul__(self, other):
         other *= 2
         return other
     def __index__(self):
           return 3

class L(list):
     def __iadd__(self, other):
         list.__iadd__(self,other)
         return self
     def __mul__(self, other):
         return L(list.__imul__(self,other))

z1, z2, c = [], L(), C()
z1 += c
z2 += c
print(z1, z2, [1]*c, L([1])*c)
 >>>
['bug!'] ['yes!'] [1, 1] [1, 1, 1] # PyPy prints ['yes!'], [1, 1, 1]

I opened http://bugs.python.org/issue11477

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list