Commit Graph

191 Commits

Author SHA1 Message Date
Serhiy Storchaka 9e373be1bc Issue #28410: Keep the traceback of original exception in _PyErr_ChainExceptions(). 2016-10-21 16:19:59 +03:00
Berker Peksag ec766d3c15 Issue #23960: Cleanup args and kwargs on error in PyErr_SetImportError
Patch by Ofer Schwarz.
2016-05-01 09:06:36 +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 48842714b9 Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:45:48 +03:00
Martin Panter 3263f6874a Issue #22836: Keep exception reports sensible despite errors 2016-02-28 03:16:11 +00:00
Victor Stinner bfd316e750 Add _PyThreadState_UncheckedGet()
Issue #26154: Add a new private _PyThreadState_UncheckedGet() function which
gets the current thread state, but don't call Py_FatalError() if it is NULL.

Python 3.5.1 removed the _PyThreadState_Current symbol from the Python C API to
no more expose complex and private atomic types. Atomic types depends on the
compiler or can even depend on compiler options. The new function
_PyThreadState_UncheckedGet() allows to get the variable value without having
to care of the exact implementation of atomic types.

Changes:

* Replace direct usage of the _PyThreadState_Current variable with a call to
  _PyThreadState_UncheckedGet().
* In pystate.c, replace direct usage of the _PyThreadState_Current variable
  with the PyThreadState_GET() macro for readability.
* Document also PyThreadState_Get() in pystate.h
2016-01-20 11:12:38 +01:00
Serhiy Storchaka 191321d11b Issue #20440: More use of Py_SETREF.
This patch is manually crafted and contains changes that couldn't be handled
automatically.
2015-12-27 15:41:34 +02:00
Yury Selivanov f488fb422a Issue #19235: Add new RecursionError exception. Patch by Georg Brandl. 2015-07-03 01:04:23 -04:00
Serhiy Storchaka 1399a01b90 Issue #22977: Fixed formatting Windows error messages on Wine.
Patch by Martin Panter.
2015-04-02 09:50:06 +03:00
Serhiy Storchaka f41f8f9974 Issue #22977: Fixed formatting Windows error messages on Wine.
Patch by Martin Panter.
2015-04-02 09:47:27 +03:00
Victor Stinner de821befd4 Issue #23571: PyErr_FormatV() and PyErr_SetObject() now always clear the
current exception because they can run arbitrary Python code and so no
exception must be set.
2015-03-24 12:41:23 +01:00
Victor Stinner e42ccd2bfd Issue #23694: Enhance _Py_fopen(), it now raises an exception on error
* If fopen() fails, OSError is raised with the original filename object.
* The GIL is now released while calling fopen()
2015-03-18 01:39:23 +01:00
Serhiy Storchaka 78184af9b5 Issue #21715: Extracted shared complicated code in the _io module to new
_PyErr_ChainExceptions() function.
2014-10-08 22:32:50 +03:00
Serhiy Storchaka e2bd2a7186 Issue #21715: Extracted shared complicated code in the _io module to new
_PyErr_ChainExceptions() function.
2014-10-08 22:31:52 +03:00
Antoine Pitrou 0676a406bf Issue #18711: Add a new `PyErr_FormatV` function, similar to `PyErr_Format` but accepting a `va_list` argument. 2014-09-30 21:16:27 +02:00
Larry Hastings 8f9f0f12e8 Issue #20517: Removed unnecessary new (short-lived) functions from PyErr. 2014-02-10 03:43:57 -08:00
Larry Hastings b082731fbb Issue #20517: Functions in the os module that accept two filenames
now register both filenames in the exception on failure.
This required adding new C API functions allowing OSError exceptions
to reference two filenames instead of one.
2014-02-09 22:05:19 -08:00
Victor Stinner bd303c165b Issue #19512, #19515: remove shared identifiers, move identifiers where they
are used.

Move also _Py_IDENTIFIER() defintions to the top in modified files to remove
identifiers duplicated in the same file.
2013-11-07 23:07:29 +01:00
Victor Stinner ad14ccd047 Issue #19512: add _PyUnicode_CompareWithId() function
_PyUnicode_CompareWithId() is faster than PyUnicode_CompareWithASCIIString()
when both strings are equal and interned.

Add also _PyId_builtins identifier for "builtins" common string.
2013-11-07 00:46:04 +01:00
Victor Stinner 090543736f Issue #19512: add some common identifiers to only create common strings once,
instead of creating temporary Unicode string objects

Add also more identifiers in pythonrun.c to avoid temporary Unicode string
objets for the interactive interpreter.
2013-11-06 22:41:44 +01:00
Antoine Pitrou 409b53840b Don't export internal symbols ("make smelly") 2013-10-12 22:41:17 +02:00
Raymond Hettinger 69492dab07 Factor-out the common code for setting a KeyError. 2013-09-02 15:59:26 -07:00
Victor Stinner daf455554b Issue #18571: Implementation of the PEP 446: file descriptors and file handles
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
2013-08-28 00:53:59 +02:00
Victor Stinner 14e461d5b9 Close #11619: The parser and the import machinery do not encode Unicode
filenames anymore on Windows.
2013-08-26 22:28:21 +02:00
Victor Stinner c82bfd871f Issue #18664, #18408: Rewrite PyErr_WriteUnraisable() to handle errors
* Catch PyFile_WriteString() and PyFile_WriteObject() errors
 * Clear the current exception on _PyObject_GetAttrId() failure
 * Use PyUnicode_CompareWithASCIIString() and PyFile_WriteObject() instead of
   _PyUnicode_AsString() and strcmp() to avoid Unicode encoding error. stderr
   has a more tolerant error handler than utf-8/strict.
2013-08-26 14:04:10 +02:00
Victor Stinner f54a574478 Issue #18520: PyErr_NoMemory() now fails with a fatal error if it is called
before PyExc_MemoryError has been initialized by _PyExc_Init()
2013-07-22 22:28:37 +02:00
Victor Stinner ace47d7efd Issue #18408: PyEval_EvalFrameEx() and PyEval_CallObjectWithKeywords() now fail
with an assertion error if they are called with an exception set
(PyErr_Occurred()).

If these functions are called with an exception set, the exception may be
cleared and so the caller looses its exception.

Add also assertions to PyEval_CallObjectWithKeywords() and call_function() to
check if the function succeed with no exception set, or the function failed
with an exception set.
2013-07-18 01:41:08 +02:00
Victor Stinner 479054bca7 Issue #18408: Fix PyErr_SetImportError(), handle PyDict_SetItemString() failure 2013-07-17 21:54:25 +02:00
Victor Stinner 74a7fa6663 Issue #18408: Fix PyErr_NormalizeException(), handle PyObject_IsSubclass() failure
PyObject_IsSubclass() can fail and raise a new exception!
2013-07-17 00:44:53 +02:00
Victor Stinner fb3a630001 Issue #18408: errors.c: in debug mode, calling PyErr_BadInternalCall() now
fails with an assertion error
2013-07-12 00:37:30 +02:00
Brett Cannon 82da8886cc Issue #15767: Revert 3a50025f1900 for ModuleNotFoundError 2013-07-04 17:48:16 -04:00
Brett Cannon 8f5ac5106e Issue #15767: Touch up ModuleNotFoundError usage by import.
Forgot to raise ModuleNotFoundError when None is found in sys.modules.
This led to introducing the C function PyErr_SetImportErrorSubclass()
to make setting ModuleNotFoundError easier.

Also updated the reference docs to mention ModuleNotFoundError
appropriately. Updated the docs for ModuleNotFoundError to mention the
None in sys.modules case.

Lastly, it was noticed that PyErr_SetImportError() was not setting an
exception when returning None in one case. That issue is now fixed.
2013-06-12 23:29:18 -04:00
Andrew Svetlov 2606a6f197 Issue #16719: Get rid of WindowsError. Use OSError instead
Patch by Serhiy Storchaka.
2012-12-19 14:33:35 +02:00
Andrew Svetlov 76bcff27b2 Issue #7317: Display full tracebacks when an error occurs asynchronously.
Patch by Alon Horev with update by Alexey Kachayev.
2012-11-03 15:56:05 +02:00
Martin v. Löwis aa2efcb0bc Issue #14098: New functions PyErr_GetExcInfo and PyErr_SetExcInfo.
Patch by Stefan Behnel.
2012-04-19 14:33:43 +02:00
Antoine Pitrou ec9bac4226 Fix it for good :-) 2012-04-18 16:57:54 +02:00
Benjamin Peterson da20cd2b6b fix refcnt/style/debuging oversights 2012-04-18 10:48:00 -04:00
Brian Curtin 94c001b503 Fix email post-commit review comments.
Add INCREFs, fix args->kwargs, and a second args==NULL check was removed,
left over from a merger with another function. Instead, checking msg==NULL
does what that used to do in a roundabout way.
2012-04-18 08:30:51 -05:00
Brian Curtin 09b86d1196 Fix #14600. Correct reference handling and naming of ImportError convenience function 2012-04-17 16:57:09 -05:00
Brett Cannon 79ec55e980 Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Currently import does not use these attributes as they are planned
for use by importlib (which will be another commit).

Thanks to Filip Gruszczyński for the initial patch and Brian Curtin
for refining it.
2012-04-12 20:24:54 -04:00
Victor Stinner 1b57967b96 Issue #13560: Locale codec functions use the classic "errors" parameter,
instead of surrogateescape

So it would be possible to support more error handlers later.
2011-12-17 05:47:23 +01:00
Victor Stinner 1f33f2b0c3 Issue #13560: os.strerror() now uses the current locale encoding instead of UTF-8 2011-12-17 04:45:09 +01:00
Florent Xicluna aa6c1d240f Issue #13575: there is only one class type. 2011-12-12 18:54:29 +01:00
Victor Stinner 9ea8e4c29d Instantiate the OS-related exception as soon as we raise it, so that "except"
works properly.

PyErr_SetFromErrnoWithFilenameObject() was already fixed by the changeset
793c75177d28. This commit fixes PyErr_SetExcFromWindowsErrWithFilenameObject(),
used on Windows.
2011-10-17 20:18:58 +02:00
Martin v. Löwis 1c67dd9b15 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId. 2011-10-14 15:16:45 +02:00
Martin v. Löwis bd928fef42 Rename _Py_identifier to _Py_IDENTIFIER. 2011-10-14 10:20:37 +02:00
Antoine Pitrou 5d6fbe8207 Instantiate the OS-related exception as soon as we raise it, so that
"except" works properly.
2011-10-12 19:39:57 +02:00
Antoine Pitrou 6b4883dec0 PEP 3151 / issue #12555: reworking the OS and IO exception hierarchy. 2011-10-12 02:54:14 +02:00
Martin v. Löwis 1ee1b6fe0d Use identifier API for PyObject_GetAttrString. 2011-10-10 18:11:30 +02:00
Martin v. Löwis d63a3b8beb Implement PEP 393. 2011-09-28 07:41:54 +02:00