[Checkins] [zopefoundation/Acquisition] 8b5d8a: Improve unittest.
    GitHub 
    noreply at github.com
       
    Sat Feb  4 16:46:02 CET 2017
    
    
  
  Branch: refs/heads/fix-matrix-mul
  Home:   https://github.com/zopefoundation/Acquisition
  Commit: 8b5d8a82eabdef2f2d3a72a283dde68f7f75416e
      https://github.com/zopefoundation/Acquisition/commit/8b5d8a82eabdef2f2d3a72a283dde68f7f75416e
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-04 (Sat, 04 Feb 2017)
  Changed paths:
    M src/Acquisition/tests.py
  Log Message:
  -----------
  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
  Commit: 077f38ad9846fdc418726cd88d93fdef7abc8ec6
      https://github.com/zopefoundation/Acquisition/commit/077f38ad9846fdc418726cd88d93fdef7abc8ec6
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-04 (Sat, 04 Feb 2017)
  Changed paths:
    M src/Acquisition/__init__.py
    M src/Acquisition/tests.py
  Log Message:
  -----------
  Support proper wrapping of matrix multiplication.
Compare: https://github.com/zopefoundation/Acquisition/compare/8b5d8a82eabd^...077f38ad9846
    
    
More information about the checkins
mailing list