From: Benjamin Peterson Date: Sun, 3 May 2015 15:28:46 +0000 (-0400) Subject: merge 3.3 (#24096) X-Git-Tag: v3.5.0b1~251^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c59816b70a30d8ec2ff4e60a8b4a747f8ff75db;p=python merge 3.3 (#24096) --- 8c59816b70a30d8ec2ff4e60a8b4a747f8ff75db diff --cc Misc/NEWS index b787c84062,827d761bf9..b8d2ab14fe --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -10,27 -10,9 +10,30 @@@ Release date: tb Core and Builtins ----------------- + - Issue #24096: Make warnings.warn_explicit more robust against mutation of the + warnings.filters list. + +- Issue #23996: Avoid a crash when a delegated generator raises an + unnormalized StopIteration exception. Patch by Stefan Behnel. + +- Issue #24022: Fix tokenizer crash when processing undecodable source code. + +- Issue #23309: Avoid a deadlock at shutdown if a daemon thread is aborted + while it is holding a lock to a buffered I/O object, and the main thread + tries to use the same I/O object (typically stdout or stderr). A fatal + error is emitted instead. + +- Issue #22977: Fixed formatting Windows error messages on Wine. + Patch by Martin Panter. + +- Issue #23803: Fixed str.partition() and str.rpartition() when a separator + is wider then partitioned string. + +- Issue #23192: Fixed generator lambdas. Patch by Bruno Cauet. + +- Issue #23629: Fix the default __sizeof__ implementation for variable-sized + objects. + - Issue #24044: Fix possible null pointer dereference in list.sort in out of memory conditions. diff --cc Python/_warnings.c index bef56479b3,d274789f4a..6dff0a2c11 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@@ -101,8 -98,8 +101,8 @@@ get_default_action(void } - /* The item is a borrowed reference. */ + /* The item is a new reference. */ -static const char * +static PyObject* get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno, PyObject *module, PyObject **item) { @@@ -147,28 -145,29 +148,43 @@@ ln_obj = PyTuple_GET_ITEM(tmp_item, 4); good_msg = check_matched(msg, text); - if (good_msg == -1) ++ if (good_msg == -1) { ++ Py_DECREF(tmp_item); + return NULL; ++ } + good_mod = check_matched(mod, module); - if (good_mod == -1) ++ if (good_mod == -1) { ++ Py_DECREF(tmp_item); + return NULL; ++ } + is_subclass = PyObject_IsSubclass(category, cat); - if (is_subclass == -1) ++ if (is_subclass == -1) { ++ Py_DECREF(tmp_item); + return NULL; ++ } + ln = PyLong_AsSsize_t(ln_obj); - if (ln == -1 && PyErr_Occurred()) - if (good_msg == -1 || good_mod == -1 || is_subclass == -1 || - (ln == -1 && PyErr_Occurred())) { ++ if (ln == -1 && PyErr_Occurred()) { + Py_DECREF(tmp_item); return NULL; + } - if (good_msg && is_subclass && good_mod && (ln == 0 || lineno == ln)) + if (good_msg && is_subclass && good_mod && (ln == 0 || lineno == ln)) { + *item = tmp_item; - return _PyUnicode_AsString(action); + return action; + } + + Py_DECREF(tmp_item); } action = get_default_action(); - if (action != NULL) + if (action != NULL) { + Py_INCREF(Py_None); + *item = Py_None; - return _PyUnicode_AsString(action); + return action; + } PyErr_SetString(PyExc_ValueError, MODULE_NAME ".defaultaction not found"); @@@ -349,17 -304,10 +365,17 @@@ warn_explicit(PyObject *category, PyObj PyObject *module, PyObject *registry, PyObject *sourceline) { PyObject *key = NULL, *text = NULL, *result = NULL, *lineno_obj = NULL; - PyObject *item = Py_None; + PyObject *item = NULL; - const char *action; + PyObject *action; int rc; + /* module can be None if a warning is emitted late during Python shutdown. + In this case, the Python warnings module was probably unloaded, filters + are no more available to choose as action. It is safer to ignore the + warning and do nothing. */ + if (module == Py_None) + Py_RETURN_NONE; + if (registry && !PyDict_Check(registry) && (registry != Py_None)) { PyErr_SetString(PyExc_TypeError, "'registry' must be a dict"); return NULL;