1# mode: run 2# ticket: 561 3# ticket: 3 4 5# The patch in #561 changes code generation for most special methods 6# to remove the Cython-generated wrapper and let PyType_Ready() 7# generate its own wrapper. (This wrapper would be used, for instance, 8# when using the special method as a bound method.) 9 10# To test this, we go through and verify that each affected special 11# method works as a bound method. 12 13# Special methods that are treated the same under Python 2 and 3 are 14# tested here; see also special_methods_T561_py2.pyx and 15# special_methods_T561_py3.pyx for tests of the differences between 16# Python 2 and 3. 17 18# Regarding ticket 3, we should additionally test that unbound method 19# calls to these special methods (e.g. ExtType.__init__()) do not use 20# a runtime lookup indirection. 21 22import sys 23 24__doc__ = u""" 25 >>> # If you define either setitem or delitem, you get wrapper objects 26 >>> # for both methods. (This behavior is unchanged by #561.) 27 >>> si_setitem = SetItem().__setitem__ 28 >>> si_setitem('foo', 'bar') 29 SetItem setitem 'foo' 'bar' 30 >>> si_delitem = SetItem().__delitem__ 31 >>> si_delitem('foo') 32 Traceback (most recent call last): 33 ... 34 NotImplementedError: Subscript deletion not supported by special_methods_T561.SetItem 35 >>> di_setitem = DelItem().__setitem__ 36 >>> di_setitem('foo', 'bar') 37 Traceback (most recent call last): 38 ... 39 NotImplementedError: Subscript assignment not supported by special_methods_T561.DelItem 40 >>> di_delitem = DelItem().__delitem__ 41 >>> di_delitem('foo') 42 DelItem delitem 'foo' 43 >>> sdi_setitem = SetDelItem().__setitem__ 44 >>> sdi_setitem('foo', 'bar') 45 SetDelItem setitem 'foo' 'bar' 46 >>> sdi_delitem = SetDelItem().__delitem__ 47 >>> sdi_delitem('foo') 48 SetDelItem delitem 'foo' 49 >>> g01 = object.__getattribute__(GetAttr(), '__getattribute__') 50 >>> g01('attr') 51 GetAttr getattr 'attr' 52 >>> g10 = object.__getattribute__(GetAttribute(), '__getattr__') 53 Traceback (most recent call last): 54 ... 55 AttributeError: 'special_methods_T561.GetAttribute' object has no attribute '__getattr__' 56 >>> g11 = object.__getattribute__(GetAttribute(), '__getattribute__') 57 >>> g11('attr') 58 GetAttribute getattribute 'attr' 59 >>> # If you define either setattr or delattr, you get wrapper objects 60 >>> # for both methods. (This behavior is unchanged by #561.) 61 >>> sa_setattr = SetAttr().__setattr__ 62 >>> sa_setattr('foo', 'bar') 63 SetAttr setattr 'foo' 'bar' 64 >>> sa_delattr = SetAttr().__delattr__ 65 >>> sa_delattr('foo') 66 Traceback (most recent call last): 67 ... 68 AttributeError: 'special_methods_T561.SetAttr' object has no attribute 'foo' 69 >>> da_setattr = DelAttr().__setattr__ 70 >>> da_setattr('foo', 'bar') 71 Traceback (most recent call last): 72 ... 73 AttributeError: 'special_methods_T561.DelAttr' object has no attribute 'foo' 74 >>> da_delattr = DelAttr().__delattr__ 75 >>> da_delattr('foo') 76 DelAttr delattr 'foo' 77 >>> sda_setattr = SetDelAttr().__setattr__ 78 >>> sda_setattr('foo', 'bar') 79 SetDelAttr setattr 'foo' 'bar' 80 >>> sda_delattr = SetDelAttr().__delattr__ 81 >>> sda_delattr('foo') 82 SetDelAttr delattr 'foo' 83 >>> # If you define either set or delete, you get wrapper objects 84 >>> # for both methods. (This behavior is unchanged by #561.) 85 >>> s_set = Set().__set__ 86 >>> s_set('instance', 'val') 87 Set set 'instance' 'val' 88 >>> s_delete = Set().__delete__ 89 >>> s_delete('instance') 90 Traceback (most recent call last): 91 ... 92 NotImplementedError: __delete__ 93 >>> d_set = Delete().__set__ 94 >>> d_set('instance', 'val') 95 Traceback (most recent call last): 96 ... 97 NotImplementedError: __set__ 98 >>> d_delete = Delete().__delete__ 99 >>> d_delete('instance') 100 Delete delete 'instance' 101 >>> sd_set = SetDelete().__set__ 102 >>> sd_set('instance', 'val') 103 SetDelete set 'instance' 'val' 104 >>> sd_delete = SetDelete().__delete__ 105 >>> sd_delete('instance') 106 SetDelete delete 'instance' 107 >>> # If you define __long__, you get a wrapper object for __int__. 108 >>> # (This behavior is unchanged by #561.) 109 >>> Li = Long().__int__ 110 >>> Li() 111 Long __long__ 112""" 113if sys.version_info >= (2,5): 114 __doc__ += u"""\ 115 >>> vs0 = VerySpecial(0) 116 VS __init__ 0 117 >>> vs0_index = vs0.__index__ 118 >>> vs0_index() 119 VS __index__ 0 120""" 121 122cdef class VerySpecial: 123 """ 124 >>> vs0 = VerySpecial(0) 125 VS __init__ 0 126 >>> vs1 = VerySpecial(1) 127 VS __init__ 1 128 129 >>> vs0_add = vs0.__add__ 130 >>> vs0_add(vs1) 131 VS __add__ 0 1 132 >>> vs0_sub = vs0.__sub__ 133 >>> vs0_sub(vs1) 134 VS __sub__ 0 1 135 >>> vs0_mul = vs0.__mul__ 136 >>> vs0_mul(vs1) 137 VS __mul__ 0 1 138 >>> vs0_mod = vs0.__mod__ 139 >>> vs0_mod(vs1) 140 VS __mod__ 0 1 141 >>> vs0_divmod = vs0.__divmod__ 142 >>> vs0_divmod(vs1) 143 VS __divmod__ 0 1 144 >>> vs0_pow = vs0.__pow__ 145 >>> vs0_pow(vs1) 146 VS __pow__ pow(0, 1, None) 147 >>> vs0_pow(vs1, 13) 148 VS __pow__ pow(0, 1, 13) 149 >>> vs0_neg = vs0.__neg__ 150 >>> vs0_neg() 151 VS __neg__ 0 152 >>> vs0_pos = vs0.__pos__ 153 >>> vs0_pos() 154 VS __pos__ 0 155 >>> vs0_abs = vs0.__abs__ 156 >>> vs0_abs() 157 VS __abs__ 0 158 >>> vs0_invert = vs0.__invert__ 159 >>> vs0_invert() 160 VS __invert__ 0 161 >>> vs0_lshift = vs0.__lshift__ 162 >>> vs0_lshift(vs1) 163 VS __lshift__ 0 << 1 164 >>> vs0_rshift = vs0.__rshift__ 165 >>> vs0_rshift(vs1) 166 VS __rshift__ 0 >> 1 167 >>> vs0_and = vs0.__and__ 168 >>> vs0_and(vs1) 169 VS __and__ 0 & 1 170 >>> vs0_xor = vs0.__xor__ 171 >>> vs0_xor(vs1) 172 VS __xor__ 0 ^ 1 173 >>> vs0_or = vs0.__or__ 174 >>> vs0_or(vs1) 175 VS __or__ 0 | 1 176 >>> vs0_int = vs0.__int__ 177 >>> vs0_int() 178 VS __int__ 0 179 >>> vs0_float = vs0.__float__ 180 >>> vs0_float() 181 VS __float__ 0 182 >>> vs0_iadd = vs0.__iadd__ 183 >>> vs0_iadd(vs1) 184 VS __iadd__ 0 += 1 185 >>> vs0_isub = vs0.__isub__ 186 >>> vs0_isub(vs1) 187 VS __isub__ 0 -= 1 188 >>> vs0_imul = vs0.__imul__ 189 >>> vs0_imul(vs1) 190 VS __imul__ 0 *= 1 191 >>> vs0_imod = vs0.__imod__ 192 >>> vs0_imod(vs1) 193 VS __imod__ 0 %= 1 194 >>> vs0_ipow = vs0.__ipow__ 195 >>> vs0_ipow(vs1) 196 VS __ipow__ 0 1 197 >>> vs0_ilshift = vs0.__ilshift__ 198 >>> vs0_ilshift(vs1) 199 VS __ilshift__ 0 <<= 1 200 >>> vs0_irshift = vs0.__irshift__ 201 >>> vs0_irshift(vs1) 202 VS __irshift__ 0 >>= 1 203 >>> vs0_iand = vs0.__iand__ 204 >>> vs0_iand(vs1) 205 VS __iand__ 0 &= 1 206 >>> vs0_ixor = vs0.__ixor__ 207 >>> vs0_ixor(vs1) 208 VS __ixor__ 0 ^= 1 209 >>> vs0_ior = vs0.__ior__ 210 >>> vs0_ior(vs1) 211 VS __ior__ 0 |= 1 212 >>> vs0_floordiv = vs0.__floordiv__ 213 >>> vs0_floordiv(vs1) 214 VS __floordiv__ 0 / 1 215 >>> vs0_truediv = vs0.__truediv__ 216 >>> vs0_truediv(vs1) 217 VS __truediv__ 0 / 1 218 >>> vs0_ifloordiv = vs0.__ifloordiv__ 219 >>> vs0_ifloordiv(vs1) 220 VS __ifloordiv__ 0 /= 1 221 >>> vs0_itruediv = vs0.__itruediv__ 222 >>> vs0_itruediv(vs1) 223 VS __itruediv__ 0 /= 1 224 225 # If you define an arithmetic method, you get wrapper objects for 226 # the reversed version as well. (This behavior is unchanged by #561.) 227 >>> vs0_radd = vs0.__radd__ 228 >>> vs0_radd(vs1) 229 VS __add__ 1 0 230 >>> vs0_rsub = vs0.__rsub__ 231 >>> vs0_rsub(vs1) 232 VS __sub__ 1 0 233 >>> vs0_rmul = vs0.__rmul__ 234 >>> vs0_rmul(vs1) 235 VS __mul__ 1 0 236 >>> vs0_rmod = vs0.__rmod__ 237 >>> vs0_rmod(vs1) 238 VS __mod__ 1 0 239 >>> vs0_rdivmod = vs0.__rdivmod__ 240 >>> vs0_rdivmod(vs1) 241 VS __divmod__ 1 0 242 >>> vs0_rpow = vs0.__rpow__ 243 >>> vs0_rpow(vs1) 244 VS __pow__ pow(1, 0, None) 245 >>> vs0_rlshift = vs0.__rlshift__ 246 >>> vs0_rlshift(vs1) 247 VS __lshift__ 1 << 0 248 >>> vs0_rrshift = vs0.__rrshift__ 249 >>> vs0_rrshift(vs1) 250 VS __rshift__ 1 >> 0 251 >>> vs0_rand = vs0.__rand__ 252 >>> vs0_rand(vs1) 253 VS __and__ 1 & 0 254 >>> vs0_rxor = vs0.__rxor__ 255 >>> vs0_rxor(vs1) 256 VS __xor__ 1 ^ 0 257 >>> vs0_ror = vs0.__ror__ 258 >>> vs0_ror(vs1) 259 VS __or__ 1 | 0 260 >>> vs0_rfloordiv = vs0.__rfloordiv__ 261 >>> vs0_rfloordiv(vs1) 262 VS __floordiv__ 1 / 0 263 >>> vs0_rtruediv = vs0.__rtruediv__ 264 >>> vs0_rtruediv(vs1) 265 VS __truediv__ 1 / 0 266 >>> vs0_getitem = vs0.__getitem__ 267 >>> vs0_getitem('foo') 268 VS __getitem__ 0['foo'] 269 >>> vs0_contains = vs0.__contains__ 270 >>> vs0_contains(vs1) 271 VS __contains__ 0 1 272 False 273 >>> vs0_len = vs0.__len__ 274 >>> vs0_len() 275 VS __len__ 0 276 0 277 >>> vs0_repr = vs0.__repr__ 278 >>> vs0_repr() 279 VS __repr__ 0 280 >>> vs0_hash = vs0.__hash__ 281 >>> vs0_hash() 282 VS __hash__ 0 283 1000 284 >>> vs0_call = vs0.__call__ 285 >>> vs0_call(vs1) 286 VS __call__ 0(1) 287 >>> vs0_str = vs0.__str__ 288 >>> vs0_str() 289 VS __str__ 0 290 291 # If you define __richcmp__, you get all of __lt__, __le__, 292 # __eq__, __ne__, __gt__, __ge__ (this behavior is unchanged by #561). 293 # (you don't get a __richcmp__ method, because it doesn't have a 294 # Python signature) 295 >>> vs0_lt = vs0.__lt__ 296 >>> vs0_lt(vs1) 297 VS richcmp 0 1 (kind=0) 298 >>> vs0_le = vs0.__le__ 299 >>> vs0_le(vs1) 300 VS richcmp 0 1 (kind=1) 301 >>> vs0_eq = vs0.__eq__ 302 >>> vs0_eq(vs1) 303 VS richcmp 0 1 (kind=2) 304 >>> vs0_ne = vs0.__ne__ 305 >>> vs0_ne(vs1) 306 VS richcmp 0 1 (kind=3) 307 >>> vs0_gt = vs0.__gt__ 308 >>> vs0_gt(vs1) 309 VS richcmp 0 1 (kind=4) 310 >>> vs0_ge = vs0.__ge__ 311 >>> vs0_ge(vs1) 312 VS richcmp 0 1 (kind=5) 313 >>> vs0_iter = vs0.__iter__ 314 >>> vs0_iter() 315 VS __iter__ 0 316 >>> vs0_next = vs0.__next__ 317 >>> vs0_next() 318 VS next/__next__ 0 319 320 >>> vs0_get = vs0.__get__ 321 >>> vs0_get('instance', 'owner') 322 VS __get__ 0 'instance' 'owner' 323 >>> vs0_init = vs0.__init__ 324 >>> vs0_init(0) 325 VS __init__ 0 326 """ 327 cdef readonly int value 328 329 def __init__(self, v): 330 self.value = v 331 print "VS __init__ %d" % self.value 332 333 def __add__(self, other): 334 print "VS __add__ %d %d" % (self.value, other.value) 335 336 def __sub__(self, other): 337 print "VS __sub__ %d %d" % (self.value, other.value) 338 339 def __mul__(self, other): 340 print "VS __mul__ %d %d" % (self.value, other.value) 341 342 def __div__(self, other): 343 print "VS __div__ %d %d" % (self.value, other.value) 344 345 def __mod__(self, other): 346 print "VS __mod__ %d %d" % (self.value, other.value) 347 348 def __divmod__(self, other): 349 print "VS __divmod__ %d %d" % (self.value, other.value) 350 351 def __pow__(self, other, mod): 352 print "VS __pow__ pow(%d, %d, %r)" % (self.value, other.value, mod) 353 354 def __lshift__(self, other): 355 print "VS __lshift__ %d << %d" % (self.value, other.value) 356 357 def __rshift__(self, other): 358 print "VS __rshift__ %d >> %d" % (self.value, other.value) 359 360 def __and__(self, other): 361 print "VS __and__ %d & %d" % (self.value, other.value) 362 363 def __xor__(self, other): 364 print "VS __xor__ %d ^ %d" % (self.value, other.value) 365 366 def __or__(self, other): 367 print "VS __or__ %d | %d" % (self.value, other.value) 368 369 def __floordiv__(self, other): 370 print "VS __floordiv__ %d / %d" % (self.value, other.value) 371 372 def __truediv__(self, other): 373 print "VS __truediv__ %d / %d" % (self.value, other.value) 374 375 def __neg__(self): 376 print "VS __neg__ %d" % self.value 377 378 def __pos__(self): 379 print "VS __pos__ %d" % self.value 380 381 def __abs__(self): 382 print "VS __abs__ %d" % self.value 383 384 def __nonzero__(self): 385 print "VS __nonzero__ %d" % self.value 386 387 def __invert__(self): 388 print "VS __invert__ %d" % self.value 389 390 def __int__(self): 391 print "VS __int__ %d" % self.value 392 393 def __long__(self): 394 print "VS __long__ %d" % self.value 395 396 def __float__(self): 397 print "VS __float__ %d" % self.value 398 399 def __oct__(self): 400 print "VS __oct__ %d" % self.value 401 402 def __hex__(self): 403 print "VS __hex__ %d" % self.value 404 405 def __iadd__(self, other): 406 print "VS __iadd__ %d += %d" % (self.value, other.value) 407 408 def __isub__(self, other): 409 print "VS __isub__ %d -= %d" % (self.value, other.value) 410 411 def __imul__(self, other): 412 print "VS __imul__ %d *= %d" % (self.value, other.value) 413 414 def __idiv__(self, other): 415 print "VS __idiv__ %d /= %d" % (self.value, other.value) 416 417 def __imod__(self, other): 418 print "VS __imod__ %d %%= %d" % (self.value, other.value) 419 420 def __ipow__(self, other): 421 # We must declare mod as an argument, but we must not touch it 422 # or we'll get a segfault. See #562 423 print "VS __ipow__ %d %d" % (self.value, other.value) 424 425 def __ilshift__(self, other): 426 print "VS __ilshift__ %d <<= %d" % (self.value, other.value) 427 428 def __irshift__(self, other): 429 print "VS __irshift__ %d >>= %d" % (self.value, other.value) 430 431 def __iand__(self, other): 432 print "VS __iand__ %d &= %d" % (self.value, other.value) 433 434 def __ixor__(self, other): 435 print "VS __ixor__ %d ^= %d" % (self.value, other.value) 436 437 def __ior__(self, other): 438 print "VS __ior__ %d |= %d" % (self.value, other.value) 439 440 def __ifloordiv__(self, other): 441 print "VS __ifloordiv__ %d /= %d" % (self.value, other.value) 442 443 def __itruediv__(self, other): 444 print "VS __itruediv__ %d /= %d" % (self.value, other.value) 445 446 def __index__(self): 447 print "VS __index__ %d" % self.value 448 449 def __getitem__(self, index): 450 print "VS __getitem__ %d[%r]" % (self.value, index) 451 452 def __contains__(self, other): 453 print "VS __contains__ %d %d" % (self.value, other.value) 454 455 def __len__(self): 456 print "VS __len__ %d" % (self.value) 457 458 def __cmp__(self, other): 459 print "VS __cmp__ %d %d" % (self.value, other.value) 460 461 def __repr__(self): 462 print "VS __repr__ %d" % self.value 463 464 def __hash__(self): 465 print "VS __hash__ %d" % self.value 466 return self.value + 1000 467 468 def __call__(self, other): 469 print "VS __call__ %d(%d)" % (self.value, other.value) 470 471 def __str__(self): 472 print "VS __str__ %d" % self.value 473 474 def __richcmp__(self, other, kind): 475 print "VS richcmp %d %d (kind=%r)" % (self.value, other.value, kind) 476 477 def __iter__(self): 478 print "VS __iter__ %d" % self.value 479 480 def __next__(self): 481 print "VS next/__next__ %d" % self.value 482 483 def __get__(self, inst, own): 484 print "VS __get__ %d %r %r" % (self.value, inst, own) 485 486cdef class SetItem: 487 def __setitem__(self, index, value): 488 print "SetItem setitem %r %r" % (index, value) 489 490cdef class DelItem: 491 def __delitem__(self, index): 492 print "DelItem delitem %r" % index 493 494cdef class SetDelItem: 495 def __setitem__(self, index, value): 496 print "SetDelItem setitem %r %r" % (index, value) 497 498 def __delitem__(self, index): 499 print "SetDelItem delitem %r" % index 500 501cdef class GetAttr: 502 def __getattr__(self, attr): 503 print "GetAttr getattr %r" % attr 504 505cdef class GetAttribute: 506 def __getattribute__(self, attr): 507 print "GetAttribute getattribute %r" % attr 508 509cdef class SetAttr: 510 def __setattr__(self, attr, val): 511 print "SetAttr setattr %r %r" % (attr, val) 512 513cdef class DelAttr: 514 def __delattr__(self, attr): 515 print "DelAttr delattr %r" % attr 516 517cdef class SetDelAttr: 518 def __setattr__(self, attr, val): 519 print "SetDelAttr setattr %r %r" % (attr, val) 520 521 def __delattr__(self, attr): 522 print "SetDelAttr delattr %r" % attr 523 524cdef class Set: 525 def __set__(self, inst, val): 526 print "Set set %r %r" % (inst, val) 527 528cdef class Delete: 529 def __delete__(self, inst): 530 print "Delete delete %r" % inst 531 532cdef class SetDelete: 533 def __set__(self, inst, val): 534 print "SetDelete set %r %r" % (inst, val) 535 536 def __delete__(self, inst): 537 print "SetDelete delete %r" % inst 538 539cdef class Long: 540 def __long__(self): 541 print "Long __long__" 542 543cdef class GetAttrGetItemRedirect: 544 """ 545 >>> o = GetAttrGetItemRedirect() 546 547 >>> assert o.item == o['item'] 548 >>> source, item_value = o.item 549 >>> assert source == 'item', source 550 551 >>> assert o['attr'] == o.attr 552 >>> source, attr_value = o['attr'] 553 >>> assert source == 'attr', source 554 555 >>> assert item_value is attr_value, repr((item_value, attr_value)) 556 """ 557 cdef object obj 558 def __cinit__(self): 559 self.obj = object() 560 561 def __getattr__(self, name): 562 if name == 'item': 563 return self[name] 564 return ('attr', self.obj) 565 566 def __getitem__(self, key): 567 if key == 'attr': 568 return getattr(self, key) 569 return ('item', self.obj) 570 571 572# test unbound method usage in subtypes 573 574cdef class VerySpecialSubType(VerySpecial): 575 """ 576 >>> vs0 = VerySpecialSubType(0) 577 VS __init__ 0 578 >>> vs1 = VerySpecialSubType(1) 579 VS __init__ 1 580 581 >>> vs0_add = vs0.__add__ 582 >>> vs0_add(vs1) 583 VS __add__ 0 1 584 >>> vs0_sub = vs0.__sub__ 585 >>> vs0_sub(vs1) 586 VS __sub__ 0 1 587 >>> vs0_mul = vs0.__mul__ 588 >>> vs0_mul(vs1) 589 VS __mul__ 0 1 590 >>> vs0_mod = vs0.__mod__ 591 >>> vs0_mod(vs1) 592 VS __mod__ 0 1 593 >>> vs0_divmod = vs0.__divmod__ 594 >>> vs0_divmod(vs1) 595 VS __divmod__ 0 1 596 >>> vs0_pow = vs0.__pow__ 597 >>> vs0_pow(vs1) 598 VS __pow__ pow(0, 1, None) 599 >>> vs0_pow(vs1, 13) 600 VS __pow__ pow(0, 1, 13) 601 >>> vs0_neg = vs0.__neg__ 602 >>> vs0_neg() 603 VS __neg__ 0 604 >>> vs0_pos = vs0.__pos__ 605 >>> vs0_pos() 606 VS __pos__ 0 607 >>> vs0_abs = vs0.__abs__ 608 >>> vs0_abs() 609 VS __abs__ 0 610 >>> vs0_invert = vs0.__invert__ 611 >>> vs0_invert() 612 VS __invert__ 0 613 >>> vs0_lshift = vs0.__lshift__ 614 >>> vs0_lshift(vs1) 615 VS __lshift__ 0 << 1 616 >>> vs0_rshift = vs0.__rshift__ 617 >>> vs0_rshift(vs1) 618 VS __rshift__ 0 >> 1 619 >>> vs0_and = vs0.__and__ 620 >>> vs0_and(vs1) 621 VS __and__ 0 & 1 622 >>> vs0_xor = vs0.__xor__ 623 >>> vs0_xor(vs1) 624 VS __xor__ 0 ^ 1 625 >>> vs0_or = vs0.__or__ 626 >>> vs0_or(vs1) 627 VS __or__ 0 | 1 628 >>> vs0_int = vs0.__int__ 629 >>> vs0_int() 630 VS __int__ 0 631 >>> vs0_float = vs0.__float__ 632 >>> vs0_float() 633 VS __float__ 0 634 >>> vs0_iadd = vs0.__iadd__ 635 >>> vs0_iadd(vs1) 636 VS __iadd__ 0 += 1 637 >>> vs0_isub = vs0.__isub__ 638 >>> vs0_isub(vs1) 639 VS __isub__ 0 -= 1 640 >>> vs0_imul = vs0.__imul__ 641 >>> vs0_imul(vs1) 642 VS __imul__ 0 *= 1 643 >>> vs0_imod = vs0.__imod__ 644 >>> vs0_imod(vs1) 645 VS __imod__ 0 %= 1 646 >>> vs0_ipow = vs0.__ipow__ 647 >>> vs0_ipow(vs1) 648 VS __ipow__ 0 1 649 >>> vs0_ilshift = vs0.__ilshift__ 650 >>> vs0_ilshift(vs1) 651 VS __ilshift__ 0 <<= 1 652 >>> vs0_irshift = vs0.__irshift__ 653 >>> vs0_irshift(vs1) 654 VS __irshift__ 0 >>= 1 655 >>> vs0_iand = vs0.__iand__ 656 >>> vs0_iand(vs1) 657 VS __iand__ 0 &= 1 658 >>> vs0_ixor = vs0.__ixor__ 659 >>> vs0_ixor(vs1) 660 VS __ixor__ 0 ^= 1 661 >>> vs0_ior = vs0.__ior__ 662 >>> vs0_ior(vs1) 663 VS __ior__ 0 |= 1 664 >>> vs0_floordiv = vs0.__floordiv__ 665 >>> vs0_floordiv(vs1) 666 VS __floordiv__ 0 / 1 667 >>> vs0_truediv = vs0.__truediv__ 668 >>> vs0_truediv(vs1) 669 VS __truediv__ 0 / 1 670 >>> vs0_ifloordiv = vs0.__ifloordiv__ 671 >>> vs0_ifloordiv(vs1) 672 VS __ifloordiv__ 0 /= 1 673 >>> vs0_itruediv = vs0.__itruediv__ 674 >>> vs0_itruediv(vs1) 675 VS __itruediv__ 0 /= 1 676 677 # If you define an arithmetic method, you get wrapper objects for 678 # the reversed version as well. (This behavior is unchanged by #561.) 679 >>> vs0_radd = vs0.__radd__ 680 >>> vs0_radd(vs1) 681 VS __add__ 1 0 682 >>> vs0_rsub = vs0.__rsub__ 683 >>> vs0_rsub(vs1) 684 VS __sub__ 1 0 685 >>> vs0_rmul = vs0.__rmul__ 686 >>> vs0_rmul(vs1) 687 VS __mul__ 1 0 688 >>> vs0_rmod = vs0.__rmod__ 689 >>> vs0_rmod(vs1) 690 VS __mod__ 1 0 691 >>> vs0_rdivmod = vs0.__rdivmod__ 692 >>> vs0_rdivmod(vs1) 693 VS __divmod__ 1 0 694 >>> vs0_rpow = vs0.__rpow__ 695 >>> vs0_rpow(vs1) 696 VS __pow__ pow(1, 0, None) 697 >>> vs0_rlshift = vs0.__rlshift__ 698 >>> vs0_rlshift(vs1) 699 VS __lshift__ 1 << 0 700 >>> vs0_rrshift = vs0.__rrshift__ 701 >>> vs0_rrshift(vs1) 702 VS __rshift__ 1 >> 0 703 >>> vs0_rand = vs0.__rand__ 704 >>> vs0_rand(vs1) 705 VS __and__ 1 & 0 706 >>> vs0_rxor = vs0.__rxor__ 707 >>> vs0_rxor(vs1) 708 VS __xor__ 1 ^ 0 709 >>> vs0_ror = vs0.__ror__ 710 >>> vs0_ror(vs1) 711 VS __or__ 1 | 0 712 >>> vs0_rfloordiv = vs0.__rfloordiv__ 713 >>> vs0_rfloordiv(vs1) 714 VS __floordiv__ 1 / 0 715 >>> vs0_rtruediv = vs0.__rtruediv__ 716 >>> vs0_rtruediv(vs1) 717 VS __truediv__ 1 / 0 718 >>> vs0_getitem = vs0.__getitem__ 719 >>> vs0_getitem('foo') 720 VS __getitem__ 0['foo'] 721 >>> vs0_contains = vs0.__contains__ 722 >>> vs0_contains(vs1) 723 VS __contains__ 0 1 724 False 725 >>> vs0_len = vs0.__len__ 726 >>> vs0_len() 727 VS __len__ 0 728 0 729 >>> vs0_repr = vs0.__repr__ 730 >>> vs0_repr() 731 VS __repr__ 0 732 >>> vs0_hash = vs0.__hash__ 733 >>> vs0_hash() 734 VS __hash__ 0 735 1000 736 >>> vs0_call = vs0.__call__ 737 >>> vs0_call(vs1) 738 VS __call__ 0(1) 739 >>> vs0_str = vs0.__str__ 740 >>> vs0_str() 741 VS __str__ 0 742 >>> vs0_lt = vs0.__lt__ 743 >>> vs0_lt(vs1) 744 VS richcmp 0 1 (kind=0) 745 >>> vs0_le = vs0.__le__ 746 >>> vs0_le(vs1) 747 VS richcmp 0 1 (kind=1) 748 >>> vs0_eq = vs0.__eq__ 749 >>> vs0_eq(vs1) 750 VS richcmp 0 1 (kind=2) 751 >>> vs0_ne = vs0.__ne__ 752 >>> vs0_ne(vs1) 753 VS richcmp 0 1 (kind=3) 754 >>> vs0_gt = vs0.__gt__ 755 >>> vs0_gt(vs1) 756 VS richcmp 0 1 (kind=4) 757 >>> vs0_ge = vs0.__ge__ 758 >>> vs0_ge(vs1) 759 VS richcmp 0 1 (kind=5) 760 >>> vs0_iter = vs0.__iter__ 761 >>> vs0_iter() 762 VS __iter__ 0 763 >>> vs0_next = vs0.__next__ 764 >>> vs0_next() 765 VS next/__next__ 0 766 >>> vs0_get = vs0.__get__ 767 >>> vs0_get('instance', 'owner') 768 VS __get__ 0 'instance' 'owner' 769 >>> vs0_init = vs0.__init__ 770 >>> vs0_init(0) 771 VS __init__ 0 772 """ 773 def __init__(self, v): 774 VerySpecial.__init__(self, v) 775 776 def __add__(self, other): 777 return VerySpecial.__add__(self, other) 778 779 def __sub__(self, other): 780 return VerySpecial.__sub__(self, other) 781 782 def __mul__(self, other): 783 return VerySpecial.__mul__(self, other) 784 785 def __div__(self, other): 786 return VerySpecial.__div__(self, other) 787 788 def __mod__(self, other): 789 return VerySpecial.__mod__(self, other) 790 791 def __divmod__(self, other): 792 return VerySpecial.__divmod__(self, other) 793 794 def __pow__(self, other, mod): 795 return VerySpecial.__pow__(self, other, mod) 796 797 def __lshift__(self, other): 798 return VerySpecial.__lshift__(self, other) 799 800 def __rshift__(self, other): 801 return VerySpecial.__rshift__(self, other) 802 803 def __and__(self, other): 804 return VerySpecial.__and__(self, other) 805 806 def __xor__(self, other): 807 return VerySpecial.__xor__(self, other) 808 809 def __or__(self, other): 810 return VerySpecial.__or__(self, other) 811 812 def __floordiv__(self, other): 813 return VerySpecial.__floordiv__(self, other) 814 815 def __truediv__(self, other): 816 return VerySpecial.__truediv__(self, other) 817 818 def __neg__(self): 819 return VerySpecial.__neg__(self) 820 821 def __pos__(self): 822 return VerySpecial.__pos__(self) 823 824 def __abs__(self): 825 return VerySpecial.__abs__(self) 826 827 def __nonzero__(self): 828 return VerySpecial.__nonzero__(self) 829 830 def __invert__(self): 831 return VerySpecial.__invert__(self) 832 833 def __int__(self): 834 return VerySpecial.__int__(self) 835 836 def __long__(self): 837 return VerySpecial.__long__(self) 838 839 def __float__(self): 840 return VerySpecial.__float__(self) 841 842 def __oct__(self): 843 return VerySpecial.__oct__(self) 844 845 def __hex__(self): 846 return VerySpecial.__hex__(self) 847 848 def __iadd__(self, other): 849 return VerySpecial.__iadd__(self, other) 850 851 def __isub__(self, other): 852 return VerySpecial.__isub__(self, other) 853 854 def __imul__(self, other): 855 return VerySpecial.__imul__(self, other) 856 857 def __idiv__(self, other): 858 return VerySpecial.__idiv__(self, other) 859 860 def __imod__(self, other): 861 return VerySpecial.__imod__(self, other) 862 863 def __ipow__(self, other): 864 return VerySpecial.__ipow__(self, other) 865 866 def __ilshift__(self, other): 867 return VerySpecial.__ilshift__(self, other) 868 869 def __irshift__(self, other): 870 return VerySpecial.__irshift__(self, other) 871 872 def __iand__(self, other): 873 return VerySpecial.__iand__(self, other) 874 875 def __ixor__(self, other): 876 return VerySpecial.__ixor__(self, other) 877 878 def __ior__(self, other): 879 return VerySpecial.__ior__(self, other) 880 881 def __ifloordiv__(self, other): 882 return VerySpecial.__ifloordiv__(self, other) 883 884 def __itruediv__(self, other): 885 return VerySpecial.__itruediv__(self, other) 886 887 def __index__(self): 888 return VerySpecial.__index__(self) 889 890 def __getitem__(self, index): 891 return VerySpecial.__getitem__(self, index) 892 893 def __contains__(self, other): 894 return VerySpecial.__contains__(self, other) 895 896 def __len__(self): 897 return VerySpecial.__len__(self) 898 899 def __cmp__(self, other): 900 return VerySpecial.__cmp__(self, other) 901 902 def __repr__(self): 903 return VerySpecial.__repr__(self) 904 905 def __hash__(self): 906 return VerySpecial.__hash__(self) 907 908 def __call__(self, arg): 909 return VerySpecial.__call__(self, arg) 910 911 def __str__(self): 912 return VerySpecial.__str__(self) 913 914# there is no __richcmp__ at the Python level 915# def __richcmp__(self, other, kind): 916# return VerySpecial.__richcmp__(self, other, kind) 917 918 def __iter__(self): 919 return VerySpecial.__iter__(self) 920 921 def __next__(self): 922 return VerySpecial.__next__(self) 923 924 def __get__(self, inst, own): 925 return VerySpecial.__get__(self, inst, own) 926