Commit Graph

351 Commits

Author SHA1 Message Date
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
Alexandre Vassalotti 865eaa1b53 Closes #17892: Fix the name of _PyObject_CallMethodObjIdArgs 2013-05-02 10:44:04 -07:00
Mark Dickinson 93196eb44f Issue #17715: Merge fix from 3.3. 2013-04-13 17:46:04 +01:00
Mark Dickinson c9734484ca Issue #17715: Add missing NULL Check to PyNumber_Long. 2013-04-13 17:44:44 +01:00
Serhiy Storchaka ee57f159af Revert a premature patch for issue #14010 (changeset 846bd418aee5). 2013-04-06 22:55:12 +03:00
Serhiy Storchaka 278d03bd66 Revert a premature patch for issue #14010 (changeset aaaf36026511). 2013-04-06 22:52:34 +03:00
Serhiy Storchaka aac81e2780 Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
2013-04-06 21:20:30 +03:00
Serhiy Storchaka e8f706eda7 Issue #14010: Fix a crash when iterating or deleting deeply nested filters
(builting and in itertools module, i.e. map(), itertools.chain(), etc).
2013-04-06 21:14:43 +03:00
Armin Ronacher 74b38b190f Issue #16148: Small improvements and cleanup. Added version information
to docs.
2012-10-07 10:29:32 +02:00
Christian Heimes b70e8a1958 and another one 2012-10-06 17:16:39 +02:00
Christian Heimes 6314d164c9 move var declaration to top of block to fix compilation on Windows, fixes a7ec0a1b0f7c 2012-10-06 17:13:29 +02:00
Armin Ronacher aa9a79d279 Issue #16148: implemented PEP 424 2012-10-06 14:03:24 +02:00
Mark Dickinson 3d7838593b Issue #16060: Fix a double DECREF in int() implementation. Thanks Serhiy Storchaka. 2012-09-27 19:38:59 +01:00
Stefan Krah 5b27c53e36 Merge 3.2. 2012-08-21 08:25:41 +02:00
Stefan Krah 7cacd2eb92 Issue #15736: Fix overflow in _PySequence_BytesToCharpArray(). 2012-08-21 08:16:09 +02:00
Stefan Krah 6adf2433e4 Merge 3.2. 2012-08-20 11:13:58 +02:00
Stefan Krah fd24f9e51e Issue #15732: Fix (constructed) crash in _PySequence_BytesToCharpArray().
Found by Coverity.
2012-08-20 11:04:24 +02:00
Stefan Krah 7d12d9df13 Issue #12834: Fix PyBuffer_ToContiguous() for non-contiguous arrays. 2012-07-28 12:25:55 +02:00
Brett Cannon fd0741555b Issue #2377: Make importlib the implementation of __import__().
importlib._bootstrap is now frozen into Python/importlib.h and stored
as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen
code along with sys and imp and then uses _frozen_importlib._install()
to set builtins.__import__() w/ _frozen_importlib.__import__().
2012-04-14 14:10:13 -04:00
Benjamin Peterson 520e8508a0 long() -> int() 2012-03-21 14:51:14 -04:00
Benjamin Peterson b7f1da5a3c make _PyNumber_ConvertIntegralToInt static, since it's only used in abstract.c 2012-03-21 14:44:43 -04:00
Benjamin Peterson d614e707ca rewrite this function, which was still accounting for classic classes 2012-03-21 14:38:11 -04:00
Benjamin Peterson 1b1a8e7cb5 correctly lookup __trunc__ in int() constructor 2012-03-20 23:48:11 -04:00
Benjamin Peterson 9fc9bf465a some more identifier goodness 2012-03-20 23:26:41 -04:00
Stefan Krah 4e14174e24 Whitespace. 2012-03-06 15:27:31 +01:00
Stefan Krah 9a2d99e28a - Issue #10181: New memoryview implementation fixes multiple ownership
and lifetime issues of dynamically allocated Py_buffer members (#9990)
  as well as crashes (#8305, #7433). Many new features have been added
  (See whatsnew/3.3), and the documentation has been updated extensively.
  The ndarray test object from _testbuffer.c implements all aspects of
  PEP-3118, so further development towards the complete implementation
  of the PEP can proceed in a test-driven manner.

  Thanks to Nick Coghlan, Antoine Pitrou and Pauli Virtanen for review
  and many ideas.

- Issue #12834: Fix incorrect results of memoryview.tobytes() for
  non-contiguous arrays.

- Issue #5231: Introduce memoryview.cast() method that allows changing
  format and shape without making a copy of the underlying memory.
2012-02-25 12:24:21 +01:00
Benjamin Peterson ce79852077 use the static identifier api for looking up special methods
I had to move the static identifier code from unicodeobject.h to object.h in
order for this to work.
2012-01-22 11:24:29 -05:00
Nick Coghlan 138f4656e3 Add a separate NEWS entry for a change to PyObject_CallMethod in the PEP 380 patch, and make the private CallMethod variants consistent with the public one 2012-01-14 16:45:48 +10:00
Nick Coghlan 1f7ce62bd6 Implement PEP 380 - 'yield from' (closes #11682) 2012-01-13 21:43:40 +10:00
Benjamin Peterson 2199227be4 fix weird indentation 2011-12-28 12:01:31 -06:00
Victor Stinner 9d3b93ba30 Use the new Unicode API
* Replace PyUnicode_FromUnicode(NULL, 0) by PyUnicode_New(0, 0)
 * Replce PyUnicode_FromUnicode(str, len) by PyUnicode_FromWideChar(str, len)
 * Replace Py_UNICODE by wchar_t
 * posix_putenv() uses PyUnicode_FromFormat() to create the string, instead
   of PyUnicode_FromUnicode() + _snwprintf()
2011-11-22 02:27:30 +01:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Martin v. Löwis afe55bba33 Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
2011-10-09 10:38:36 +02:00
Martin v. Löwis d63a3b8beb Implement PEP 393. 2011-09-28 07:41:54 +02:00
Brian Curtin dfc80e3d97 Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
The macro was introduced in #12724.
2011-08-10 20:28:54 -05:00
Victor Stinner f2a94216de Close #10616: mention bytes and bytearray in PyObject_AsCharBuffer() error
message
2011-05-30 23:21:30 +02:00
Victor Stinner 0a5f65ab0a Issue #7330, #10833: Replace %100s by %.100s and %200s by %.200s
I suppose that the author would like to truncate the type name, not get a
string of 100/200 characters.
2011-03-22 01:09:21 +01:00
Benjamin Peterson 72288d4f3c code style 2010-11-20 17:21:08 +00:00
R. David Murray 6bb9989ae3 #1574217: only swallow AttributeErrors in isinstance, not everything.
Patch and tests by Brian Harring, with improvements by Ralf Schmitt.
2010-11-20 16:33:30 +00:00
Benjamin Peterson 568867a6f2 check for NULL tp_as_mapping in PySequence_(Get/Set/Del)Slice #9834 2010-09-11 16:02:03 +00:00
Antoine Pitrou f68c2a701b Issue #3101: Helper functions _add_one_to_C() and _add_one_to_F() become
_Py_add_one_to_C() and _Py_add_one_to_F(), respectively.
2010-09-01 12:58:21 +00:00
Alexander Belopolsky f0f45142d5 Issue #2443: Added a new macro, Py_VA_COPY, which is equivalent to C99
va_copy, but available on all python platforms.  Untabified a few
unrelated files.
2010-08-11 17:31:17 +00:00
Benjamin Peterson e893af5ab7 update error message 2010-06-28 19:43:42 +00:00
Benjamin Peterson 6f889ad32f Merged revisions 81712 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81712 | benjamin.peterson | 2010-06-04 21:07:01 -0500 (Fri, 04 Jun 2010) | 1 line

  _PyObject_LookupSpecial returns a new reference
........
2010-06-05 02:11:45 +00:00
Benjamin Peterson da2cf04c28 Merged revisions 81706-81707 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81706 | benjamin.peterson | 2010-06-04 19:32:50 -0500 (Fri, 04 Jun 2010) | 1 line

  properly lookup the __format__ special method
........
  r81707 | benjamin.peterson | 2010-06-04 19:38:22 -0500 (Fri, 04 Jun 2010) | 1 line

  remove PyType_Ready call; float should be initialized in interpreter startup
........
2010-06-05 00:45:37 +00:00
Antoine Pitrou f95a1b3c53 Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
2010-05-09 15:52:27 +00:00
Gregory P. Smith 68f52178d9 * Fix the refcount leak in _PySequence_BytesToCharpArray from r78946.
* Also fixes a potential extra DECREF of an arg in the error case within
  _posixsubprocess.fork_exec() by not reusing the process_args variable.
2010-03-15 06:07:42 +00:00
Gregory P. Smith fb94c5f1e5 * Replaces the internals of the subprocess module from fork through exec on
POSIX systems with a C extension module.  This is required in order for
  the subprocess module to be made thread safe.

  The pure python implementation is retained so that it can continue to be
  used if for some reason the _posixsubprocess extension module is not
  available.

  The unittest executes tests on both code paths to guarantee compatibility.

* Moves PyLong_FromPid and PyLong_AsPid from posixmodule.c into longobject.h.

Code reviewed by jeffrey.yasskin at http://codereview.appspot.com/223077/show
2010-03-14 06:49:55 +00:00
Benjamin Peterson 8f326b2369 Merged revisions 76052,76522,76591,76689,76697,76733 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r76052 | gregory.p.smith | 2009-11-01 20:02:38 -0600 (Sun, 01 Nov 2009) | 5 lines

  see issue1006238, this merges in the following patch to ease cross
  compiling the printf %zd check.

   http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-lang/python/files/python-2.5-cross-printf.patch?rev=1.1&view=markup
........
  r76522 | barry.warsaw | 2009-11-25 12:38:32 -0600 (Wed, 25 Nov 2009) | 2 lines

  Add mktime_tz to __all__.  It's documented as being available in email.utils.
........
  r76591 | benjamin.peterson | 2009-11-29 16:26:26 -0600 (Sun, 29 Nov 2009) | 4 lines

  now that deepcopy can handle instance methods, this hack can be removed #7409

  Thanks Robert Collins
........
  r76689 | benjamin.peterson | 2009-12-06 11:37:48 -0600 (Sun, 06 Dec 2009) | 1 line

  rewrite translate_newlines for clarity
........
  r76697 | benjamin.peterson | 2009-12-06 15:24:30 -0600 (Sun, 06 Dec 2009) | 2 lines

  fix test_parser from tokenizer tweak
........
  r76733 | benjamin.peterson | 2009-12-09 21:37:59 -0600 (Wed, 09 Dec 2009) | 1 line

  substitute PyDict_Check() for PyObject_IsInstance
........
2009-12-13 02:10:36 +00:00
Georg Brandl 61b96dc2fe Slightly improve buffer-related error message. 2009-08-04 20:29:27 +00:00
Benjamin Peterson 94c65d9a8f Merged revisions 72907 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72907 | benjamin.peterson | 2009-05-24 21:40:21 -0500 (Sun, 24 May 2009) | 1 line

  handle errors from _PyObject_LookupSpecial when __get__ fails
........
2009-05-25 03:10:48 +00:00
Georg Brandl dcfe8e44c3 Remove unused variables. 2009-05-17 08:22:45 +00:00
Benjamin Peterson 88fe5f9776 Merged revisions 72690 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72690 | benjamin.peterson | 2009-05-16 16:44:25 -0500 (Sat, 16 May 2009) | 1 line

  properly lookup __instancecheck__ and __subclasscheck__
........
2009-05-16 21:55:24 +00:00
Benjamin Peterson b0ba27dff1 only need to catch an TypeError here 2009-05-09 19:30:46 +00:00
Benjamin Peterson e18df23d5d Merged revisions 72518 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72518 | benjamin.peterson | 2009-05-09 14:18:36 -0500 (Sat, 09 May 2009) | 1 line

  clear error state properly
........
2009-05-09 19:24:36 +00:00
Benjamin Peterson a5758c0120 Merged revisions 72508 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72508 | benjamin.peterson | 2009-05-09 11:36:39 -0500 (Sat, 09 May 2009) | 1 line

  convert some more special methods to use _PyObject_LookupSpecial
........
2009-05-09 18:15:04 +00:00
Georg Brandl 0192bffe90 Merged revisions 71607,71653,71696,71771,71786 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71607 | benjamin.peterson | 2009-04-14 23:23:09 +0200 (Di, 14 Apr 2009) | 1 line

  tupel -> tuple
........
  r71653 | raymond.hettinger | 2009-04-16 20:16:10 +0200 (Do, 16 Apr 2009) | 1 line

  Clarify the behavior of any() and all() with an empty iterable.
........
  r71696 | georg.brandl | 2009-04-18 10:26:21 +0200 (Sa, 18 Apr 2009) | 1 line

  "not subscriptable" should be a bit more understandable than "unsubscriptable".
........
  r71771 | raymond.hettinger | 2009-04-20 20:23:57 +0200 (Mo, 20 Apr 2009) | 1 line

  Fix typo
........
  r71786 | georg.brandl | 2009-04-21 20:23:08 +0200 (Di, 21 Apr 2009) | 1 line

  #5757: fix copy-paste error in notify().
........
2009-04-27 16:49:41 +00:00
Mark Dickinson 934896dc09 Merged revisions 69846 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69846 | mark.dickinson | 2009-02-21 20:27:01 +0000 (Sat, 21 Feb 2009) | 2 lines

  Issue #5341: Fix a variety of spelling errors.
........
2009-02-21 20:59:32 +00:00
Raymond Hettinger 5d65412d35 Validate that __length_hint__ returns a usable result. 2009-02-03 02:12:10 +00:00
Raymond Hettinger e8364233ae Issue 1242657: list(obj) can swallow KeyboardInterrupt. 2009-02-02 22:55:09 +00:00
Mark Dickinson f02e0aaafd Issue #1717: remove the cmp builtin function, the C-API functions
PyObject_Cmp, PyObject_Compare, and various support functions.
2009-02-01 12:13:56 +00:00
Amaury Forgeot d'Arc f343e01c17 Merged revisions 68560 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68560 | amaury.forgeotdarc | 2009-01-13 00:36:55 +0100 (mar., 13 janv. 2009) | 6 lines

  #3720: Interpreter crashes when an evil iterator removes its own next function.

  Now the slot is filled with a function that always raises.

  Will not backport: extensions compiled with 2.6.x would not run on 2.6.0.
........
2009-01-12 23:58:21 +00:00
Mark Dickinson e5e298f875 Issue #4910 (1st patch of a series): fix int() and the corresponding
PyNumber_Int/PyNumber_Long API function so that it no longer attempts
to call the __long__ method for conversion.  Only the __int__ and __trunc__
methods are used.  (This removes a major remaining use of the nb_long
slot from the Python 3.x core.)

Thanks Benjamin for review.
2009-01-12 20:49:19 +00:00
Benjamin Peterson 60320cb3e4 #3946 fix PyObject_CheckBuffer on a memoryview object
reviewed by Antoine
2008-09-26 21:49:22 +00:00
Benjamin Peterson 9edd2bd35c Fix #3651 various memory leaks when using the buffer interface
by Amaury Forgeot d'Arc
Reviewer: Antoine Pitrou
2008-08-27 00:31:37 +00:00
Antoine Pitrou ec569b7947 Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
mechanism. In the process, fix a bug where isinstance() and issubclass(),
when given a tuple of classes as second argument, were looking up
__instancecheck__ / __subclasscheck__ on the tuple rather than on each
type object.

Reviewed by Benjamin Peterson and Raymond Hettinger.
2008-08-26 22:40:48 +00:00