mirror of https://github.com/python/cpython
bpo-39495: Remove default value from C impl of TreeBuilder.start (GH-18275)
This commit is contained in:
parent
1f577ce363
commit
4edc95cf0a
|
@ -2259,6 +2259,10 @@ class BugsTest(unittest.TestCase):
|
|||
text = text[6:-4]
|
||||
self.assertEqual(root.get('b'), text)
|
||||
|
||||
def test_39495_treebuilder_start(self):
|
||||
self.assertRaises(TypeError, ET.TreeBuilder().start, "tag")
|
||||
self.assertRaises(TypeError, ET.TreeBuilder().start, "tag", None)
|
||||
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Remove default value from *attrs* parameter of :meth:`xml.etree.ElementTree.TreeBuilder.start` for consistency between Python and C implementations.
|
|
@ -3038,7 +3038,7 @@ _elementtree_TreeBuilder_close_impl(TreeBuilderObject *self)
|
|||
_elementtree.TreeBuilder.start
|
||||
|
||||
tag: object
|
||||
attrs: object = None
|
||||
attrs: object(subclass_of='&PyDict_Type')
|
||||
/
|
||||
|
||||
[clinic start generated code]*/
|
||||
|
@ -3046,7 +3046,7 @@ _elementtree.TreeBuilder.start
|
|||
static PyObject *
|
||||
_elementtree_TreeBuilder_start_impl(TreeBuilderObject *self, PyObject *tag,
|
||||
PyObject *attrs)
|
||||
/*[clinic end generated code: output=e7e9dc2861349411 input=95fc1758dd042c65]*/
|
||||
/*[clinic end generated code: output=e7e9dc2861349411 input=7288e9e38e63b2b6]*/
|
||||
{
|
||||
return treebuilder_handle_start(self, tag, attrs);
|
||||
}
|
||||
|
|
|
@ -761,7 +761,7 @@ _elementtree_TreeBuilder_close(TreeBuilderObject *self, PyObject *Py_UNUSED(igno
|
|||
}
|
||||
|
||||
PyDoc_STRVAR(_elementtree_TreeBuilder_start__doc__,
|
||||
"start($self, tag, attrs=None, /)\n"
|
||||
"start($self, tag, attrs, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
|
@ -777,17 +777,17 @@ _elementtree_TreeBuilder_start(TreeBuilderObject *self, PyObject *const *args, P
|
|||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *tag;
|
||||
PyObject *attrs = Py_None;
|
||||
PyObject *attrs;
|
||||
|
||||
if (!_PyArg_CheckPositional("start", nargs, 1, 2)) {
|
||||
if (!_PyArg_CheckPositional("start", nargs, 2, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
tag = args[0];
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
if (!PyDict_Check(args[1])) {
|
||||
_PyArg_BadArgument("start", "argument 2", "dict", args[1]);
|
||||
goto exit;
|
||||
}
|
||||
attrs = args[1];
|
||||
skip_optional:
|
||||
return_value = _elementtree_TreeBuilder_start_impl(self, tag, attrs);
|
||||
|
||||
exit:
|
||||
|
@ -916,4 +916,4 @@ skip_optional:
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=bee26d0735a3fddc input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=3ad029ba71f5ae39 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Reference in New Issue