From e26d3af7ee5b8ce804786d31ecfda173d92d7ab0 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 24 Sep 2012 13:17:08 +0200 Subject: Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD() method doesn't require an argument again. --- Lib/test/test_pyexpat.py | 10 ++++++++++ Misc/NEWS | 3 +++ Modules/pyexpat.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py index 27eecb8..117bda0 100644 --- a/Lib/test/test_pyexpat.py +++ b/Lib/test/test_pyexpat.py @@ -641,6 +641,16 @@ class ForeignDTDTests(unittest.TestCase): parser.Parse("") self.assertEqual(handler_call_args, [(None, None)]) + # test UseForeignDTD() is equal to UseForeignDTD(True) + handler_call_args[:] = [] + + parser = expat.ParserCreate() + parser.UseForeignDTD() + parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS) + parser.ExternalEntityRefHandler = resolve_entity + parser.Parse("") + self.assertEqual(handler_call_args, [(None, None)]) + def test_ignore_use_foreign_dtd(self): """ If UseForeignDTD is passed True and a document with an external diff --git a/Misc/NEWS b/Misc/NEWS index 57ed006..3283117 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -482,6 +482,9 @@ Library Extension Modules ----------------- +- Issue #16012: Fix a regression in pyexpat. The parser's UseForeignDTD() + method doesn't require an argument again. + - Issue #15676: Now "mmap" check for empty files before doing the offset check. Patch by Steven Willis. diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index c965ff4..4b9687a 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1035,7 +1035,7 @@ xmlparse_UseForeignDTD(xmlparseobject *self, PyObject *args) PyObject *flagobj = NULL; int flag = 1; enum XML_Error rc; - if (!PyArg_ParseTuple(args, "O:UseForeignDTD", &flagobj)) + if (!PyArg_ParseTuple(args, "|O:UseForeignDTD", &flagobj)) return NULL; if (flagobj != NULL) { flag = PyObject_IsTrue(flagobj); -- cgit v0.12