Commit Graph

685 Commits

Author SHA1 Message Date
Nick Coghlan 944368e1cc Issue #23722: Initialize __class__ from type.__new__()
The __class__ cell used by zero-argument super() is now initialized
from type.__new__ rather than __build_class__, so class methods
relying on that will now work correctly when called from metaclass
methods during class creation.

Patch by Martin Teichmann.
2016-09-11 14:45:49 +10:00
Serhiy Storchaka 7c19affdce Issue #25856: The __module__ attribute of extension classes and functions
now is interned. This leads to more compact pickle data with protocol 4.
2016-09-10 00:53:02 +03:00
Benjamin Peterson 6cb526e54d remove unconvincing use of Py_LOCAL 2016-09-09 12:42:51 -07:00
Eric Snow 4f29e75289 Issue #24254: Drop cls.__definition_order__. 2016-09-08 15:11:11 -07:00
Christian Heimes 07a2a1b7e5 Additional safe-guard against dereferencing NULL in reduce_newobj
_PyObject_GetNewArguments() can leave args == NULL but the __newobj_ex__
branch expects args to be not-NULL.

CID 1353201
2016-09-09 00:21:22 +02:00
Victor Stinner ad8c83ad6b Avoid inefficient way to call functions without argument
Don't pass "()" format to PyObject_CallXXX() to call a function without
argument: pass NULL as the format string instead. It avoids to have to parse a
string to produce 0 argument.
2016-09-05 17:53:15 -07:00
Eric Snow 92a6c170e6 Issue #24254: Preserve class attribute definition order. 2016-09-05 14:50:11 -07:00
Raymond Hettinger 15f44ab043 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-08-30 10:47:49 -07:00
Victor Stinner 3f1057a4b6 method_call() and slot_tp_new() now uses fast call
Issue #27841: Add _PyObject_Call_Prepend() helper function to prepend an
argument to existing arguments to call a function. This helper uses fast calls.

Modify method_call() and slot_tp_new() to use _PyObject_Call_Prepend().
2016-08-25 01:04:14 +02:00
Victor Stinner 463b86a881 Issue #27809: Use _PyObject_FastCallDict()
Modify:

* init_subclass()
* builtin___build_class__()

Fix also a bug in init_subclass(): check for super() failure.
2016-08-22 23:33:13 +02:00
Victor Stinner 559bb6a713 Rename _PyObject_FastCall() to _PyObject_FastCallDict()
Issue #27809:

* Rename _PyObject_FastCall() function to _PyObject_FastCallDict()
* Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1()
  macros calling _PyObject_FastCallDict()
2016-08-22 22:48:54 +02:00
Victor Stinner 253021dd94 Issue #27366: Fix init_subclass()
Handle PyTuple_New(0) failure.
2016-08-20 02:37:41 +02:00
Victor Stinner 6911267615 slot_tp_iter() now uses fast call
Issue #27128: slot_tp_iter() now calls _PyObject_FastCall() to avoid a
temporary empty tuple.
2016-08-19 18:41:02 +02:00
Victor Stinner 20a3007a8d slot_nb_bool() now uses fast call
Issue #27128: slot_nb_bool() now calls _PyObject_FastCall() to avoid a
temporary empty tuple to call the slot function.
2016-08-19 18:28:25 +02:00
Victor Stinner a12eec48b6 Issue #27128: Cleanup slot_nb_bool()
Use an error label to reduce the level of indentation.
2016-08-19 18:26:05 +02:00
Victor Stinner 5e87749a8e Issue #27128: slot_sq_item() uses fast call
slot_sq_item() now calls _PyObject_FastCall() to avoid the creation of a
temporary tuple of 1 item to pass the 'item' argument to the slot function.
2016-08-19 18:19:42 +02:00
Victor Stinner 018016d8e3 Issue #27128: Cleanup slot_sq_item()
* Invert condition of test to avoid levels of indentation
* Remove useless Py_XDECREF(args) in the error block
* Replace Py_XDECREF(func) with Py_DECREF(func) in the error block: func cannot
  be NULL when reaching the error block
2016-08-19 18:17:37 +02:00
Victor Stinner f736c261a2 call_method() and call_maybe() now use fast call
Issue #27128. The call_method() and call_maybe() functions of typeobject.c now
use fast call for empty format string to avoid the creation of a temporary
empty tuple.
2016-08-19 18:05:37 +02:00
Victor Stinner 94463c980e Cleanup call_method() and call_maybe()
Issue #27128. Move va_start/va_end around Py_VaBuildValue().
2016-08-19 18:01:41 +02:00
Victor Stinner 56142c701b Merge 3.5 (fix refleak in call_maybe()) 2016-08-19 17:58:30 +02:00
Victor Stinner 6902ddf2ca Fix a refleak in call_maybe()
Issue #27128. Fix a reference leak if creating the tuple to pass positional
parameters fails.
2016-08-19 17:58:12 +02:00
Victor Stinner 59e9ca6bda Merge 3.5 (fix refleak in call_method) 2016-08-19 17:52:08 +02:00
Victor Stinner d925bd5794 Fix a refleak in call_method()
Issue #27128. Fix a reference leak if creating the tuple to pass positional
parameters fails.
2016-08-19 17:51:49 +02:00
Victor Stinner a7720f61aa contains and rich compare slots use fast call
Issue #27128. Modify slot_sq_contains() and slot_tp_richcompare() to use fast
call to avoid a temporary tuple to pass a single positional parameter.
2016-08-19 17:48:51 +02:00
Berker Peksag 3f015a64b8 Issue #27157: Make only type() itself accept the one-argument form
Patch by Eryk Sun and Emanuel Barry.
2016-08-19 11:04:07 +03:00
Guido van Rossum 97c1adf393 Anti-registration of various ABC methods.
- Issue #25958: Support "anti-registration" of special methods from
  various ABCs, like __hash__, __iter__ or __len__.  All these (and
  several more) can be set to None in an implementation class and the
  behavior will be as if the method is not defined at all.
  (Previously, this mechanism existed only for __hash__, to make
  mutable classes unhashable.)  Code contributed by Andrew Barnert and
  Ivan Levkivskyi.
2016-08-18 09:22:23 -07:00
Martin Panter 02b75abf73 Merge spelling and grammar fixes from 3.5 2016-08-05 01:51:39 +00:00
Martin Panter 69332c1a64 Fix spelling and grammar in documentation and code comments 2016-08-04 13:07:31 +00:00
Berker Peksag 01d1719062 Issue #27366: Tweak PEP 487 documentation
* Added versionadded directives
* Deleted duplicate sentence from __init_subclass__ docstring
* Modernized tests
2016-07-30 14:06:15 +03:00
Nick Coghlan d78448e912 Issue #27366: Implement PEP 487
- __init_subclass__ called when new subclasses defined
- __set_name__ called when descriptors are part of a
  class definition
2016-07-30 16:26:03 +10:00
Benjamin Peterson ab078e9ed1 Backed out changeset af29d89083b3 (closes #25548) (closes #27498) 2016-07-13 21:13:29 -07:00
Benjamin Peterson c13d85bf8d merge 3.5 (#27248)
Patch from Xiang Zhang.
2016-07-06 23:28:19 -07:00
Benjamin Peterson 27007dccec fix refleaks in PyDict_SetItem error cases (closes #27248) 2016-07-06 23:26:32 -07:00
Serhiy Storchaka 841de28035 Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.
Patch by Xiang Zhang.
2016-06-05 10:50:16 +03:00
Serhiy Storchaka 484c913ed9 Issue #27225: Fixed a reference leak in type_new when setting __new__ fails.
Patch by Xiang Zhang.
2016-06-05 10:48:36 +03:00
Kushal Das 5801ecb440 Issue #25548: Showing memory address of class objects in repl 2016-06-04 16:21:13 -07:00
Benjamin Peterson 6ca4260219 merge 3.5 2016-05-28 14:05:11 -07:00
Benjamin Peterson c352620c92 backout 3c9512d8ac0d 2016-05-28 14:04:40 -07:00
Serhiy Storchaka 27ba8864a4 Issue #27118: Clean up Py_XINCREF/Py_XDECREF in typeobject.c.
Patch by Xiang Zhang.
2016-05-25 16:14:55 +03:00
Berker Peksag 0ac70c0e90 Fix typos. Reported by andportnoy on GitHub. 2016-04-29 16:54:10 +03:00
Martin Panter abe4d52a1a Merge doc and comment fixes from 3.5 2016-04-19 23:23:16 +00:00
Martin Panter 8f26565ba9 Fix spelling (inital), grammar (may translates) in documentation, comments 2016-04-19 04:03:41 +00:00
Serhiy Storchaka 131b8f8eee Issue #26718: super.__init__ no longer leaks memory if called multiple times.
NOTE: A direct call of super.__init__ is not endorsed!
2016-04-13 15:28:53 +03:00
Serhiy Storchaka 3d7497608b Issue #26718: super.__init__ no longer leaks memory if called multiple times.
NOTE: A direct call of super.__init__ is not endorsed!
2016-04-13 15:27:33 +03:00
Serhiy Storchaka f01e408c16 Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
in places where Py_DECREF was used.
2016-04-10 18:12:01 +03:00
Serhiy Storchaka 57a01d3a0e Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
in places where Py_DECREF was used.
2016-04-10 18:05:40 +03:00
Serhiy Storchaka ec39756960 Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:50:03 +03:00
Serhiy Storchaka 48842714b9 Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:45:48 +03:00
Benjamin Peterson 2c028492d4 merge 3.5 (#25731) 2016-01-18 21:18:35 -08:00
Benjamin Peterson 9ad11544bf set tp_new from the class in the hierarchy that actually owns the descriptor (closes #25731)
Debugging by Eryk Sun.
2016-01-18 21:11:18 -08:00