[pypy-svn] r56361 - in pypy/dist/pypy/lib: . app_test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Jul 7 23:16:44 CEST 2008
Author: cfbolz
Date: Mon Jul 7 23:16:43 2008
New Revision: 56361
Modified:
pypy/dist/pypy/lib/app_test/test_pyexpat.py
pypy/dist/pypy/lib/pyexpat.py
Log:
Better error-checking for ParserCreate (before you could segfault pypy).
Modified: pypy/dist/pypy/lib/app_test/test_pyexpat.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/test_pyexpat.py (original)
+++ pypy/dist/pypy/lib/app_test/test_pyexpat.py Mon Jul 7 23:16:43 2008
@@ -643,3 +643,6 @@
assert parser.buffer_size == 1024
parser.Parse(xml2, 1)
assert self.n == 4
+
+ def test_segfault(self):
+ py.test.raises(TypeError, expat.ParserCreate, 1234123123)
Modified: pypy/dist/pypy/lib/pyexpat.py
==============================================================================
--- pypy/dist/pypy/lib/pyexpat.py (original)
+++ pypy/dist/pypy/lib/pyexpat.py Mon Jul 7 23:16:43 2008
@@ -436,6 +436,9 @@
xxx
def ParserCreate(encoding=None, namespace_separator=None, intern=None):
+ if (not isinstance(encoding, str) and
+ not encoding is None):
+ raise TypeError("ParserCreate() argument 1 must be string or None, not %s" % encoding.__class__.__name__)
if (not isinstance(namespace_separator, str) and
not namespace_separator is None):
raise TypeError("ParserCreate() argument 2 must be string or None, not %s" % namespace_separator.__class__.__name__)
More information about the Pypy-commit
mailing list