summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2004-12-20 12:26:43 +0000
committerArmin Rigo <arigo@tunes.org>2004-12-20 12:26:43 +0000
commit19dd32cbcee05c86aabc54ef041ab539058165a2 (patch)
tree8ed482910c06c2b556cc908e27ee4a2ddc6614c5
parent7b5b139e32b8ac4507a24baf46fd56d7d888b6cd (diff)
downloadcpython-19dd32cbcee05c86aabc54ef041ab539058165a2.tar.gz
Back-ported: marshal.dumps() with the new optional argument 'version' just
immediately segfaults, due to a typo!
-rw-r--r--Doc/lib/libmarshal.tex6
-rw-r--r--Lib/test/test_marshal.py5
-rw-r--r--Python/marshal.c2
3 files changed, 9 insertions, 4 deletions
diff --git a/Doc/lib/libmarshal.tex b/Doc/lib/libmarshal.tex
index 53ca668856..d3dd835347 100644
--- a/Doc/lib/libmarshal.tex
+++ b/Doc/lib/libmarshal.tex
@@ -62,7 +62,7 @@ operating on strings.
The module defines these functions:
-\begin{funcdesc}{dump}{value, file}
+\begin{funcdesc}{dump}{value, file\optional{, version}}
Write the value on the open file. The value must be a supported
type. The file must be an open file object such as
\code{sys.stdout} or returned by \function{open()} or
@@ -75,7 +75,7 @@ The module defines these functions:
read back by \function{load()}.
\versionadded[The \var{version} argument indicates the data
- format that \code{dumps} should use.]{2.4}
+ format that \code{dump} should use (see below)]{2.4}
\end{funcdesc}
\begin{funcdesc}{load}{file}
@@ -96,7 +96,7 @@ The module defines these functions:
contains an object that has) an unsupported type.
\versionadded[The \var{version} argument indicates the data
- format that \code{dumps} should use.]{2.4}
+ format that \code{dumps} should use (see below)]{2.4}
\end{funcdesc}
\begin{funcdesc}{loads}{string}
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index eb07521788..5c1a3f3c6d 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -180,6 +180,11 @@ class BugsTestCase(unittest.TestCase):
self.assertRaises(Exception, marshal.loads, 'f')
self.assertRaises(Exception, marshal.loads, marshal.dumps(5L)[:-1])
+ def test_version_argument(self):
+ # Python 2.4.0 crashes for any call to marshal.dumps(x, y)
+ self.assertEquals(marshal.loads(marshal.dumps(5, 0)), 5)
+ self.assertEquals(marshal.loads(marshal.dumps(5, 1)), 5)
+
def test_main():
test_support.run_unittest(IntTestCase,
FloatTestCase,
diff --git a/Python/marshal.c b/Python/marshal.c
index 590e1ca391..0ab0597d32 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -893,7 +893,7 @@ marshal_dumps(PyObject *self, PyObject *args)
{
PyObject *x;
int version = Py_MARSHAL_VERSION;
- if (!PyArg_ParseTuple(args, "O|i:dumps", &x, version))
+ if (!PyArg_ParseTuple(args, "O|i:dumps", &x, &version))
return NULL;
return PyMarshal_WriteObjectToString(x, version);
}