[Checkins] [zopefoundation/Acquisition] 4b1549: Improve some Wrapper methods by

GitHub noreply at github.com
Wed Feb 22 08:30:46 CET 2017


  Branch: refs/heads/c-extension-clean
  Home:   https://github.com/zopefoundation/Acquisition
  Commit: 4b1549f7151c93240cac7cb54f8673a784d1deab
      https://github.com/zopefoundation/Acquisition/commit/4b1549f7151c93240cac7cb54f8673a784d1deab
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Improve some Wrapper methods by

- Replace tabs with spaces.
- Braces on the same line as if.
- indent with 4 spaces.
- Use OBJECT for typecast.


  Commit: 4d95201f8ad6cc9d950aec09ca684e75c4d5a03d
      https://github.com/zopefoundation/Acquisition/commit/4d95201f8ad6cc9d950aec09ca684e75c4d5a03d
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor CallMethodO.

Did not like they way it handles the ref-count of args.
All the other C-API calls do *not* decref the reference count of args.
So this method behaves not as you usually expect.

Add a new method 'CallMethodArgs' which makes it easier to call methods
where format strings are used to specify positional arguments.


  Commit: 33ae28e3562d54f08165d0be611d339c77dfafc6
      https://github.com/zopefoundation/Acquisition/commit/33ae28e3562d54f08165d0be611d339c77dfafc6
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Let the number protocol wrappers use the new CallMethodArgs method.

This is results in a 20% speedup, since PyObject_CallMethod creates
*always* a new string (unicode in py3) object from the 'char *' pointer.


  Commit: 3d8fc85c03113398fd214375fa5e0fd9ee872f47
      https://github.com/zopefoundation/Acquisition/commit/3d8fc85c03113398fd214375fa5e0fd9ee872f47
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Implement the tp_new slot.

With this change it is impossible to create a Wrapper object where
'self->obj' == NULL. __new__ is the very first place where a new
instance is created and there it is ensured that self->obj is set to a
reasonable value. I have seen no other code where self->obj is set.

This allows now to change several places in _Acquisition.c where
self->obj is checked for NULL pointer. Which leads to simpler code.


  Commit: 357add6fa73f5404d4d007f2b8defe2074b82627
      https://github.com/zopefoundation/Acquisition/commit/357add6fa73f5404d4d007f2b8defe2074b82627
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_special

* Make use of the fact that 'self->obj' cannot be NULL (if its of type Wrapper)
* Replace tabs with spaces
* Use 4 spaces to indent


  Commit: c5c5a87583bab71f292a4193b6c710e46209554c
      https://github.com/zopefoundation/Acquisition/commit/c5c5a87583bab71f292a4193b6c710e46209554c
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Clean up: Wrapper_findattr_name

- Ident with 4 spaces
- replace tabs with spaces
- More use of braces. I know in some situations they can be omited,
  but they are very dangerous and typically avoided.
- Introduce two macros to check
 - if a string starts with another string
 - if a string is equal to another
- move the swallowing of attribute error into function for reuse.

The string macros and swallow_attribute_error have to potential to be
user for more cleanups.


  Commit: 45b447097b7db355c1eac3ea9aa3a18467ec1600
      https://github.com/zopefoundation/Acquisition/commit/45b447097b7db355c1eac3ea9aa3a18467ec1600
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_acquire.


  Commit: 4a1bfd5906c46b17f0e1cd7e1e45ffe2940b6480
      https://github.com/zopefoundation/Acquisition/commit/4a1bfd5906c46b17f0e1cd7e1e45ffe2940b6480
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_getattro

Due to __new__ there is always self->obj.


  Commit: 23a2922a9373c8a886d479188f12d66972cbe409
      https://github.com/zopefoundation/Acquisition/commit/23a2922a9373c8a886d479188f12d66972cbe409
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_[get,set]attro

* Make use of the fact that no empty wrappers exist any more.
* This hand craftet startswith has no meassurable speed boost => omitted.
* The usual spaces/tabs/indent stuff.


  Commit: 9822ab68851f5ed638882024f76b5ac15f3d6c7e
      https://github.com/zopefoundation/Acquisition/commit/9822ab68851f5ed638882024f76b5ac15f3d6c7e
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_[rich]compare


  Commit: 11103f7e3a147dba7696f0e66d5534e65801972d
      https://github.com/zopefoundation/Acquisition/commit/11103f7e3a147dba7696f0e66d5534e65801972d
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_[repr,str,unicode]

Just the right indentation.


  Commit: 5e643c0fc78175fe4a1f0d4f314b915585613995
      https://github.com/zopefoundation/Acquisition/commit/5e643c0fc78175fe4a1f0d4f314b915585613995
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor: Wrapper_coerce


  Commit: bb71c928fd49beb12ae86a053e222c2bd115e04b
      https://github.com/zopefoundation/Acquisition/commit/bb71c928fd49beb12ae86a053e222c2bd115e04b
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor Wrapper_acquire_method

Typical tab/spaces/indent stuff.


  Commit: ecdb4f412b727e8b3b896098bec24a291b90ea91
      https://github.com/zopefoundation/Acquisition/commit/ecdb4f412b727e8b3b896098bec24a291b90ea91
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  White space tab cleanup.


  Commit: f7f11ac27261f78df12bdd9696a4d9bb5866a137
      https://github.com/zopefoundation/Acquisition/commit/f7f11ac27261f78df12bdd9696a4d9bb5866a137
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor acquire_of.

Instead of two functiond doing nearly the same, create a now one with
the Wrapper class to create as a parameter.
Since only a single argument is needed use METH_O instead of VARARGS.
Now the argument parsing inside the function can be omited, because
python does this for us.


  Commit: 87eb71a740bb2aca8f485d8c1d239018880b3105
      https://github.com/zopefoundation/Acquisition/commit/87eb71a740bb2aca8f485d8c1d239018880b3105
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [module|capi]_aq_acquire


  Commit: 9af9a8c515ada1de43ad62af88e364647faeb54e
      https://github.com/zopefoundation/Acquisition/commit/9af9a8c515ada1de43ad62af88e364647faeb54e
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor capi_aq_get.

Almost the same as 'aq_acquire'.
Only difference is that the default value is always returned if *any*
excpetion happens.
aq_acquire returns the default value just on Attribute error.

The important bit is to call aq_aquire with
filter=NULL
extra=NULL
explicit=1


  Commit: cc5d12b9a93b826932551a755bd2ea3f424efa1d
      https://github.com/zopefoundation/Acquisition/commit/cc5d12b9a93b826932551a755bd2ea3f424efa1d
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [capi|module]_aq_base

* __new__ ensures that self->obj is never NULL
* Use METH_O instead of manual parsing a single argument.


  Commit: bf4959a9614b1a81295e24a7b0d30c527bc437b8
      https://github.com/zopefoundation/Acquisition/commit/bf4959a9614b1a81295e24a7b0d30c527bc437b8
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [capi|module]_aq_parent

* The usual tabs/spaces/indent stuff.
* Use METH_O for a function with a single argument.


  Commit: 02a90a34947c66b8e358b73f18e03519dd4a4281
      https://github.com/zopefoundation/Acquisition/commit/02a90a34947c66b8e358b73f18e03519dd4a4281
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [module|capi]_aq_self


  Commit: 6618e95c073c904312fb54a17b35d744251e2333
      https://github.com/zopefoundation/Acquisition/commit/6618e95c073c904312fb54a17b35d744251e2333
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [module|capi]_ac_inner

* The usual tabs/spaces/indent stuff.
* Make use of the fact that __new__ ensures that self->obj is never NULL


  Commit: acaee010e0e4778559b483f06fef4ad7f3efcef1
      https://github.com/zopefoundation/Acquisition/commit/acaee010e0e4778559b483f06fef4ad7f3efcef1
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [module|capi]_aq_chain

* Usual tabs/spaces/indent stuff
* Make use of the fact that __new__ ensures that self->obj is never NULL
* Fix memory leak when PyObject_GetAttr(self, py__parent__) raised
  something else then AttributeError. Before 'result' was leaking.
* The 'err:' section returned 'result' in case of erros. Due to the decref
  before 'result' became an invalid pointer. Returning this pointer
  would have let to a segfault. The proper way to signal an error is by
  returning a NULL pointer. As it is done now.
* Prevent segfault if the return value of
  PyObject_GetAttr(self, py__parent__) had an refcount of 1.
  In that case it Py_DECREF came too early and an access of this pointer
  later would have lead to segfault. Now the reference is kept alive
  until the end of the function. Yes this complicated the other
  assignments to self a bit.


  Commit: 12c446c2051d1be000e34467d612c297f93ec62f
      https://github.com/zopefoundation/Acquisition/commit/12c446c2051d1be000e34467d612c297f93ec62f
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Refactor [module|capi]_aq_inContextOf

* The usual tab/spaces/indent stuff.
* No checks for self->obj are needed, because __new__ ensures that its always set.
* Handle errors from capi_aq_inner and capi_aq_parent.
  Before the NULL pointer was used as a regular result,
  which would have lead to segfault.
* Don't decref the result from capi_aq_parent too early.
  Before the result of capi_aq_parent() was immediatly Py_DECREF and
  after that *used* ! This was a potential segfault in case the result
  of this had a refcount of 1.
  Now the refcount is decremented at the very end.


  Commit: 0b87f64a7039b5cc3a92f9aa1d3144912aef368c
      https://github.com/zopefoundation/Acquisition/commit/0b87f64a7039b5cc3a92f9aa1d3144912aef368c
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Ident with 4 instead of 2 spaces.


  Commit: f176d89cbfc1415682f50026cbddbfbecf699e0f
      https://github.com/zopefoundation/Acquisition/commit/f176d89cbfc1415682f50026cbddbfbecf699e0f
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Get rid of a few typedefs and defines.

Modern verions of python have them in their headers.


  Commit: 7f20484387eaf45abef5e433f3f165bbf3eed91d
      https://github.com/zopefoundation/Acquisition/commit/7f20484387eaf45abef5e433f3f165bbf3eed91d
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Python has an implementation for ASSIGN, lets use it.


  Commit: 1e2774c7ff770555ecb4f0ee0fa7c8b5dfa54a87
      https://github.com/zopefoundation/Acquisition/commit/1e2774c7ff770555ecb4f0ee0fa7c8b5dfa54a87
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Use get_base at other places.

New helper function get_inner.


  Commit: e2a1fa07dc0e10c8d90eef2510bc1aba22f1278c
      https://github.com/zopefoundation/Acquisition/commit/e2a1fa07dc0e10c8d90eef2510bc1aba22f1278c
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Use apply__of__ at other places.


  Commit: 50b527e1d25a2b1fd4f8cb05ce2b0cd5f091e422
      https://github.com/zopefoundation/Acquisition/commit/50b527e1d25a2b1fd4f8cb05ce2b0cd5f091e422
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M src/Acquisition/_Acquisition.c

  Log Message:
  -----------
  Use STR_EQ in Wrapper_special.


  Commit: e6e74d23b17ce94c1dc1121262e2077353a88157
      https://github.com/zopefoundation/Acquisition/commit/e6e74d23b17ce94c1dc1121262e2077353a88157
  Author: stephan-hof <sh at axiros.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M include/ExtensionClass/ExtensionClass.h

  Log Message:
  -----------
  Add the latest ExtensionClass.h


Compare: https://github.com/zopefoundation/Acquisition/compare/af4f0b3c6c5b...e6e74d23b17c


More information about the checkins mailing list