]> granicus.if.org Git - python/commitdiff
ParserCreate(): Added test that the namespace_separator value, if given,
authorFred Drake <fdrake@acm.org>
Sun, 29 Oct 2000 04:57:53 +0000 (04:57 +0000)
committerFred Drake <fdrake@acm.org>
Sun, 29 Oct 2000 04:57:53 +0000 (04:57 +0000)
                 has the required length.

initpyexpat():  Provide the type object for the ParserCreate() return
                value as XMLParserType.

Modules/pyexpat.c

index 543648bf9d42e8d434b65926fd9c978b6f08744e..35530cf870a685004a9c49ac3125d97d8d08780c 100644 (file)
@@ -826,6 +826,13 @@ pyexpat_ParserCreate(PyObject *notused, PyObject *args, PyObject *kw)
        if (!PyArg_ParseTupleAndKeywords(args, kw, "|zz:ParserCreate", kwlist,
                                         &encoding, &namespace_separator))
                return NULL;
+       if (namespace_separator != NULL
+           && strlen(namespace_separator) != 1) {
+               PyErr_SetString(PyExc_ValueError,
+                               "namespace_separator must be one character,"
+                               " omitted, or None");
+               return NULL;
+       }
        return (PyObject *)newxmlparseobject(encoding, namespace_separator);
 }
 
@@ -913,6 +920,8 @@ initpyexpat(void)
         ErrorObject = PyErr_NewException("xml.parsers.expat.error",
                                          NULL, NULL);
     PyModule_AddObject(m, "error", ErrorObject);
+    Py_INCREF(&Xmlparsetype);
+    PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
 
     PyModule_AddObject(m, "__version__",
                        PyString_FromStringAndSize(rev+11, strlen(rev+11)-2));