Commit Graph

316 Commits

Author SHA1 Message Date
Victor Stinner 64faad6e45 Cleanup call_function_tail()
Make call_function_tail() less weird: don't decrement args reference counter,
the caller is now responsible to do that. The caller now also checks if args is
NULL.

Issue #27128.
2016-08-19 16:50:49 +02:00
Victor Stinner 8880708f81 call_function_tail() uses fast call
Issue #27128: Modify call_function_tail() to use _PyObject_FastCall() when args
is not a tuple to avoid the creation of a temporary tuple.

call_function_tail() is used by:

* PyObject_CallFunction()
* PyObject_CallMethod()
* _PyObject_CallMethodId()
2016-08-19 16:44:19 +02:00
Victor Stinner 9be7e7b52f Add _PyObject_FastCall()
Issue #27128: Add _PyObject_FastCall(), a new calling convention avoiding a
temporary tuple to pass positional parameters in most cases, but create a
temporary tuple if needed (ex: for the tp_call slot).

The API is prepared to support keyword parameters, but the full implementation
will come later (_PyFunction_FastCall() doesn't support keyword parameters
yet).

Add also:

* _PyStack_AsTuple() helper function: convert a "stack" of parameters to
  a tuple.
* _PyCFunction_FastCall(): fast call implementation for C functions
* _PyFunction_FastCall(): fast call implementation for Python functions
2016-08-19 16:11:43 +02:00
Martin Panter 32d2ce3561 Issue #27581: Merge overflow fix from 3.5 2016-07-25 03:31:29 +00:00
Martin Panter e8db861f47 Issue #27581: Don’t rely on overflow wrapping in PySequence_Tuple()
Patch by Xiang Zhang.
2016-07-25 02:30:05 +00:00
Martin Panter 590dcab95a Merge spelling fixes from 3.5 2016-06-20 07:55:14 +00:00
Martin Panter 2275e626b1 Fix spelling errors in code comments 2016-06-20 07:52:50 +00:00
Serhiy Storchaka 5697c4b641 Comment fixes extracted from patch by Demur Rumed. 2016-06-12 17:02:10 +03:00
Serhiy Storchaka 16931c3559 Issue #26983: float() now always return an instance of exact float.
The deprecation warning is emitted if __float__ returns an instance of
a strict subclass of float.  In a future versions of Python this can
be an error.
2016-06-03 21:42:55 +03:00
Martin Panter 9513ba3b8f Issue #24802: Merge null termination fixes from 3.5 2015-11-07 03:15:32 +00:00
Martin Panter 61d6e4ae9d Issue #24802: Merge null termination fixes from 3.4 into 3.5 2015-11-07 02:56:11 +00:00
Martin Panter eeb896c411 Issue #24802: Copy bytes-like objects to null-terminated buffers if necessary
This avoids possible buffer overreads when int(), float(), compile(), exec()
and eval() are passed bytes-like objects. Similar code is removed from the
complex() constructor, where it was not reachable.

Patch by John Leitch, Serhiy Storchaka and Martin Panter.
2015-11-07 02:32:21 +00:00
Victor Stinner e20310fa19 Issue #25556: Add assertions to PyObject_GetItem() to ensure that an exception
is raised when it returns NULL.

Simplify also ceval.c: rely on the fact that PyObject_GetItem() raised an
exception when it returns NULL.
2015-11-05 13:56:58 +01:00
Martin Panter 2eb819f7a8 Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5 2015-11-02 04:04:57 +00:00
Martin Panter 7462b64911 Issue #25523: Correct "a" article to "an" article
This changes the main documentation, doc strings, source code comments, and a
couple error messages in the test suite. In some cases the word was removed
or edited some other way to fix the grammar.
2015-11-02 03:37:02 +00:00
Martin Panter ec1aa5c2a1 More typos in 3.5 documentation and comments 2015-10-07 11:03:53 +00:00
Raymond Hettinger 740d6134f1 merge 2015-05-17 14:47:00 -07:00
Raymond Hettinger 610a51f364 Issue #23757: Only call the concrete list API for exact lists. 2015-05-17 14:45:58 -07:00
Victor Stinner 944fbcc478 Issue #23571: Enhance _Py_CheckFunctionResult()
Too bad, sometimes Py_FatalError() is unable to write the exception into
sys.stderr (on "AMD64 OpenIndiana 3.x" buildbot, the buildbot was probably out
of memory).

Call Py_FatalError() with a different message for the two cases (result+error,
or no result and no error).
2015-03-24 16:28:52 +01:00
Victor Stinner 3b06dfb9d1 Issue #23571: In debug mode, _Py_CheckFunctionResult() now calls
Py_FatalError() instead of using an assertion in debug mode. Py_FatalError()
displays the current exception and the traceback which contain more information
than just the assertion error.
2015-03-24 12:53:59 +01:00
Victor Stinner efde146b0c Issue #23571: _Py_CheckFunctionResult() now gives the name of the function
which returned an invalid result (result+error or no result without error) in
the exception message.

Add also unit test to check that the exception contains the name of the
function.

Special case: the final _PyEval_EvalFrameEx() check doesn't mention the
function since it didn't execute a single function but a whole frame.
2015-03-21 15:04:43 +01:00
Victor Stinner 283f3f8ab3 Issue #23571: Oops, fix #ifdef assert()
assert() are noop when NDEBUG is defined. We want the opposite.
2015-03-09 15:55:37 +01:00
Victor Stinner 4a7cc88472 Issue #23571: PyObject_Call(), PyCFunction_Call() and call_function() now
raise a SystemError if a function returns a result and raises an exception.
The SystemError is chained to the previous exception.

Refactor also PyObject_Call() and PyCFunction_Call() to make them more readable.

Remove some checks which became useless (duplicate checks).

Change reviewed by Serhiy Storchaka.
2015-03-06 23:35:27 +01:00
Stefan Krah 5178d91be0 Issue #14203: Remove obsolete support for view==NULL in PyBuffer_FillInfo()
and bytearray_getbuffer().  Both functions now raise BufferError in that
case.
2015-02-03 16:57:21 +01:00
Serhiy Storchaka 3dd3e26680 Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
and PyObject_AsWriteBuffer().
2015-02-03 01:25:42 +02:00
Serhiy Storchaka 4fdb68491e Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
and PyObject_AsWriteBuffer().
2015-02-03 01:21:08 +02:00
Stefan Krah 2e6658b4a7 Merge from 3.4. 2015-02-01 19:19:49 +01:00
Stefan Krah 7213fcc27e Issue #23370: Fix off-by-one error for non-contiguous buffers. 2015-02-01 16:19:23 +01:00
Stefan Krah 363af44a4a Issue #22445: PyBuffer_IsContiguous() now implements precise contiguity
tests, compatible with NumPy's NPY_RELAXED_STRIDES_CHECKING compilation
flag.  Previously the function reported false negatives for corner cases.
2015-02-01 14:53:54 +01:00
Ethan Furman b95b56150f Issue20284: Implement PEP461 2015-01-23 20:05:18 -08:00
R David Murray 861470c836 #16518: Bring error messages in harmony with docs ("bytes-like object")
Some time ago we changed the docs to consistently use the term 'bytes-like
object' in all the contexts where bytes, bytearray, memoryview, etc are used.
This patch (by Ezio Melotti) completes that work by changing the error
messages that previously reported that certain types did "not support the
buffer interface" to instead say that a bytes-like object is required.  (The
glossary entry for bytes-like object references the discussion of the buffer
protocol in the docs.)
2014-10-05 11:47:01 -04:00
Georg Brandl 72b8a80e59 Closes #22540: speed up PyObject_IsInstance and PyObject_IsSubclass in the common case that the second argument has metaclass "type". 2014-10-03 09:26:37 +02:00
Victor Stinner 8f4ec8d3ef Issue #22290: PyObject_Call() now fails with an assertion error when called
with an exception set. This new assertion helps to understand if the exception
was already set before calling the function or raised by the function.
2014-09-05 01:10:29 +02:00
Benjamin Peterson 3cbae68de6 merge 3.4 2014-06-26 23:29:19 -07:00
Benjamin Peterson 1791c224dd use NULL not 0 2014-06-26 23:29:13 -07:00
Benjamin Peterson d51374ed78 PEP 465: a dedicated infix operator for matrix multiplication (closes #21176) 2014-04-09 23:55:56 -04:00
Victor Stinner 4ac9c00cff Better assertion in PyObject_Call() to detect functions returning a result with
an exception set (invalid state).
2013-12-19 13:47:35 +01:00
Serhiy Storchaka c4f3212abc Issue #17576: Deprecation warning emitted now when __int__() or __index__()
return not int instance.  Introduced _PyLong_FromNbInt() and refactored
PyLong_As*() functions.
2013-12-11 21:26:36 +02:00
Serhiy Storchaka 31a655411a Issue #17576: Deprecation warning emitted now when __int__() or __index__()
return not int instance.  Introduced _PyLong_FromNbInt() and refactored
PyLong_As*() functions.
2013-12-11 21:07:54 +02:00
Victor Stinner 0b0c867178 Issue #19437: Fix PyObject_CallFunction(), handle Py_VaBuildValue() and
PyTuple_New() failure
2013-10-29 19:29:52 +01:00
Serhiy Storchaka f740d467bf Issue #19369: Optimized the usage of __length_hint__(). 2013-10-24 23:19:51 +03:00
Serhiy Storchaka c679227e31 Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
Serhiy Storchaka 46e1ce214b Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 20:17:03 +03:00
Serhiy Storchaka 9594942716 Issue #18783: Removed existing mentions of Python long type in docstrings,
error messages and comments.
2013-08-27 19:40:23 +03:00
Serhiy Storchaka 579ddc2fd4 Issue #16741: Fix an error reporting in int(). 2013-08-03 21:14:05 +03:00
Serhiy Storchaka f6d0aeeadc Issue #16741: Fix an error reporting in int(). 2013-08-03 20:55:06 +03:00
Victor Stinner f243ee4055 Issue #18408: add more assertions on PyErr_Occurred() in ceval.c to detect bugs
earlier
2013-07-16 01:02:12 +02:00
Victor Stinner 3de5869864 Issue #18408: PyObject_Call() now fails with an assertion error in debug mode
if the function called failed whereas no exception was raised, to detect bugs
earlier.
2013-07-15 17:50:07 +02:00
Victor Stinner 0e2d3cf2cb Issue #18203: Replace malloc() with PyMem_Malloc() in _PySequence_BytesToCharpArray() 2013-07-07 17:22:41 +02:00
Serhiy Storchaka 1cfebc73e0 Issue #9369: The types of `char*` arguments of PyObject_CallFunction() and
PyObject_CallMethod() now changed to `const char*`.
Based on patches by Jörg Müller and Lars Buitinck.
2013-05-29 18:50:54 +03:00