Commit Graph

4332 Commits

Author SHA1 Message Date
Christian Heimes 01a513b5d3 Remove last bit of GNU pth thread
PEP 11:
  Name: Systems using --with-pth (GNU pth threads)
  Unsupported in: Python 3.2
  Code removed in: Python 3.3
2013-08-17 00:17:58 +02:00
Antoine Pitrou 95b21460ee Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing. 2013-08-16 20:49:32 +02:00
Antoine Pitrou ec34ab5010 Issue #18756: Improve error reporting in os.urandom() when the failure is due to something else than /dev/urandom not existing. 2013-08-16 20:44:38 +02:00
Antoine Pitrou 9ed5f27266 Issue #18722: Remove uses of the "register" keyword in C code. 2013-08-13 20:18:52 +02:00
Antoine Pitrou 40322e6ad5 Issue #10241: Clear extension module dict copies at interpreter shutdown.
Patch by Neil Schemenauer, minimally modified.

(re-apply after fix for tkinter-related crash)
2013-08-11 00:30:09 +02:00
Christian Heimes ad73a9cf97 Issue #16400: Add command line option for isolated mode.
-I

    Run Python in isolated mode. This also implies -E and -s. In isolated mode
    sys.path contains neither the script’s directory nor the user’s
    site-packages directory. All PYTHON* environment variables are ignored,
    too. Further restrictions may be imposed to prevent the user from
    injecting malicious code.
2013-08-10 16:36:18 +02:00
Antoine Pitrou 79ba3882ad Improve verbose reporting of shutdown phase by using the "public" module name 2013-08-06 22:50:15 +02:00
Antoine Pitrou 58720d6145 Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles. 2013-08-05 23:26:40 +02:00
Antoine Pitrou 95db2e7b8a Backout 62658d9d8926 (issue #10241): it causes a crash at shutdown when deallocating a Tkapp object. 2013-08-02 20:39:46 +02:00
Antoine Pitrou 84f31a5676 Issue #10241: Clear extension module dict copies at interpreter shutdown.
Patch by Neil Schemenauer, minimally modified.
2013-08-01 22:07:06 +02:00
Antoine Pitrou dcedaf6e53 Issue #18214: Improve finalization of Python modules to avoid setting their globals to None, in most cases. 2013-07-31 23:14:08 +02:00
Antoine Pitrou 32d483c39b Fix style 2013-07-30 21:01:23 +02:00
Victor Stinner c588feeea9 Issue #15893: Improve error handling in main() and Py_FrozenMain()
* handle _PyMem_RawStrdup() failure
* Py_FrozenMain() releases memory on error
* Py_FrozenMain() duplicates the old locale, as done in main()
2013-07-27 02:39:09 +02:00
Victor Stinner 739cf4e3e6 Py_FrozenMain() now uses _Py_char2wchar() to decode command line arguments, as
done in main()
2013-07-27 02:24:52 +02:00
Victor Stinner b5245bec93 Issue #18203: Replace PyMem_Malloc() with PyMem_RawMalloc() at Python initialization 2013-07-27 01:13:34 +02:00
Victor Stinner 597696c70c (Merge 3.3) Issue #15893: frozenmain.c now handles PyMem_Malloc() failure 2013-07-27 01:05:49 +02:00
Victor Stinner 36577e4e8c Issue #15893: frozenmain.c now handles PyMem_Malloc() failure 2013-07-27 01:04:56 +02:00
Christian Heimes b7f1b38dea Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object(). 2013-07-27 00:33:35 +02:00
Christian Heimes 70c94e7896 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object(). 2013-07-27 00:33:13 +02:00
Victor Stinner b318990cac (Merge 3.3) Parser/asdl_c.py: use Py_CLEAR() 2013-07-27 00:04:42 +02:00
Victor Stinner 1acc129d48 Parser/asdl_c.py: use Py_CLEAR() 2013-07-27 00:03:47 +02:00
Victor Stinner ee4b59c0f8 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Replace 8 spaces with 4.
2013-07-27 00:01:35 +02:00
Victor Stinner ce72e1ce6c According to the PEP 7, C code must "use 4-space indents"
Replace 8 spaces with 4.
2013-07-27 00:00:36 +02:00
Christian Heimes 4ebf6d7c3c Issue #18560: Fix potential NULL pointer dereference in sum() 2013-07-26 22:50:01 +02:00
Christian Heimes 704e2d374f Issue #18560: Fix potential NULL pointer dereference in sum() 2013-07-26 22:49:26 +02:00
Christian Heimes 6f08d30afe Fix potential NULL pointer dereferencing in ast module
CID 719690
2013-07-24 21:02:50 +02:00
Christian Heimes 72f562f719 Fix potential NULL pointer dereferencing in ast module
CID 719690
2013-07-24 21:02:17 +02:00
Benjamin Peterson 26421ab302 merge 3.3 2013-07-22 22:08:17 -07:00
Benjamin Peterson 7d28b6b379 return NULL here 2013-07-22 22:08:09 -07:00
Victor Stinner ba30883f60 Issue #18520: Fix initstdio(), handle PySys_SetObject() failure 2013-07-22 23:55:19 +02:00
Victor Stinner 62ce62a3a1 Issue #18520: initsite() is a little bit more verbose when import site fails 2013-07-22 22:53:28 +02:00
Victor Stinner 580496005d Issue #18520: Fix _PySys_Init(), handle PyDict_SetItemString() errors 2013-07-22 22:40:00 +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 1c8f059019 Issue #18520: Add a new PyStructSequence_InitType2() function, same than
PyStructSequence_InitType() except that it has a return value (0 on success,
-1 on error).

 * PyStructSequence_InitType2() now raises MemoryError on memory allocation failure
 * Fix also some calls to PyDict_SetItemString(): handle error
2013-07-22 22:24:54 +02:00
Christian Heimes de0e63bd9c Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
2013-07-22 12:54:21 +02:00
Christian Heimes 60a6067709 Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
2013-07-22 12:53:32 +02:00
Benjamin Peterson c3e10c237b merge 3.3 2013-07-21 13:29:42 -07:00
Benjamin Peterson 0f9b7d32c7 fix spacing 2013-07-21 13:29:37 -07:00
Benjamin Peterson 33113a3504 merge 3.3 2013-07-21 13:26:27 -07:00
Benjamin Peterson 04b01dc8f7 let's not return NULL from functions that should return ints 2013-07-21 13:26:13 -07:00
Victor Stinner d786ad55ef Issue #18520: Fix initsigs(), handle PyOS_InitInterrupts() error
PyOS_InitInterrupts() can raise error when importing the signal module
2013-07-21 13:25:51 +02:00
Christian Heimes 02e8b53e6d Check return value of lseek() in _Py_DisplaySourceLine().
Also use portable SEEK_SET instead of 0.
CID 1040639
2013-07-21 02:12:44 +02:00
Christian Heimes 1f34729f42 Check return value of lseek() in _Py_DisplaySourceLine().
Also use portable SEEK_SET instead of 0.
CID 1040639
2013-07-21 02:12:35 +02:00
Christian Heimes 8282d749a6 Check return value of PyObject_AsFileDescriptor() in _Py_DisplaySourceLine() for error
CID 486768
2013-07-21 01:53:18 +02:00
Christian Heimes 8c077bc03e Check return value of PyObject_AsFileDescriptor() in _Py_DisplaySourceLine() for error
CID 486768
2013-07-21 01:53:10 +02:00
Christian Heimes 7bc80fcf4e Check return value of fstat() in _PyImport_GetDynLoadFunc()
CID 486250
2013-07-20 22:18:19 +02:00
Christian Heimes 27c4c3ec79 Check return value of fstat() in _PyImport_GetDynLoadFunc()
CID 486250
2013-07-20 22:17:55 +02:00
Christian Heimes 74ba26a40c Add missing check of PyDict_SetItem()'s return value in _PyImport_FindExtensionObject()
CID 486649
2013-07-20 14:52:18 +02:00
Christian Heimes 09ca794afe Add missing check of PyDict_SetItem()'s return value in _PyImport_FindExtensionObject()
CID 486649
2013-07-20 14:51:53 +02:00
Christian Heimes 895bdfb16e Add missing check of PyDict_SetItem()'s return value in PyEval_EvalCodeEx()
CID 486647
2013-07-20 14:48:21 +02:00
Christian Heimes 0bd447f847 Add missing check of PyDict_SetItem()'s return value in PyEval_EvalCodeEx()
CID 486647
2013-07-20 14:48:10 +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 8e54b1c448 Issue #18408: Fix _PyImport_LoadDynamicModule(), handle PyUnicode_FromFormat() failure 2013-07-17 21:53:23 +02:00
Victor Stinner 0fae8f9083 Issue #18408: Fix ast_for_atom(), PyErr_Fetch(&type, &value, &tback) can set value to NULL 2013-07-17 21:51:42 +02:00
Victor Stinner 26f91999b4 Close #18469: Replace PyDict_GetItemString() with _PyDict_GetItemId() in structseq.c
_PyDict_GetItemId() is more efficient: it only builds the Unicode string once.
Identifiers (dictionary keys) are now created at Python initialization, and if
the creation failed, Python does exit with a fatal error.

Before, PyDict_GetItemString() failure was not handled: structseq_new() could
call PyObject_GC_NewVar() with a negative size, and structseq_dealloc() could
also crash.
2013-07-17 01:22:45 +02:00
Victor Stinner 43d8195a70 Issue #18408: Handle PyArena_AddPyObject() failure in ast.c
PyList_Append() (called by PyArena_AddPyObject()) can fail because of a
MemoryError for example.
2013-07-17 00:57:58 +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 bdf630c4a7 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError) 2013-07-17 00:17:15 +02:00
Victor Stinner 1e53bbaced Issue #18408: handle PySys_GetObject() failure, raise a RuntimeError 2013-07-16 22:26:05 +02:00
Victor Stinner 78e2c985ac Issue #18408: Fix show_warning(), clear also the exception raised by
_Py_DisplaySourceLine()

For example, _PyGC_DumpShutdownStats() calls PyErr_WarnExplicitFormat() while
the import machinery does not work anymore, _Py_DisplaySourceLine() fails when
trying to import the io module.
2013-07-16 01:54:37 +02: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 ceceaa00ba Issue #18408: Fix _Py_DisplaySourceLine()
Report _Py_FindSourceFile() error, so the error is cleared;
and clear io.open(filename) exception on failure.
2013-07-16 00:32:14 +02:00
Victor Stinner 7eab0d000c Issue #18408: Fix PyEval_EvalFrameEx() for MemoryError
Don't pass a NULL traceback to PyException_SetTraceback(): pass Py_None.
Passing NULL would raise a new exception.
2013-07-15 21:16:27 +02:00
Brett Cannon a79e4fb38d Issue #18342: Use the repr of a module name for ``from ... import
...`` when an ImportError occurs.

Other cases had already been switched over to using the repr.

Thanks to Tomasz Maćkowiak for the patch.
2013-07-12 11:22:26 -04:00
Brett Cannon f0cb69274c Issue #18415: Normalize what type of quotes are used with string
constants in importlib._bootstrap. Along the way clean up from string
interpolation to use the repr explicitly.

Initial patch by Madison May.
2013-07-12 11:04:23 -04: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
Victor Stinner 365b693adc Issue #18408: ceval.c: in debug mode, convert the PyErr_Occurred() check on
exception (when getting NULL) to an assertion to detect bugs earlier
2013-07-12 00:11:58 +02:00
Victor Stinner cc35159ed8 Issue #18408: normalizestring() now raises MemoryError on memory allocation failure 2013-07-12 00:02:55 +02:00
Victor Stinner 6b64a6803e Issue #18408: Fix compiler_import() to handle PyUnicode_Substring() failure properly 2013-07-11 22:50:45 +02:00
Victor Stinner 9a4fb66966 Issue #18408: ste_new() initialize all attributes before handling error
If an attribute is not initialized, the destructor can crash
2013-07-11 22:49:00 +02:00
Serhiy Storchaka f9e6672ae8 Issue #17872: Fix a segfault in marshal.load() when input stream returns
more bytes than requested.
2013-07-11 22:28:18 +03:00
Serhiy Storchaka 3641a74e1c Issue #17872: Fix a segfault in marshal.load() when input stream returns
more bytes than requested.
2013-07-11 22:20:47 +03:00
Serhiy Storchaka a155d40ed5 Fix reference leaks introduced by the patch for issue #5308. 2013-07-11 19:19:47 +03:00
Serhiy Storchaka dfde2151ed Fix reference leaks introduced by the patch for issue #5308. 2013-07-11 19:14:26 +03:00
Christian Heimes 6cee994674 Issue #18426: improve exception message. Courtesy of Amaury 2013-07-11 13:02:37 +02:00
Christian Heimes 7ce57d67c9 Issue #18426: improve exception message. Courtesy of Amaury 2013-07-11 13:02:30 +02:00
Christian Heimes 5ec44649df Issue #18426: Fix NULL pointer dereference in C extension import when
PyModule_GetDef() returns an error.
2013-07-11 11:23:34 +02:00
Christian Heimes 848ee099f5 Issue #18426: Fix NULL pointer dereference in C extension import when
PyModule_GetDef() returns an error.
2013-07-11 11:22:21 +02:00
R David Murray acb362e29f Merge: #18424: PEP8ify the tense of the sum docstring. 2013-07-10 16:22:59 -04:00
R David Murray 87ead1138d #18424: PEP8ify the tense of the sum docstring. 2013-07-10 16:22:14 -04:00
Victor Stinner aaa8ed8b84 Issue #18408: Fix call_exc_trace(): if the traceback is NULL, use None when
building the tuple (type, value, traceback) passed to the callback.

PyTuple_Pack() does crash if an argument is NULL.
2013-07-10 13:57:55 +02:00
Victor Stinner e0af3a802a Issue #18408: Fix PyCode_Optimize(): raise a MemoryError on memory allocation
failure.
2013-07-09 00:32:04 +02:00
Victor Stinner 0ff0f54dd4 Issue #18408: Fix call_function() of ceval.c to handle PyTuple_New() failure
(in load_args()), ex: MemoryError.
2013-07-08 22:27:42 +02:00
Victor Stinner 3a8b79d4d2 Issue #18408: Fix marshal reader for Unicode strings: handle
PyUnicode_DecodeUTF8() failure (ex: MemoryError).
2013-07-08 22:23:32 +02:00
Victor Stinner 49fc8ece81 Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()
Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the
GIL is held or not.
2013-07-07 23:30:24 +02:00
Victor Stinner c6632e7eb4 Issue #18203: Replace malloc() with PyMem_Malloc() to allocate arena objects 2013-07-07 17:18:53 +02:00
Victor Stinner 80aa565fb4 Issue #18203: Replace malloc() with PyMem_RawMalloc() to allocate thread locks 2013-07-07 17:17:59 +02:00
Victor Stinner 65bf9cf26f Issue #18203: Fix decode_ascii_surrogateescape(), use PyMem_RawMalloc() as _Py_char2wchar() 2013-07-07 16:35:54 +02:00
Victor Stinner 1a7425f67a Issue #18203: Replace malloc() with PyMem_RawMalloc() at Python initialization
* Replace malloc() with PyMem_RawMalloc()
* Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held.
* _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead
  of PyMem_Malloc()
2013-07-07 16:25:15 +02:00
Victor Stinner 51fa458d0a Issue #18203: Fix Py_Finalize(): destroy the GIL after the last call to
PyMem_Malloc() or PyObject_Malloc().

For example, PyCFunction_Fini() calls PyObject_GC_Del() which calls
PyObject_FREE().
2013-07-07 15:50:49 +02:00
Brett Cannon 7e5d55705c merge for issue #18351. 2013-07-06 18:04:41 -04:00
Brett Cannon a53cca3fea Issue #18351: Fix various issues with
importlib._bootstrap._get_sourcefile().

Thanks to its only use by the C API, it was never properly tested
until now.

Thanks to Neal Norwitz for discovering the bug and Madison May for the patch.
2013-07-06 17:56:43 -04:00
Brett Cannon 0075110ab2 Issue #18364: Stop using the ImportError._not_found hack.
The private attribute was leaking out of importlib and led to at least
one person noticing it. Switch to another hack which won't leak
outside of importlib and is nearly as robust.
2013-07-06 14:48:18 -04:00
Brett Cannon 679ecb565b Issue #15767: back out 8a0ed9f63c6e, finishing the removal of
ModuleNotFoundError.
2013-07-04 17:51:50 -04:00
Brett Cannon 82da8886cc Issue #15767: Revert 3a50025f1900 for ModuleNotFoundError 2013-07-04 17:48:16 -04:00
Christian Heimes 1d5b933504 Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now the
tstate is first removed from TLS and then deallocated.
CID 1019639 (#1 of 1): Use after free (USE_AFTER_FREE)
 use_after_free: Using freed pointer tstate.
2013-07-01 23:43:09 +02:00
Christian Heimes b9dbc7d6e1 Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now the
tstate is first removed from TLS and then deallocated.
CID 1019639 (#1 of 1): Use after free (USE_AFTER_FREE)
 use_after_free: Using freed pointer tstate.
2013-07-01 23:42:28 +02:00
Raymond Hettinger 4d6018fe45 Issue 18111: Add a default argument to min() and max() 2013-06-24 22:43:02 -07:00
Victor Stinner 14b9b11098 If MS_WIN64 is defined, MS_WINDOWS is also defined: #ifdef can be simplified. 2013-06-25 00:37:25 +02:00