[pypy-svn] r63118 - pypy/trunk/pypy/module/pyexpat
afa at codespeak.net
afa at codespeak.net
Fri Mar 20 10:28:40 CET 2009
Author: afa
Date: Fri Mar 20 10:28:40 2009
New Revision: 63118
Modified:
pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py
Log:
Give more precise error messages in ParseCreate
This fixes the output of test_pyexpat.
Modified: pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py
==============================================================================
--- pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py (original)
+++ pypy/trunk/pypy/module/pyexpat/interp_pyexpat.py Fri Mar 20 10:28:40 2009
@@ -574,12 +574,18 @@
Return a new XML parser object."""
if space.is_w(w_encoding, space.w_None):
encoding = None
- else:
+ elif space.is_true(space.isinstance(w_encoding, space.w_str)):
encoding = space.str_w(w_encoding)
+ else:
+ type_name = space.type(w_encoding).getname(space, '?')
+ raise OperationError(
+ space.w_TypeError,
+ space.wrap('ParserCreate() argument 1 must be string or None,'
+ ' not %s' % (type_name,)))
if space.is_w(w_namespace_separator, space.w_None):
namespace_separator = 0
- else:
+ elif space.is_true(space.isinstance(w_namespace_separator, space.w_str)):
separator = space.str_w(w_namespace_separator)
if len(separator) == 0:
namespace_separator = 0
@@ -590,6 +596,13 @@
space.w_ValueError,
space.wrap('namespace_separator must be at most one character,'
' omitted, or None'))
+ else:
+ type_name = space.type(w_namespace_separator).getname(space, '?')
+ raise OperationError(
+ space.w_TypeError,
+ space.wrap('ParserCreate() argument 2 must be string or None,'
+ ' not %s' % (type_name,)))
+
if w_intern is None:
w_intern = space.newdict()
More information about the Pypy-commit
mailing list