A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-April/144361.html below:

[Python-Dev] Inconsistency of PyModule_AddObject()

[Python-Dev] Inconsistency of PyModule_AddObject()Hrvoje Niksic hrvoje.niksic at avl.com
Wed Apr 27 08:31:37 EDT 2016
On 04/27/2016 09:14 AM, Serhiy Storchaka wrote:
> There are three functions (or at least three documented functions) in C
> API that "steals" references: PyList_SetItem(), PyTuple_SetItem() and
> PyModule_AddObject(). The first two "steals" references even on failure,
> and this is well known behaviour. But PyModule_AddObject() "steals" a
> reference only on success. There is nothing in the documentation that
> points on this.

This inconsistency has caused bugs (or, more fairly, potential leaks) 
before, see http://bugs.python.org/issue1782

Unfortunately, the suggested Python 3 change to PyModule_AddObject was 
not accepted.

> 1. Add a new function PyModule_AddObject2(), that steals a reference
> even on failure.

This sounds like a good idea, except the name could be prettier :), e.g. 
PyModule_InsertObject. PyModule_AddObject could be deprecated.

Hrvoje

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4