From eeb5635843810ee67f2b18b96f4266d134d913ee Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 11 Sep 2012 14:11:03 +0200 Subject: Issue #15895: Fix FILE pointer leak in PyRun_SimpleFileExFlags() when filename points to a pyc/pyo file and closeit is false. --- Python/pythonrun.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 05dfb8e..7e9f654 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1385,7 +1385,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, { PyObject *m, *d, *v; const char *ext; - int set_file_name = 0, ret; + int set_file_name = 0, close_own_fp = 0, ret; size_t len; m = PyImport_AddModule("__main__"); @@ -1419,6 +1419,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, ret = -1; goto done; } + close_own_fp = 1; /* Turn on optimization if a .pyo file is given */ if (strcmp(ext, ".pyo") == 0) Py_OptimizeFlag = 1; @@ -1449,6 +1450,9 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, Py_DECREF(v); ret = 0; done: + if (close_own_fp) { + fclose(fp); + } if (set_file_name && PyDict_DelItemString(d, "__file__")) PyErr_Clear(); return ret; -- cgit v0.12 From 04ac4c1cb8e7af5571adbe64cb82938a323e5850 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 11 Sep 2012 15:47:28 +0200 Subject: Issue #15895: my analysis was slightly off. The FILE pointer is only leaked when set_main_loader() fails for a pyc file with closeit=0. In the success case run_pyc_file() does its own cleanup of the fp. I've changed the code to use another FILE ptr for pyc files and moved the fclose() to PyRun_SimpleFileExFlags() to make it more obvious what's happening. --- Python/pythonrun.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 7e9f654..b1ca125 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1385,7 +1385,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, { PyObject *m, *d, *v; const char *ext; - int set_file_name = 0, close_own_fp = 0, ret; + int set_file_name = 0, ret; size_t len; m = PyImport_AddModule("__main__"); @@ -1411,15 +1411,15 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, len = strlen(filename); ext = filename + len - (len > 4 ? 4 : 0); if (maybe_pyc_file(fp, filename, ext, closeit)) { + FILE *pyc_fp; /* Try to run a pyc file. First, re-open in binary */ if (closeit) fclose(fp); - if ((fp = fopen(filename, "rb")) == NULL) { + if ((pyc_fp = fopen(filename, "rb")) == NULL) { fprintf(stderr, "python: Can't reopen .pyc file\n"); ret = -1; goto done; } - close_own_fp = 1; /* Turn on optimization if a .pyo file is given */ if (strcmp(ext, ".pyo") == 0) Py_OptimizeFlag = 1; @@ -1427,9 +1427,11 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, if (set_main_loader(d, filename, "SourcelessFileLoader") < 0) { fprintf(stderr, "python: failed to set __main__.__loader__\n"); ret = -1; + fclose(pyc_fp); goto done; } - v = run_pyc_file(fp, filename, d, d, flags); + v = run_pyc_file(pyc_fp, filename, d, d, flags); + fclose(pyc_fp); } else { /* When running from stdin, leave __main__.__loader__ alone */ if (strcmp(filename, "") != 0 && @@ -1450,9 +1452,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, Py_DECREF(v); ret = 0; done: - if (close_own_fp) { - fclose(fp); - } if (set_file_name && PyDict_DelItemString(d, "__file__")) PyErr_Clear(); return ret; @@ -1999,7 +1998,6 @@ run_pyc_file(FILE *fp, const char *filename, PyObject *globals, (void) PyMarshal_ReadLongFromFile(fp); (void) PyMarshal_ReadLongFromFile(fp); v = PyMarshal_ReadLastObjectFromFile(fp); - fclose(fp); if (v == NULL || !PyCode_Check(v)) { Py_XDECREF(v); PyErr_SetString(PyExc_RuntimeError, -- cgit v0.12 From 6c4b09533464e3337623e0b2abc990500898c0b8 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 11 Sep 2012 19:28:42 +0200 Subject: Updates NEWS for issue #15895 --- Misc/NEWS | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index e6e4cbb..9a301c3 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,7 +2,7 @@ Python News +++++++++++ -What's New in Python 3.3.0? +What's New in Python 3.3.0 Release Candidate 3? =========================== *Release date: XX-Sep-2012* @@ -10,6 +10,10 @@ What's New in Python 3.3.0? Core and Builtins ----------------- +- Issue #15895: Fix FILE pointer leak in one error branch of + PyRun_SimpleFileExFlags() when filename points to a pyc/pyo file, closeit + is false an and set_main_loader() fails. + Library ------- -- cgit v0.12 From dbcf103be09b63531451166e4f53e8f9a6dd852e Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Mon, 10 Sep 2012 19:34:58 +0200 Subject: Issue #15882: Change _decimal to accept any coefficient tuple when constructing infinities. This is done for backwards compatibility with decimal.py: Infinity coefficients are undefined in _decimal (in accordance with the specification). --- Lib/test/test_decimal.py | 17 ++++++++++------- Misc/NEWS | 4 ++++ Modules/_decimal/_decimal.c | 7 +++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index d00ed5a..3ca5927 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -1992,7 +1992,8 @@ class UsabilityTest(unittest.TestCase): d = Decimal("-4.34913534E-17") self.assertEqual(d.as_tuple(), (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) ) - # XXX non-compliant infinity payload. + # The '0' coefficient is implementation specific to decimal.py. + # It has no meaning in the C-version and is ignored there. d = Decimal("Infinity") self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) @@ -2012,12 +2013,14 @@ class UsabilityTest(unittest.TestCase): d = Decimal( (1, (), 'n') ) self.assertEqual(d.as_tuple(), (1, (), 'n') ) - # XXX coefficient in infinity should raise an error - if self.decimal == P: - d = Decimal( (0, (4, 5, 3, 4), 'F') ) - self.assertEqual(d.as_tuple(), (0, (0,), 'F')) - d = Decimal( (1, (0, 2, 7, 1), 'F') ) - self.assertEqual(d.as_tuple(), (1, (0,), 'F')) + # For infinities, decimal.py has always silently accepted any + # coefficient tuple. + d = Decimal( (0, (0,), 'F') ) + self.assertEqual(d.as_tuple(), (0, (0,), 'F')) + d = Decimal( (0, (4, 5, 3, 4), 'F') ) + self.assertEqual(d.as_tuple(), (0, (0,), 'F')) + d = Decimal( (1, (0, 2, 7, 1), 'F') ) + self.assertEqual(d.as_tuple(), (1, (0,), 'F')) def test_subclassing(self): # Different behaviours when subclassing Decimal diff --git a/Misc/NEWS b/Misc/NEWS index 9a301c3..bed62b6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -17,6 +17,10 @@ Core and Builtins Library ------- +- Issue #15882: Change _decimal to accept any coefficient tuple when + constructing infinities. This is done for backwards compatibility + with decimal.py: Infinity coefficients are undefined in _decimal + (in accordance with the specification). What's New in Python 3.3.0 Release Candidate 2? =============================================== diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 15c64e2..996f9da 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -2364,6 +2364,7 @@ dectuple_as_str(PyObject *dectuple) long sign, l; mpd_ssize_t exp = 0; Py_ssize_t i, mem, tsize; + int is_infinite = 0; int n; assert(PyTuple_Check(dectuple)); @@ -2399,6 +2400,7 @@ dectuple_as_str(PyObject *dectuple) /* special */ if (PyUnicode_CompareWithASCIIString(tmp, "F") == 0) { strcat(sign_special, "Inf"); + is_infinite = 1; } else if (PyUnicode_CompareWithASCIIString(tmp, "n") == 0) { strcat(sign_special, "NaN"); @@ -2470,6 +2472,11 @@ dectuple_as_str(PyObject *dectuple) "coefficient must be a tuple of digits"); goto error; } + if (is_infinite) { + /* accept but ignore any well-formed coefficient for compatibility + with decimal.py */ + continue; + } *cp++ = (char)l + '0'; } *cp = '\0'; -- cgit v0.12 From f022aa502d1c3730f11a17e8534ea1ac91db4a8c Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 22 Sep 2012 08:53:12 +0200 Subject: Spacing fix. --- Misc/NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/NEWS b/Misc/NEWS index bed62b6..96e5fdd 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,7 @@ Library with decimal.py: Infinity coefficients are undefined in _decimal (in accordance with the specification). + What's New in Python 3.3.0 Release Candidate 2? =============================================== -- cgit v0.12 From 63b38bbd1d36538dac8a21ba33117bd6800e58b4 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 20 Sep 2012 12:42:54 +0200 Subject: Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times --- Misc/NEWS | 3 +++ Modules/_ssl.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 96e5fdd..04bc41d 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -201,6 +201,9 @@ Documentation - Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by Daniel Ellis. +- Issue #15977: Fix memory leak in Modules/_ssl.c when the function + _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. + Tests ----- diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 1104a4e..1516b87 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1713,6 +1713,9 @@ context_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } self->ctx = ctx; +#ifdef OPENSSL_NPN_NEGOTIATED + self->npn_protocols = NULL; +#endif /* Defaults */ SSL_CTX_set_verify(self->ctx, SSL_VERIFY_NONE, NULL); SSL_CTX_set_options(self->ctx, @@ -1812,6 +1815,10 @@ _set_npn_protocols(PySSLContext *self, PyObject *args) if (!PyArg_ParseTuple(args, "y*:set_npn_protocols", &protos)) return NULL; + if (self->npn_protocols != NULL) { + PyMem_Free(self->npn_protocols); + } + self->npn_protocols = PyMem_Malloc(protos.len); if (self->npn_protocols == NULL) { PyBuffer_Release(&protos); -- cgit v0.12 From ebf7f957d75bfa0e0f0c68019c8ed3616bef0c6c Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 22 Sep 2012 08:56:12 +0200 Subject: Fix NEWS entry location. --- Misc/NEWS | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 04bc41d..612f70c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1,4 +1,4 @@ -+++++++++++ +s+++++++++++ Python News +++++++++++ @@ -22,6 +22,12 @@ Library with decimal.py: Infinity coefficients are undefined in _decimal (in accordance with the specification). +Extension Modules +----------------- + +- Issue #15977: Fix memory leak in Modules/_ssl.c when the function + _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. + What's New in Python 3.3.0 Release Candidate 2? =============================================== @@ -201,9 +207,6 @@ Documentation - Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by Daniel Ellis. -- Issue #15977: Fix memory leak in Modules/_ssl.c when the function - _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. - Tests ----- -- cgit v0.12 From deb92b5b1b015191bb9f072b67536e471bd37a7a Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 22 Sep 2012 08:58:55 +0200 Subject: Closes #15969: rename new API to have consistent names in the faulthandler module. --- Doc/library/faulthandler.rst | 8 ++++---- Lib/test/test_faulthandler.py | 38 +++++++++++++++++++------------------- Misc/NEWS | 4 ++++ Modules/faulthandler.c | 28 ++++++++++++++-------------- 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index b079b30..3c33621 100644 --- a/Doc/library/faulthandler.rst +++ b/Doc/library/faulthandler.rst @@ -71,7 +71,7 @@ Fault handler state Dump the tracebacks after a timeout ----------------------------------- -.. function:: dump_tracebacks_later(timeout, repeat=False, file=sys.stderr, exit=False) +.. function:: dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False) Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, call @@ -84,9 +84,9 @@ Dump the tracebacks after a timeout This function is implemented using a watchdog thread and therefore is not available if Python is compiled with threads disabled. -.. function:: cancel_dump_tracebacks_later() +.. function:: cancel_dump_traceback_later() - Cancel the last call to :func:`dump_tracebacks_later`. + Cancel the last call to :func:`dump_traceback_later`. Dump the traceback on a user signal @@ -112,7 +112,7 @@ Dump the traceback on a user signal File descriptor issue --------------------- -:func:`enable`, :func:`dump_tracebacks_later` and :func:`register` keep the +:func:`enable`, :func:`dump_traceback_later` and :func:`register` keep the file descriptor of their *file* argument. If the file is closed and its file descriptor is reused by a new file, or if :func:`os.dup2` is used to replace the file descriptor, the traceback will be written into a different file. Call diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py index c186b34..b81b34d 100644 --- a/Lib/test/test_faulthandler.py +++ b/Lib/test/test_faulthandler.py @@ -407,7 +407,7 @@ Current thread XXX: with temporary_filename() as filename: self.check_dump_traceback_threads(filename) - def _check_dump_tracebacks_later(self, repeat, cancel, filename, loops): + def _check_dump_traceback_later(self, repeat, cancel, filename, loops): """ Check how many times the traceback is written in timeout x 2.5 seconds, or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending @@ -422,11 +422,11 @@ import time def func(timeout, repeat, cancel, file, loops): for loop in range(loops): - faulthandler.dump_tracebacks_later(timeout, repeat=repeat, file=file) + faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file) if cancel: - faulthandler.cancel_dump_tracebacks_later() + faulthandler.cancel_dump_traceback_later() time.sleep(timeout * 5) - faulthandler.cancel_dump_tracebacks_later() + faulthandler.cancel_dump_traceback_later() timeout = {timeout} repeat = {repeat} @@ -462,9 +462,9 @@ if file is not None: self.assertEqual(trace, '') self.assertEqual(exitcode, 0) - @unittest.skipIf(not hasattr(faulthandler, 'dump_tracebacks_later'), - 'need faulthandler.dump_tracebacks_later()') - def check_dump_tracebacks_later(self, repeat=False, cancel=False, + @unittest.skipIf(not hasattr(faulthandler, 'dump_traceback_later'), + 'need faulthandler.dump_traceback_later()') + def check_dump_traceback_later(self, repeat=False, cancel=False, file=False, twice=False): if twice: loops = 2 @@ -472,25 +472,25 @@ if file is not None: loops = 1 if file: with temporary_filename() as filename: - self._check_dump_tracebacks_later(repeat, cancel, + self._check_dump_traceback_later(repeat, cancel, filename, loops) else: - self._check_dump_tracebacks_later(repeat, cancel, None, loops) + self._check_dump_traceback_later(repeat, cancel, None, loops) - def test_dump_tracebacks_later(self): - self.check_dump_tracebacks_later() + def test_dump_traceback_later(self): + self.check_dump_traceback_later() - def test_dump_tracebacks_later_repeat(self): - self.check_dump_tracebacks_later(repeat=True) + def test_dump_traceback_later_repeat(self): + self.check_dump_traceback_later(repeat=True) - def test_dump_tracebacks_later_cancel(self): - self.check_dump_tracebacks_later(cancel=True) + def test_dump_traceback_later_cancel(self): + self.check_dump_traceback_later(cancel=True) - def test_dump_tracebacks_later_file(self): - self.check_dump_tracebacks_later(file=True) + def test_dump_traceback_later_file(self): + self.check_dump_traceback_later(file=True) - def test_dump_tracebacks_later_twice(self): - self.check_dump_tracebacks_later(twice=True) + def test_dump_traceback_later_twice(self): + self.check_dump_traceback_later(twice=True) @unittest.skipIf(not hasattr(faulthandler, "register"), "need faulthandler.register") diff --git a/Misc/NEWS b/Misc/NEWS index 612f70c..b9cb2fe 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,6 +28,10 @@ Extension Modules - Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. +- Issue #5969: faulthandler module: rename dump_tracebacks_later() to + dump_traceback_later() and cancel_dump_tracebacks_later() to + cancel_dump_traceback_later(). + What's New in Python 3.3.0 Release Candidate 2? =============================================== diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 4aa9124..7e363f0 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -462,7 +462,7 @@ faulthandler_thread(void *unused) } static void -cancel_dump_tracebacks_later(void) +cancel_dump_traceback_later(void) { /* Notify cancellation */ PyThread_release_lock(thread.cancel_event); @@ -509,7 +509,7 @@ format_timeout(double timeout) } static PyObject* -faulthandler_dump_tracebacks_later(PyObject *self, +faulthandler_dump_traceback_later(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = {"timeout", "repeat", "file", "exit", NULL}; @@ -524,7 +524,7 @@ faulthandler_dump_tracebacks_later(PyObject *self, size_t header_len; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "d|iOi:dump_tracebacks_later", kwlist, + "d|iOi:dump_traceback_later", kwlist, &timeout, &repeat, &file, &exit)) return NULL; if ((timeout * 1e6) >= (double) PY_TIMEOUT_MAX) { @@ -552,7 +552,7 @@ faulthandler_dump_tracebacks_later(PyObject *self, header_len = strlen(header); /* Cancel previous thread, if running */ - cancel_dump_tracebacks_later(); + cancel_dump_traceback_later(); Py_XDECREF(thread.file); Py_INCREF(file); @@ -582,9 +582,9 @@ faulthandler_dump_tracebacks_later(PyObject *self, } static PyObject* -faulthandler_cancel_dump_tracebacks_later_py(PyObject *self) +faulthandler_cancel_dump_traceback_later_py(PyObject *self) { - cancel_dump_tracebacks_later(); + cancel_dump_traceback_later(); Py_RETURN_NONE; } #endif /* FAULTHANDLER_LATER */ @@ -970,16 +970,16 @@ static PyMethodDef module_methods[] = { "dump the traceback of the current thread, or of all threads " "if all_threads is True, into file")}, #ifdef FAULTHANDLER_LATER - {"dump_tracebacks_later", - (PyCFunction)faulthandler_dump_tracebacks_later, METH_VARARGS|METH_KEYWORDS, - PyDoc_STR("dump_tracebacks_later(timeout, repeat=False, file=sys.stderrn, exit=False):\n" + {"dump_traceback_later", + (PyCFunction)faulthandler_dump_traceback_later, METH_VARARGS|METH_KEYWORDS, + PyDoc_STR("dump_traceback_later(timeout, repeat=False, file=sys.stderrn, exit=False):\n" "dump the traceback of all threads in timeout seconds,\n" "or each timeout seconds if repeat is True. If exit is True, " "call _exit(1) which is not safe.")}, - {"cancel_dump_tracebacks_later", - (PyCFunction)faulthandler_cancel_dump_tracebacks_later_py, METH_NOARGS, - PyDoc_STR("cancel_dump_tracebacks_later():\ncancel the previous call " - "to dump_tracebacks_later().")}, + {"cancel_dump_traceback_later", + (PyCFunction)faulthandler_cancel_dump_traceback_later_py, METH_NOARGS, + PyDoc_STR("cancel_dump_traceback_later():\ncancel the previous call " + "to dump_traceback_later().")}, #endif #ifdef FAULTHANDLER_USER @@ -1120,7 +1120,7 @@ void _PyFaulthandler_Fini(void) #ifdef FAULTHANDLER_LATER /* later */ if (thread.cancel_event) { - cancel_dump_tracebacks_later(); + cancel_dump_traceback_later(); PyThread_release_lock(thread.cancel_event); PyThread_free_lock(thread.cancel_event); thread.cancel_event = NULL; -- cgit v0.12 From 1aca31e8f329e19de62a2f1a2080995e5712a9cd Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 22 Sep 2012 09:03:56 +0200 Subject: Closes #15925: fix regression in parsedate() and parsedate_tz() that should return None if unable to parse the argument. --- Lib/email/_parseaddr.py | 4 ++++ Lib/email/utils.py | 24 ++---------------------- Lib/test/test_email/test_email.py | 13 +++++++++++-- Misc/NEWS | 4 ++++ 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index 3528d02..cdfa372 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -48,6 +48,8 @@ def parsedate_tz(data): Accounts for military timezones. """ res = _parsedate_tz(data) + if not res: + return if res[9] is None: res[9] = 0 return tuple(res) @@ -62,6 +64,8 @@ def _parsedate_tz(data): source timezone really was UTC. """ + if not data: + return data = data.split() # The FWS after the comma after the day-of-week is optional, so search and # adjust for this. diff --git a/Lib/email/utils.py b/Lib/email/utils.py index 73bc348..6b6d7f4 100644 --- a/Lib/email/utils.py +++ b/Lib/email/utils.py @@ -37,10 +37,7 @@ from email._parseaddr import quote from email._parseaddr import AddressList as _AddressList from email._parseaddr import mktime_tz -# We need wormarounds for bugs in these methods in older Pythons (see below) -from email._parseaddr import parsedate as _parsedate -from email._parseaddr import parsedate_tz as _parsedate_tz -from email._parseaddr import _parsedate_tz as __parsedate_tz +from email._parseaddr import parsedate, parsedate_tz, _parsedate_tz from quopri import decodestring as _qdecode @@ -222,25 +219,8 @@ def make_msgid(idstring=None, domain=None): return msgid - -# These functions are in the standalone mimelib version only because they've -# subsequently been fixed in the latest Python versions. We use this to worm -# around broken older Pythons. -def parsedate(data): - if not data: - return None - return _parsedate(data) - - -def parsedate_tz(data): - if not data: - return None - return _parsedate_tz(data) - def parsedate_to_datetime(data): - if not data: - return None - *dtuple, tz = __parsedate_tz(data) + *dtuple, tz = _parsedate_tz(data) if tz is None: return datetime.datetime(*dtuple[:6]) return datetime.datetime(*dtuple[:6], diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 5cc6d04..36c344f 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -2718,8 +2718,17 @@ class TestMiscellaneous(TestEmailBase): utils.formatdate(now, localtime=False, usegmt=True), time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(now))) - def test_parsedate_none(self): - self.assertEqual(utils.parsedate(''), None) + # parsedate and parsedate_tz will become deprecated interfaces someday + def test_parsedate_returns_None_for_invalid_strings(self): + self.assertIsNone(utils.parsedate('')) + self.assertIsNone(utils.parsedate_tz('')) + self.assertIsNone(utils.parsedate('0')) + self.assertIsNone(utils.parsedate_tz('0')) + self.assertIsNone(utils.parsedate('A Complete Waste of Time')) + self.assertIsNone(utils.parsedate_tz('A Complete Waste of Time')) + # Not a part of the spec but, but this has historically worked: + self.assertIsNone(utils.parsedate(None)) + self.assertIsNone(utils.parsedate_tz(None)) def test_parsedate_compact(self): # The FWS after the comma is optional diff --git a/Misc/NEWS b/Misc/NEWS index b9cb2fe..0594152 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,10 @@ Library with decimal.py: Infinity coefficients are undefined in _decimal (in accordance with the specification). +- Issue #15925: Fix a regression in email.util where the parsedate() and + parsedate_tz() functions did not return None anymore when the argument could + not be parsed. + Extension Modules ----------------- -- cgit v0.12 From fd296ff5d6436ad3a782cca816783f05acd9fe78 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 12 Sep 2012 18:01:36 +0200 Subject: Issue #15926: Fix crash after multiple reinitializations of the interpreter. --- Misc/NEWS | 2 ++ Modules/posixmodule.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 0594152..882d274 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ What's New in Python 3.3.0 Release Candidate 3? Core and Builtins ----------------- +- Issue #15926: Fix crash after multiple reinitializations of the interpreter. + - Issue #15895: Fix FILE pointer leak in one error branch of PyRun_SimpleFileExFlags() when filename points to a pyc/pyo file, closeit is false an and set_main_loader() fails. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 1f2b0cc..54f6cd2 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -11852,7 +11852,6 @@ INITFUNC(void) /* initialize TerminalSize_info */ PyStructSequence_InitType(&TerminalSizeType, &TerminalSize_desc); - Py_INCREF(&TerminalSizeType); } #if defined(HAVE_WAITID) && !defined(__APPLE__) Py_INCREF((PyObject*) &WaitidResultType); @@ -11915,6 +11914,7 @@ INITFUNC(void) #endif /* __APPLE__ */ + Py_INCREF(&TerminalSizeType); PyModule_AddObject(m, "terminal_size", (PyObject*) &TerminalSizeType); billion = PyLong_FromLong(1000000000); -- cgit v0.12 From 0085a2407574a4af46019bee279895bdafbd76b8 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 22 Sep 2012 09:23:12 +0200 Subject: Closes #15973: fix a segmentation fault when comparing timezone objects. --- Lib/datetime.py | 2 ++ Lib/test/datetimetester.py | 2 ++ Misc/NEWS | 3 +++ Modules/_datetimemodule.c | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/Lib/datetime.py b/Lib/datetime.py index a15c6b0..f506e9a 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1854,6 +1854,8 @@ class timezone(tzinfo): return (self._offset, self._name) def __eq__(self, other): + if type(other) != timezone: + return False return self._offset == other._offset def __hash__(self): diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index a417170..931ef6f 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -235,6 +235,8 @@ class TestTimeZone(unittest.TestCase): self.assertEqual(timezone(-5 * HOUR), timezone(-5 * HOUR, 'EST')) with self.assertRaises(TypeError): timezone(ZERO) < timezone(ZERO) self.assertIn(timezone(ZERO), {timezone(ZERO)}) + self.assertTrue(timezone(ZERO) != None) + self.assertFalse(timezone(ZERO) == None) def test_aware_datetime(self): # test that timezone instances can be used by datetime diff --git a/Misc/NEWS b/Misc/NEWS index 882d274..f82da60 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -31,6 +31,9 @@ Library Extension Modules ----------------- +- Issue #15973: Fix a segmentation fault when comparing datetime timezone + objects. + - Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 6df5c03..01c85d1 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -3215,6 +3215,12 @@ timezone_richcompare(PyDateTime_TimeZone *self, { if (op != Py_EQ && op != Py_NE) Py_RETURN_NOTIMPLEMENTED; + if (Py_TYPE(other) != &PyDateTime_TimeZoneType) { + if (op == Py_EQ) + Py_RETURN_FALSE; + else + Py_RETURN_TRUE; + } return delta_richcompare(self->offset, other->offset, op); } -- cgit v0.12 From bdc7e69f42fbb769f96fb970c9883a9a0c953b71 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 11 Sep 2012 14:03:25 +0200 Subject: Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap() --- Misc/NEWS | 2 ++ Objects/unicodeobject.c | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index f82da60..bd44af5 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ What's New in Python 3.3.0 Release Candidate 3? Core and Builtins ----------------- +- Issue #15900: Fixed reference leak in PyUnicode_TranslateCharmap(). + - Issue #15926: Fix crash after multiple reinitializations of the interpreter. - Issue #15895: Fix FILE pointer leak in one error branch of diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 773a9be..6d49806 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8585,10 +8585,13 @@ PyUnicode_TranslateCharmap(const Py_UNICODE *p, PyObject *mapping, const char *errors) { + PyObject *result; PyObject *unicode = PyUnicode_FromUnicode(p, size); if (!unicode) return NULL; - return _PyUnicode_TranslateCharmap(unicode, mapping, errors); + result = _PyUnicode_TranslateCharmap(unicode, mapping, errors); + Py_DECREF(unicode); + return result; } PyObject * @@ -8600,14 +8603,10 @@ PyUnicode_Translate(PyObject *str, str = PyUnicode_FromObject(str); if (str == NULL) - goto onError; + return NULL; result = _PyUnicode_TranslateCharmap(str, mapping, errors); Py_DECREF(str); return result; - - onError: - Py_XDECREF(str); - return NULL; } static Py_UCS4 -- cgit v0.12 From 19606411d32fb0f8107f2d7843cfe0f96cc48338 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Sep 2012 03:50:48 +0200 Subject: Fixed out-of-bounce write to rawmode buffer. The fixed size buffer wasn't enlarged for the new 'x' flag. The buffer may contain the 5 flags xrwa+ and the \0 byte --- Modules/_io/_iomodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 15781ac..0622c58 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -229,7 +229,7 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds) int creating = 0, reading = 0, writing = 0, appending = 0, updating = 0; int text = 0, binary = 0, universal = 0; - char rawmode[5], *m; + char rawmode[6], *m; int line_buffering, isatty; PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL; -- cgit v0.12 From 9471797cc634ed52c6fa7b35901f34c5595b0414 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Fri, 21 Sep 2012 09:30:19 -0700 Subject: Add What's New entries for some minor work I did in 3.3. --- Doc/whatsnew/3.3.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst index 9e68203..1895ce1 100644 --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -1322,7 +1322,7 @@ os files and directories, it is more reliable (and also faster) to manipulate file descriptors instead of file names. Python 3.3 enhances existing functions and introduces new functions to work on file descriptors (:issue:`4761`, - :issue:`10755`). + :issue:`10755` and :issue:`14626`). - The :mod:`os` module has a new :func:`~os.fwalk` function similar to :func:`~os.walk` except that it also yields file descriptors referring to the @@ -1355,6 +1355,12 @@ os Windows. (Contributed by Antoine Pitrou in :issue:`8828`.) +* The stat family of functions (:func:`~os.stat`, :func:`~os.fstat`, + and :func:`~os.lstat`) now support reading a file's timestamps + with nanosecond precision. Symmetrically, :func:`~os.utime` + can now write file timestamps with nanosecond precision. (Contributed by + Larry Hastings in :issue:`14127`.) + * The new :func:`os.get_terminal_size` function queries the size of the terminal attached to a file descriptor. See also :func:`shutil.get_terminal_size`. @@ -1474,6 +1480,11 @@ shutil path also specifying the user/group names and not only their numeric ids. (Contributed by Sandro Tosi in :issue:`12191`) +* :func:`~shutil.copy2` and :func:`~shutil.copystat` now preserve file + timestamps with nanosecond precision on platforms that support it. + They also preserve file "extended attributes" on Linux. (Contributed + by Larry Hastings in :issue:`14127` and :issue:`15238`.) + * The new :func:`shutil.get_terminal_size` function returns the size of the terminal window the interpreter is attached to. (Contributed by Zbigniew Jędrzejewski-Szmek in :issue:`13609`.) -- cgit v0.12 From dc07bac29efc1b8c9a2ae22a878e1b75bffc3f15 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Fri, 21 Sep 2012 09:40:41 -0700 Subject: Mention that "defaults" can be None for inspect.getfullargspec. Also minor formatting cleanups. --- Doc/library/inspect.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 9b7ae9c..83b7702 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -675,9 +675,9 @@ Classes and functions :term:`named tuple` ``ArgSpec(args, varargs, keywords, defaults)`` is returned. *args* is a list of the argument names. *varargs* and *keywords* are the names of the ``*`` and ``**`` arguments or ``None``. *defaults* is a - tuple of default argument values or None if there are no default arguments; - if this tuple has *n* elements, they correspond to the last *n* elements - listed in *args*. + tuple of default argument values or ``None`` if there are no default + arguments; if this tuple has *n* elements, they correspond to the last + *n* elements listed in *args*. .. deprecated:: 3.0 Use :func:`getfullargspec` instead, which provides information about @@ -693,8 +693,9 @@ Classes and functions annotations)`` *args* is a list of the argument names. *varargs* and *varkw* are the names - of the ``*`` and ``**`` arguments or ``None``. *defaults* is an n-tuple of - the default values of the last n arguments. *kwonlyargs* is a list of + of the ``*`` and ``**`` arguments or ``None``. *defaults* is an *n*-tuple + of the default values of the last *n* arguments, or ``None`` if there are no + default arguments. *kwonlyargs* is a list of keyword-only argument names. *kwonlydefaults* is a dictionary mapping names from kwonlyargs to defaults. *annotations* is a dictionary mapping argument names to annotations. -- cgit v0.12 From 60eba57f3e17f3d1dae8b31375a849ec7dfc34c6 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Fri, 21 Sep 2012 10:12:14 -0700 Subject: Cleanup/rewrite shutil docs regarding follow_symlinks and copying attributes. --- Doc/library/shutil.rst | 115 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 31 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 8ed7e9e..080c923 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -50,14 +50,15 @@ Directory and files operations .. function:: copyfile(src, dst, *, follow_symlinks=True) Copy the contents (no metadata) of the file named *src* to a file named - *dst* and return *dst*. *dst* must be the complete target file name; look at - :func:`shutil.copy` for a copy that accepts a target directory path. If - *src* and *dst* are the same files, :exc:`Error` is raised. + *dst* and return *dst*. *src* and *dst* are path names given as strings. + *dst* must be the complete target file name; look at :func:`shutil.copy` + for a copy that accepts a target directory path. If *src* and *dst* + specify the same file, :exc:`Error` is raised. - The destination location must be writable; otherwise, an :exc:`OSError` exception - will be raised. If *dst* already exists, it will be replaced. Special files - such as character or block devices and pipes cannot be copied with this - function. *src* and *dst* are path names given as strings. + The destination location must be writable; otherwise, an :exc:`OSError` + exception will be raised. If *dst* already exists, it will be replaced. + Special files such as character or block devices and pipes cannot be + copied with this function. If *follow_symlinks* is false and *src* is a symbolic link, a new symbolic link will be created instead of copying the @@ -71,52 +72,104 @@ Directory and files operations .. function:: copymode(src, dst, *, follow_symlinks=True) Copy the permission bits from *src* to *dst*. The file contents, owner, and - group are unaffected. *src* and *dst* are path names given as strings. If - *follow_symlinks* is false, *src* is a symbolic link, and the operating - system supports modes for symbolic links (for example BSD-based ones), - the mode of the link will be copied. + group are unaffected. *src* and *dst* are path names given as strings. + If *follow_symlinks* is false, and both *src* and *dst* are symbolic links, + :func:`copymode` will attempt to modify the mode of *dst* itself (rather + than the file it points to). This functionality is not available on every + platform; please see :func:`copystat` for more information. If + :func:`copymode` cannot modify symbolic links on the local platform, and it + is asked to do so, it will do nothing and return. .. versionchanged:: 3.3 Added *follow_symlinks* argument. .. function:: copystat(src, dst, *, follow_symlinks=True) - Copy the permission bits, last access time, last modification time, and flags - from *src* to *dst*. The file contents, owner, and group are unaffected. *src* - and *dst* are path names given as strings. If *follow_symlinks* is false, and - *src* and *dst* are both symbolic links, the stats of the link will be copied as - far as the platform allows. On Linux, :func:`copystat` also copies the - "extended attributes" where possible. + Copy the permission bits, last access time, last modification time, and + flags from *src* to *dst*. On Linux, :func:`copystat` also copies the + "extended attributes" where possible. The file contents, owner, and + group are unaffected. *src* and *dst* are path names given as strings. + + If *follow_symlinks* is false, and *src* and *dst* both + refer to symbolic links, :func:`copystat` will operate on + the symbolic links themselves rather than the files the + symbolic links refer to--reading the information from the + *src* symbolic link, and writing the information to the + *dst* symbolic link. + + .. note:: + + Not all platforms provide the ability to examine and + modify symbolic links. Python itself can tell you what + functionality is locally available. + + * If ``os.chmod in os.supports_follow_symlinks`` is + ``True``, :func:`copystat` can modify the permission + bits of a symbolic link. + + * If ``os.utime in os.supports_follow_symlinks`` is + ``True``, :func:`copystat` can modify the last access + and modification times of a symbolic link. + + * If ``os.chflags in os.supports_follow_symlinks`` is + ``True``, :func:`copystat` can modify the flags of + a symbolic link. (``os.chflags`` is not available on + all platforms.) + + On platforms where some or all of this functionality + is unavailable, when asked to modify a symbolic link, + :func:`copystat` will copy everything it can. + :func:`copystat` never returns failure. + + Please see :data:`os.supports_follow_symlinks` + for more information. .. versionchanged:: 3.3 Added *follow_symlinks* argument and support for Linux extended attributes. .. function:: copy(src, dst, *, follow_symlinks=True) - Copy the file *src* to the file or directory *dst* and return the file's - destination. If *dst* is a directory, a - file with the same basename as *src* is created (or overwritten) in the - directory specified. Permission bits are copied. *src* and *dst* are path - names given as strings. If *follow_symlinks* is false, symbolic - links won't be followed but recreated instead -- this resembles GNU's - :program:`cp -P`. + Copies the file *src* to the file or directory *dst*. *src* and *dst* + should be strings. If *dst* specifies a directory, the file will be + copied into *dst* using the base filename from *src*. Returns the + path to the newly created file. + + If *follow_symlinks* is false, and *src* is a symbolic link, + *dst* will be created as a symbolic link. If *follow_symlinks* + is true and *src* is a symbolic link, *dst* will be a copy of + the file *src* refers to. + + :func:`copy` copies the file data and the file's permission + mode (see :func:`os.chmod`). Other metadata, like the + file's creation and modification times, is not preserved. + To preserve all file metadata from the original, use + :func:`~shutil.copy2` instead. .. versionchanged:: 3.3 Added *follow_symlinks* argument. - Now returns *dst*. + Now returns path to the newly created file. .. function:: copy2(src, dst, *, follow_symlinks=True) - Similar to :func:`shutil.copy`, including that the destination is - returned, but metadata is copied as well. This is similar to the Unix - command :program:`cp -p`. If *follow_symlinks* is false, - symbolic links won't be followed but recreated instead -- this resembles - GNU's :program:`cp -P`. + Identical to :func:`~shutil.copy` except that :func:`copy2` + also attempts to preserve all file metadata. + + When *follow_symlinks* is false, and *src* is a symbolic + link, :func:`copy2` attempts to copy all metadata from the + *src* symbolic link to the newly-created *dst* symbolic link. + However, this functionality is not available on all platforms. + On platforms where some or all of this functionality is + unavailable, :func:`copy2` will preserve all the metadata + it can; :func:`copy2` never returns failure. + + :func:`copy2` uses :func:`copystat` to copy the file metadata. + Please see :func:`copystat` for more information + about platform support for modifying symbolic link metadata. .. versionchanged:: 3.3 Added *follow_symlinks* argument, try to copy extended file system attributes too (currently Linux only). - Now returns *dst*. + Now returns path to the newly created file. .. function:: ignore_patterns(\*patterns) -- cgit v0.12 From be232923e48630235da0939f5a47a3dd5908779f Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 23 Sep 2012 11:17:01 +0200 Subject: Fix issue number. --- Misc/NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index bd44af5..957ee60 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -39,7 +39,7 @@ Extension Modules - Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times, thanks to Daniel Sommermann. -- Issue #5969: faulthandler module: rename dump_tracebacks_later() to +- Issue #15969: faulthandler module: rename dump_tracebacks_later() to dump_traceback_later() and cancel_dump_tracebacks_later() to cancel_dump_traceback_later(). -- cgit v0.12 From fd3023649459c5eac49f401335d43a9587da5e71 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Sep 2012 11:48:41 +0200 Subject: Fixed memory leak in error branch of formatfloat(). CID 719687 --- Objects/unicodeobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6d49806..34a934d 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13237,8 +13237,10 @@ formatfloat(PyObject *v, int flags, int prec, int type, return -1; len = strlen(p); if (writer) { - if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) + if (_PyUnicodeWriter_Prepare(writer, len, 127) == -1) { + PyMem_Free(p); return -1; + } unicode_write_cstr(writer->buffer, writer->pos, p, len); writer->pos += len; } -- cgit v0.12 From 8f734ebe94fec52380789a5f1c95a531378db024 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Sep 2012 17:46:09 +0200 Subject: Fixed reference leak in error branch of _bufferedreader_read_all(). The variable data can contain a bytes object but it wasn't cleaned up when PyList_New() failed. CID 715364 --- Modules/_io/bufferedio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 67b7cc4..334734b 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1499,8 +1499,10 @@ _bufferedreader_read_all(buffered *self) } chunks = PyList_New(0); - if (chunks == NULL) + if (chunks == NULL) { + Py_XDECREF(data); return NULL; + } while (1) { if (data) { -- cgit v0.12 From f817a7b178e945b4261f2ddee067ae849dfbc5ec Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Sun, 23 Sep 2012 15:46:09 +0200 Subject: Use C-style comments. --- Modules/_decimal/libmpdec/mpdecimal.c | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c index 0558d5e..05f7628 100644 --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -5063,28 +5063,28 @@ _karatsuba_rec(mpd_uint_t *c, const mpd_uint_t *a, const mpd_uint_t *b, return; } - m = (la+1)/2; // ceil(la/2) + m = (la+1)/2; /* ceil(la/2) */ /* lb <= m < la */ if (lb <= m) { /* lb can now be larger than la-m */ if (lb > la-m) { - lt = lb + lb + 1; // space needed for result array - mpd_uint_zero(w, lt); // clear result array - _karatsuba_rec(w, b, a+m, w+lt, lb, la-m); // b*ah + lt = lb + lb + 1; /* space needed for result array */ + mpd_uint_zero(w, lt); /* clear result array */ + _karatsuba_rec(w, b, a+m, w+lt, lb, la-m); /* b*ah */ } else { - lt = (la-m) + (la-m) + 1; // space needed for result array - mpd_uint_zero(w, lt); // clear result array - _karatsuba_rec(w, a+m, b, w+lt, la-m, lb); // ah*b + lt = (la-m) + (la-m) + 1; /* space needed for result array */ + mpd_uint_zero(w, lt); /* clear result array */ + _karatsuba_rec(w, a+m, b, w+lt, la-m, lb); /* ah*b */ } - _mpd_baseaddto(c+m, w, (la-m)+lb); // add ah*b*B**m + _mpd_baseaddto(c+m, w, (la-m)+lb); /* add ah*b*B**m */ - lt = m + m + 1; // space needed for the result array - mpd_uint_zero(w, lt); // clear result array - _karatsuba_rec(w, a, b, w+lt, m, lb); // al*b - _mpd_baseaddto(c, w, m+lb); // add al*b + lt = m + m + 1; /* space needed for the result array */ + mpd_uint_zero(w, lt); /* clear result array */ + _karatsuba_rec(w, a, b, w+lt, m, lb); /* al*b */ + _mpd_baseaddto(c, w, m+lb); /* add al*b */ return; } @@ -5360,34 +5360,34 @@ _karatsuba_rec_fnt(mpd_uint_t *c, const mpd_uint_t *a, const mpd_uint_t *b, return 1; } - m = (la+1)/2; // ceil(la/2) + m = (la+1)/2; /* ceil(la/2) */ /* lb <= m < la */ if (lb <= m) { /* lb can now be larger than la-m */ if (lb > la-m) { - lt = lb + lb + 1; // space needed for result array - mpd_uint_zero(w, lt); // clear result array - if (!_karatsuba_rec_fnt(w, b, a+m, w+lt, lb, la-m)) { // b*ah + lt = lb + lb + 1; /* space needed for result array */ + mpd_uint_zero(w, lt); /* clear result array */ + if (!_karatsuba_rec_fnt(w, b, a+m, w+lt, lb, la-m)) { /* b*ah */ return 0; /* GCOV_UNLIKELY */ } } else { - lt = (la-m) + (la-m) + 1; // space needed for result array - mpd_uint_zero(w, lt); // clear result array - if (!_karatsuba_rec_fnt(w, a+m, b, w+lt, la-m, lb)) { // ah*b + lt = (la-m) + (la-m) + 1; /* space needed for result array */ + mpd_uint_zero(w, lt); /* clear result array */ + if (!_karatsuba_rec_fnt(w, a+m, b, w+lt, la-m, lb)) { /* ah*b */ return 0; /* GCOV_UNLIKELY */ } } - _mpd_baseaddto(c+m, w, (la-m)+lb); // add ah*b*B**m + _mpd_baseaddto(c+m, w, (la-m)+lb); /* add ah*b*B**m */ - lt = m + m + 1; // space needed for the result array - mpd_uint_zero(w, lt); // clear result array - if (!_karatsuba_rec_fnt(w, a, b, w+lt, m, lb)) { // al*b + lt = m + m + 1; /* space needed for the result array */ + mpd_uint_zero(w, lt); /* clear result array */ + if (!_karatsuba_rec_fnt(w, a, b, w+lt, m, lb)) { /* al*b */ return 0; /* GCOV_UNLIKELY */ } - _mpd_baseaddto(c, w, m+lb); // add al*b + _mpd_baseaddto(c, w, m+lb); /* add al*b */ return 1; } -- cgit v0.12 From a4b4dea4150631c3390f6bd85cb4e0f845434396 Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Sun, 23 Sep 2012 15:51:16 +0200 Subject: Use C-style comments (required for the AIX build slave). --- Modules/unicodedata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 5c982f5..d339f58 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -1236,8 +1236,8 @@ unicodedata_lookup(PyObject* self, PyObject* args) PyErr_Format(PyExc_KeyError, "undefined character name '%s'", name); return NULL; } - // check if code is in the PUA range that we use for named sequences - // and convert it + /* check if code is in the PUA range that we use for named sequences + and convert it */ if (IS_NAMED_SEQ(code)) { index = code-named_sequences_start; return PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, -- cgit v0.12 From b8cd700155960ef720d4a8845fccf9d9f55ce105 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 23 Sep 2012 16:11:15 +0200 Subject: Use C-style comments for C89 / ANSI C compatibility --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 54f6cd2..55aeb61 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -10488,7 +10488,7 @@ posix_listxattr(PyObject *self, PyObject *args, PyObject *kwargs) static Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 }; Py_ssize_t buffer_size = buffer_sizes[i]; if (!buffer_size) { - // ERANGE + /* ERANGE */ path_error("listxattr", &path); break; } -- cgit v0.12 From ab816b5c85aeb4cf09542265423e68354a236bb3 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 23 Sep 2012 16:15:01 +0200 Subject: GCC doesn't support typeof in strict ansi mode (e.g. -ansi or -std=c89) --- Include/pymacro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/pymacro.h b/Include/pymacro.h index 1dc0c61..f3001f4 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -30,7 +30,7 @@ error (see Py_BUILD_ASSERT_EXPR). Written by Rusty Russell, public domain, http://ccodearchive.net/ */ -#if defined(__GNUC__) +#if (defined(__GNUC__) && !defined(__STRICT_ANSI__)) /* Two gcc extensions. &a[0] degrades to a pointer: a different type from an array */ #define Py_ARRAY_LENGTH(array) \ -- cgit v0.12 From 6147515d02f0c2961f3bf5fd93a85cc512b18c95 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 23 Sep 2012 17:11:26 +0200 Subject: Add news entries for recent changes. --- Misc/NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 957ee60..b38d088 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -18,6 +18,8 @@ Core and Builtins PyRun_SimpleFileExFlags() when filename points to a pyc/pyo file, closeit is false an and set_main_loader() fails. +- Fixes for a few crash and memory leak regressions found by Coverity. + Library ------- @@ -43,6 +45,7 @@ Extension Modules dump_traceback_later() and cancel_dump_tracebacks_later() to cancel_dump_traceback_later(). +- _decimal module: use only C 89 style comments. What's New in Python 3.3.0 Release Candidate 2? =============================================== -- cgit v0.12 From 8506d3591cb49d2ccda1d452cf04463274f5349d Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 23 Sep 2012 17:15:21 +0200 Subject: Bump to 3.3.0rc3. --- Include/patchlevel.h | 4 ++-- Lib/distutils/__init__.py | 2 +- Lib/idlelib/idlever.py | 2 +- Misc/NEWS | 6 +++--- Misc/RPM/python-3.3.spec | 2 +- README | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h index ba0b566..78b18fd 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -20,10 +20,10 @@ #define PY_MINOR_VERSION 3 #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 2 +#define PY_RELEASE_SERIAL 3 /* Version as a string */ -#define PY_VERSION "3.3.0rc2+" +#define PY_VERSION "3.3.0rc3" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py index f23d886..b755eaa 100644 --- a/Lib/distutils/__init__.py +++ b/Lib/distutils/__init__.py @@ -13,5 +13,5 @@ used from a setup script as # Updated automatically by the Python release process. # #--start constants-- -__version__ = "3.3.0rc2" +__version__ = "3.3.0rc3" #--end constants-- diff --git a/Lib/idlelib/idlever.py b/Lib/idlelib/idlever.py index b73ce75..ff6cb72 100644 --- a/Lib/idlelib/idlever.py +++ b/Lib/idlelib/idlever.py @@ -1 +1 @@ -IDLE_VERSION = "3.3.0rc2" +IDLE_VERSION = "3.3.0rc3" diff --git a/Misc/NEWS b/Misc/NEWS index b38d088..c0bfcce 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1,11 +1,11 @@ -s+++++++++++ ++++++++++++ Python News +++++++++++ What's New in Python 3.3.0 Release Candidate 3? -=========================== +=============================================== -*Release date: XX-Sep-2012* +*Release date: 23-Sep-2012* Core and Builtins ----------------- diff --git a/Misc/RPM/python-3.3.spec b/Misc/RPM/python-3.3.spec index ab21f96..ce21695 100644 --- a/Misc/RPM/python-3.3.spec +++ b/Misc/RPM/python-3.3.spec @@ -39,7 +39,7 @@ %define name python #--start constants-- -%define version 3.3.0rc2 +%define version 3.3.0rc3 %define libvers 3.3 #--end constants-- %define release 1pydotorg diff --git a/README b/README index 81f0d20..19451ab 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is Python version 3.3.0 release candidate 2 +This is Python version 3.3.0 release candidate 3 ================================================ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, -- cgit v0.12 From 700765fe914a0998056dea5e588458441532fc3e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 23 Sep 2012 17:15:25 +0200 Subject: Added tag v3.3.0rc3 for changeset c191d21cefaf --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 3df57b7..080b6c6 100644 --- a/.hgtags +++ b/.hgtags @@ -107,3 +107,4 @@ e15c554cd43eb23bc0a528a4e8741da9bbec9607 v3.3.0b1 4972a8f1b2aa3d7cdd64dc96aa7fa112fe1ea343 v3.3.0b2 8bb5c7bc46ba43804480f3e328e1fa956672c885 v3.3.0rc1 88a0792e8ba3e4916b24c7e7a522c277d326d66e v3.3.0rc2 +c191d21cefafb3832c45570e84854e309aa62eaa v3.3.0rc3 -- cgit v0.12 From f2487177eba8c8e88ab3c11344720f4df6000d72 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 24 Sep 2012 07:42:20 +0200 Subject: Post-release updates. --- Include/patchlevel.h | 2 +- Misc/NEWS | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Include/patchlevel.h b/Include/patchlevel.h index 78b18fd..d977d3f 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -23,7 +23,7 @@ #define PY_RELEASE_SERIAL 3 /* Version as a string */ -#define PY_VERSION "3.3.0rc3" +#define PY_VERSION "3.3.0rc3+" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/Misc/NEWS b/Misc/NEWS index c0bfcce..bdab245 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2,6 +2,18 @@ Python News +++++++++++ +What's New in Python 3.3.0? +=========================== + +*Release date: XX-Sep-2012* + +Core and Builtins +----------------- + +Library +------- + + What's New in Python 3.3.0 Release Candidate 3? =============================================== -- cgit v0.12