cpython: e67b3a9bd2dc (original) (raw)
Mercurial > cpython
changeset 75375:e67b3a9bd2dc
- Issue #14177: marshal.loads() now raises TypeError when given an unicode string. Patch by Guilherme Gonçalves. [#14177]
Antoine Pitrou solipsis@pitrou.net | |
---|---|
date | Sat, 03 Mar 2012 02:38:37 +0100 |
parents | 8ec51b2e57c2(current diff)4966907d3661(diff) |
children | 58eef400866e |
files | Lib/test/test_exceptions.py Lib/test/test_marshal.py Misc/ACKS Misc/NEWS Python/marshal.c |
diffstat | 5 files changed, 15 insertions(+), 6 deletions(-)[+] [-] Lib/test/test_exceptions.py 2 Lib/test/test_marshal.py 7 Misc/ACKS 1 Misc/NEWS 3 Python/marshal.c 8 |
line wrap: on
line diff
--- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -38,7 +38,7 @@ class ExceptionTests(unittest.TestCase): try: try: import marshal
marshal.loads('')[](#l1.7)
marshal.loads(b'')[](#l1.8) except EOFError:[](#l1.9) pass[](#l1.10) finally:[](#l1.11)
--- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -201,7 +201,7 @@ class BugsTestCase(unittest.TestCase): pass def test_loads_recursion(self):
s = 'c' + ('X' * 4*4) + '{' * 2**20[](#l2.7)
s = b'c' + (b'X' * 4*4) + b'{' * 2**20[](#l2.8) self.assertRaises(ValueError, marshal.loads, s)[](#l2.9)
def test_recursion_limit(self): @@ -274,6 +274,11 @@ class BugsTestCase(unittest.TestCase): finally: support.unlink(support.TESTFN)
- def test_loads_reject_unicode_strings(self):
# Issue #14177: marshal.loads() should not accept unicode strings[](#l2.17)
unicode_string = 'T'[](#l2.18)
self.assertRaises(TypeError, marshal.loads, unicode_string)[](#l2.19)
+ def test_main(): support.run_unittest(IntTestCase,
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -371,6 +371,7 @@ Yannick Gingras Michael Goderbauer Christoph Gohlke Tim Golden +Guilherme Gonçalves Tiago Gonçalves Chris Gonnerman David Goodger
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -511,6 +511,9 @@ Core and Builtins Library ------- +- Issue #14177: marshal.loads() now raises TypeError when given an unicode
- Issue #13550: Remove the debug machinery from the threading module: remove verbose arguments from all threading classes and functions.
--- a/Python/marshal.c +++ b/Python/marshal.c @@ -1384,7 +1384,7 @@ marshal_loads(PyObject *self, PyObject * char s; Py_ssize_t n; PyObject result;
- if (!PyArg_ParseTuple(args, "y*:loads", &p)) return NULL; s = p.buf; n = p.len; @@ -1400,10 +1400,10 @@ marshal_loads(PyObject *self, PyObject * }
PyDoc_STRVAR(loads_doc, -"loads(string)\n[](#l5.16) +"loads(bytes)\n[](#l5.17) \n[](#l5.18) -Convert the string to a value. If no valid value is found, raise\n[](#l5.19) -EOFError, ValueError or TypeError. Extra characters in the string are\n[](#l5.20) +Convert the bytes object to a value. If no valid value is found, raise\n[](#l5.21) +EOFError, ValueError or TypeError. Extra characters in the input are\n[](#l5.22) ignored."); static PyMethodDef marshal_methods[] = {