[Checkins] [zopefoundation/Acquisition] 80573a: Fix wrapping of matmul and imatmul (#15)

GitHub noreply at github.com
Sun Feb 5 14:07:04 CET 2017


  Branch: refs/heads/c-extension-py3
  Home:   https://github.com/zopefoundation/Acquisition
  Commit: 80573aeae0899808f5f2d5013d4849865a5ad3dc
      https://github.com/zopefoundation/Acquisition/commit/80573aeae0899808f5f2d5013d4849865a5ad3dc
  Author: stephan-hof <stephan-hof at users.noreply.github.com>
  Date:   2017-02-05 (Sun, 05 Feb 2017)

  Changed paths:
    M src/Acquisition/__init__.py
    M src/Acquisition/tests.py

  Log Message:
  -----------
  Fix wrapping of matmul and imatmul (#15)

* Improve unittest.

Before:
It was two steps
1) Acquire the method (for example __iadd__).
   On a C-Level this triggers Base_getattro
2) Then call the return object.

However this is not exactly what CPython does on a statement like this:
a += 1

CPython looks first at the number protocol of that type.
If the number protocol has the slot defined it calls it, otherwise it
raises a TypeError.
https://docs.python.org/3.6/c-api/typeobj.html?highlight=pynumbermethods#c.PyNumberMethods
=> CPython omits Base_getattro at all.

Now: By using the operator module, the unittests behave exactly as
cpython on a statement like this:
a += 1

* Support proper wrapping of matrix multiplication.




More information about the checkins mailing list