LCOV - code coverage report
Current view: top level - Modules/clinic - pyexpat.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 150 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 10 0.0 %
Branches: 0 116 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__,
      12                 :            : "Parse($self, data, isfinal=False, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Parse XML data.\n"
      16                 :            : "\n"
      17                 :            : "`isfinal\' should be true at end of input.");
      18                 :            : 
      19                 :            : #define PYEXPAT_XMLPARSER_PARSE_METHODDEF    \
      20                 :            :     {"Parse", _PyCFunction_CAST(pyexpat_xmlparser_Parse), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__},
      21                 :            : 
      22                 :            : static PyObject *
      23                 :            : pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls,
      24                 :            :                              PyObject *data, int isfinal);
      25                 :            : 
      26                 :            : static PyObject *
      27                 :          0 : pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      28                 :            : {
      29                 :          0 :     PyObject *return_value = NULL;
      30                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      31                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
      32                 :            :     #else
      33                 :            :     #  define KWTUPLE NULL
      34                 :            :     #endif
      35                 :            : 
      36                 :            :     static const char * const _keywords[] = {"", "", NULL};
      37                 :            :     static _PyArg_Parser _parser = {
      38                 :            :         .keywords = _keywords,
      39                 :            :         .fname = "Parse",
      40                 :            :         .kwtuple = KWTUPLE,
      41                 :            :     };
      42                 :            :     #undef KWTUPLE
      43                 :            :     PyObject *argsbuf[2];
      44                 :            :     PyObject *data;
      45                 :          0 :     int isfinal = 0;
      46                 :            : 
      47   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             #  #  #  # ]
      48         [ #  # ]:          0 :     if (!args) {
      49                 :          0 :         goto exit;
      50                 :            :     }
      51                 :          0 :     data = args[0];
      52         [ #  # ]:          0 :     if (nargs < 2) {
      53                 :          0 :         goto skip_optional_posonly;
      54                 :            :     }
      55                 :          0 :     isfinal = PyObject_IsTrue(args[1]);
      56         [ #  # ]:          0 :     if (isfinal < 0) {
      57                 :          0 :         goto exit;
      58                 :            :     }
      59                 :          0 : skip_optional_posonly:
      60                 :          0 :     return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal);
      61                 :            : 
      62                 :          0 : exit:
      63                 :          0 :     return return_value;
      64                 :            : }
      65                 :            : 
      66                 :            : PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__,
      67                 :            : "ParseFile($self, file, /)\n"
      68                 :            : "--\n"
      69                 :            : "\n"
      70                 :            : "Parse XML data from file-like object.");
      71                 :            : 
      72                 :            : #define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF    \
      73                 :            :     {"ParseFile", _PyCFunction_CAST(pyexpat_xmlparser_ParseFile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__},
      74                 :            : 
      75                 :            : static PyObject *
      76                 :            : pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls,
      77                 :            :                                  PyObject *file);
      78                 :            : 
      79                 :            : static PyObject *
      80                 :          0 : pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      81                 :            : {
      82                 :          0 :     PyObject *return_value = NULL;
      83                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      84                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
      85                 :            :     #else
      86                 :            :     #  define KWTUPLE NULL
      87                 :            :     #endif
      88                 :            : 
      89                 :            :     static const char * const _keywords[] = {"", NULL};
      90                 :            :     static _PyArg_Parser _parser = {
      91                 :            :         .keywords = _keywords,
      92                 :            :         .fname = "ParseFile",
      93                 :            :         .kwtuple = KWTUPLE,
      94                 :            :     };
      95                 :            :     #undef KWTUPLE
      96                 :            :     PyObject *argsbuf[1];
      97                 :            :     PyObject *file;
      98                 :            : 
      99   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     100         [ #  # ]:          0 :     if (!args) {
     101                 :          0 :         goto exit;
     102                 :            :     }
     103                 :          0 :     file = args[0];
     104                 :          0 :     return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file);
     105                 :            : 
     106                 :          0 : exit:
     107                 :          0 :     return return_value;
     108                 :            : }
     109                 :            : 
     110                 :            : PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__,
     111                 :            : "SetBase($self, base, /)\n"
     112                 :            : "--\n"
     113                 :            : "\n"
     114                 :            : "Set the base URL for the parser.");
     115                 :            : 
     116                 :            : #define PYEXPAT_XMLPARSER_SETBASE_METHODDEF    \
     117                 :            :     {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_O, pyexpat_xmlparser_SetBase__doc__},
     118                 :            : 
     119                 :            : static PyObject *
     120                 :            : pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base);
     121                 :            : 
     122                 :            : static PyObject *
     123                 :          0 : pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
     124                 :            : {
     125                 :          0 :     PyObject *return_value = NULL;
     126                 :            :     const char *base;
     127                 :            : 
     128         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     129                 :          0 :         _PyArg_BadArgument("SetBase", "argument", "str", arg);
     130                 :          0 :         goto exit;
     131                 :            :     }
     132                 :            :     Py_ssize_t base_length;
     133                 :          0 :     base = PyUnicode_AsUTF8AndSize(arg, &base_length);
     134         [ #  # ]:          0 :     if (base == NULL) {
     135                 :          0 :         goto exit;
     136                 :            :     }
     137         [ #  # ]:          0 :     if (strlen(base) != (size_t)base_length) {
     138                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     139                 :          0 :         goto exit;
     140                 :            :     }
     141                 :          0 :     return_value = pyexpat_xmlparser_SetBase_impl(self, base);
     142                 :            : 
     143                 :          0 : exit:
     144                 :          0 :     return return_value;
     145                 :            : }
     146                 :            : 
     147                 :            : PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__,
     148                 :            : "GetBase($self, /)\n"
     149                 :            : "--\n"
     150                 :            : "\n"
     151                 :            : "Return base URL string for the parser.");
     152                 :            : 
     153                 :            : #define PYEXPAT_XMLPARSER_GETBASE_METHODDEF    \
     154                 :            :     {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__},
     155                 :            : 
     156                 :            : static PyObject *
     157                 :            : pyexpat_xmlparser_GetBase_impl(xmlparseobject *self);
     158                 :            : 
     159                 :            : static PyObject *
     160                 :          0 : pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
     161                 :            : {
     162                 :          0 :     return pyexpat_xmlparser_GetBase_impl(self);
     163                 :            : }
     164                 :            : 
     165                 :            : PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__,
     166                 :            : "GetInputContext($self, /)\n"
     167                 :            : "--\n"
     168                 :            : "\n"
     169                 :            : "Return the untranslated text of the input that caused the current event.\n"
     170                 :            : "\n"
     171                 :            : "If the event was generated by a large amount of text (such as a start tag\n"
     172                 :            : "for an element with many attributes), not all of the text may be available.");
     173                 :            : 
     174                 :            : #define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF    \
     175                 :            :     {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__},
     176                 :            : 
     177                 :            : static PyObject *
     178                 :            : pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self);
     179                 :            : 
     180                 :            : static PyObject *
     181                 :          0 : pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
     182                 :            : {
     183                 :          0 :     return pyexpat_xmlparser_GetInputContext_impl(self);
     184                 :            : }
     185                 :            : 
     186                 :            : PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__,
     187                 :            : "ExternalEntityParserCreate($self, context, encoding=<unrepresentable>,\n"
     188                 :            : "                           /)\n"
     189                 :            : "--\n"
     190                 :            : "\n"
     191                 :            : "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler.");
     192                 :            : 
     193                 :            : #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF    \
     194                 :            :     {"ExternalEntityParserCreate", _PyCFunction_CAST(pyexpat_xmlparser_ExternalEntityParserCreate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__},
     195                 :            : 
     196                 :            : static PyObject *
     197                 :            : pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self,
     198                 :            :                                                   PyTypeObject *cls,
     199                 :            :                                                   const char *context,
     200                 :            :                                                   const char *encoding);
     201                 :            : 
     202                 :            : static PyObject *
     203                 :          0 : pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     204                 :            : {
     205                 :          0 :     PyObject *return_value = NULL;
     206                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     207                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     208                 :            :     #else
     209                 :            :     #  define KWTUPLE NULL
     210                 :            :     #endif
     211                 :            : 
     212                 :            :     static const char * const _keywords[] = {"", "", NULL};
     213                 :            :     static _PyArg_Parser _parser = {
     214                 :            :         .keywords = _keywords,
     215                 :            :         .fname = "ExternalEntityParserCreate",
     216                 :            :         .kwtuple = KWTUPLE,
     217                 :            :     };
     218                 :            :     #undef KWTUPLE
     219                 :            :     PyObject *argsbuf[2];
     220                 :            :     const char *context;
     221                 :          0 :     const char *encoding = NULL;
     222                 :            : 
     223   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             #  #  #  # ]
     224         [ #  # ]:          0 :     if (!args) {
     225                 :          0 :         goto exit;
     226                 :            :     }
     227         [ #  # ]:          0 :     if (args[0] == Py_None) {
     228                 :          0 :         context = NULL;
     229                 :            :     }
     230         [ #  # ]:          0 :     else if (PyUnicode_Check(args[0])) {
     231                 :            :         Py_ssize_t context_length;
     232                 :          0 :         context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
     233         [ #  # ]:          0 :         if (context == NULL) {
     234                 :          0 :             goto exit;
     235                 :            :         }
     236         [ #  # ]:          0 :         if (strlen(context) != (size_t)context_length) {
     237                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
     238                 :          0 :             goto exit;
     239                 :            :         }
     240                 :            :     }
     241                 :            :     else {
     242                 :          0 :         _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]);
     243                 :          0 :         goto exit;
     244                 :            :     }
     245         [ #  # ]:          0 :     if (nargs < 2) {
     246                 :          0 :         goto skip_optional_posonly;
     247                 :            :     }
     248         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
     249                 :          0 :         _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]);
     250                 :          0 :         goto exit;
     251                 :            :     }
     252                 :            :     Py_ssize_t encoding_length;
     253                 :          0 :     encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
     254         [ #  # ]:          0 :     if (encoding == NULL) {
     255                 :          0 :         goto exit;
     256                 :            :     }
     257         [ #  # ]:          0 :     if (strlen(encoding) != (size_t)encoding_length) {
     258                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     259                 :          0 :         goto exit;
     260                 :            :     }
     261                 :          0 : skip_optional_posonly:
     262                 :          0 :     return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding);
     263                 :            : 
     264                 :          0 : exit:
     265                 :          0 :     return return_value;
     266                 :            : }
     267                 :            : 
     268                 :            : PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__,
     269                 :            : "SetParamEntityParsing($self, flag, /)\n"
     270                 :            : "--\n"
     271                 :            : "\n"
     272                 :            : "Controls parsing of parameter entities (including the external DTD subset).\n"
     273                 :            : "\n"
     274                 :            : "Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n"
     275                 :            : "XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n"
     276                 :            : "XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n"
     277                 :            : "was successful.");
     278                 :            : 
     279                 :            : #define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF    \
     280                 :            :     {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_O, pyexpat_xmlparser_SetParamEntityParsing__doc__},
     281                 :            : 
     282                 :            : static PyObject *
     283                 :            : pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag);
     284                 :            : 
     285                 :            : static PyObject *
     286                 :          0 : pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
     287                 :            : {
     288                 :          0 :     PyObject *return_value = NULL;
     289                 :            :     int flag;
     290                 :            : 
     291                 :          0 :     flag = _PyLong_AsInt(arg);
     292   [ #  #  #  # ]:          0 :     if (flag == -1 && PyErr_Occurred()) {
     293                 :          0 :         goto exit;
     294                 :            :     }
     295                 :          0 :     return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
     296                 :            : 
     297                 :          0 : exit:
     298                 :          0 :     return return_value;
     299                 :            : }
     300                 :            : 
     301                 :            : #if (XML_COMBINED_VERSION >= 19505)
     302                 :            : 
     303                 :            : PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__,
     304                 :            : "UseForeignDTD($self, flag=True, /)\n"
     305                 :            : "--\n"
     306                 :            : "\n"
     307                 :            : "Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n"
     308                 :            : "\n"
     309                 :            : "This readily allows the use of a \'default\' document type controlled by the\n"
     310                 :            : "application, while still getting the advantage of providing document type\n"
     311                 :            : "information to the parser. \'flag\' defaults to True if not provided.");
     312                 :            : 
     313                 :            : #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF    \
     314                 :            :     {"UseForeignDTD", _PyCFunction_CAST(pyexpat_xmlparser_UseForeignDTD), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__},
     315                 :            : 
     316                 :            : static PyObject *
     317                 :            : pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls,
     318                 :            :                                      int flag);
     319                 :            : 
     320                 :            : static PyObject *
     321                 :          0 : pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     322                 :            : {
     323                 :          0 :     PyObject *return_value = NULL;
     324                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     325                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     326                 :            :     #else
     327                 :            :     #  define KWTUPLE NULL
     328                 :            :     #endif
     329                 :            : 
     330                 :            :     static const char * const _keywords[] = {"", NULL};
     331                 :            :     static _PyArg_Parser _parser = {
     332                 :            :         .keywords = _keywords,
     333                 :            :         .fname = "UseForeignDTD",
     334                 :            :         .kwtuple = KWTUPLE,
     335                 :            :     };
     336                 :            :     #undef KWTUPLE
     337                 :            :     PyObject *argsbuf[1];
     338                 :          0 :     int flag = 1;
     339                 :            : 
     340   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             #  #  #  # ]
     341         [ #  # ]:          0 :     if (!args) {
     342                 :          0 :         goto exit;
     343                 :            :     }
     344         [ #  # ]:          0 :     if (nargs < 1) {
     345                 :          0 :         goto skip_optional_posonly;
     346                 :            :     }
     347                 :          0 :     flag = PyObject_IsTrue(args[0]);
     348         [ #  # ]:          0 :     if (flag < 0) {
     349                 :          0 :         goto exit;
     350                 :            :     }
     351                 :          0 : skip_optional_posonly:
     352                 :          0 :     return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag);
     353                 :            : 
     354                 :          0 : exit:
     355                 :          0 :     return return_value;
     356                 :            : }
     357                 :            : 
     358                 :            : #endif /* (XML_COMBINED_VERSION >= 19505) */
     359                 :            : 
     360                 :            : PyDoc_STRVAR(pyexpat_ParserCreate__doc__,
     361                 :            : "ParserCreate($module, /, encoding=None, namespace_separator=None,\n"
     362                 :            : "             intern=<unrepresentable>)\n"
     363                 :            : "--\n"
     364                 :            : "\n"
     365                 :            : "Return a new XML parser object.");
     366                 :            : 
     367                 :            : #define PYEXPAT_PARSERCREATE_METHODDEF    \
     368                 :            :     {"ParserCreate", _PyCFunction_CAST(pyexpat_ParserCreate), METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__},
     369                 :            : 
     370                 :            : static PyObject *
     371                 :            : pyexpat_ParserCreate_impl(PyObject *module, const char *encoding,
     372                 :            :                           const char *namespace_separator, PyObject *intern);
     373                 :            : 
     374                 :            : static PyObject *
     375                 :          0 : pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     376                 :            : {
     377                 :          0 :     PyObject *return_value = NULL;
     378                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     379                 :            : 
     380                 :            :     #define NUM_KEYWORDS 3
     381                 :            :     static struct {
     382                 :            :         PyGC_Head _this_is_not_used;
     383                 :            :         PyObject_VAR_HEAD
     384                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     385                 :            :     } _kwtuple = {
     386                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     387                 :            :         .ob_item = { &_Py_ID(encoding), &_Py_ID(namespace_separator), &_Py_ID(intern), },
     388                 :            :     };
     389                 :            :     #undef NUM_KEYWORDS
     390                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     391                 :            : 
     392                 :            :     #else  // !Py_BUILD_CORE
     393                 :            :     #  define KWTUPLE NULL
     394                 :            :     #endif  // !Py_BUILD_CORE
     395                 :            : 
     396                 :            :     static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL};
     397                 :            :     static _PyArg_Parser _parser = {
     398                 :            :         .keywords = _keywords,
     399                 :            :         .fname = "ParserCreate",
     400                 :            :         .kwtuple = KWTUPLE,
     401                 :            :     };
     402                 :            :     #undef KWTUPLE
     403                 :            :     PyObject *argsbuf[3];
     404         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     405                 :          0 :     const char *encoding = NULL;
     406                 :          0 :     const char *namespace_separator = NULL;
     407                 :          0 :     PyObject *intern = NULL;
     408                 :            : 
     409   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf);
             #  #  #  # ]
     410         [ #  # ]:          0 :     if (!args) {
     411                 :          0 :         goto exit;
     412                 :            :     }
     413         [ #  # ]:          0 :     if (!noptargs) {
     414                 :          0 :         goto skip_optional_pos;
     415                 :            :     }
     416         [ #  # ]:          0 :     if (args[0]) {
     417         [ #  # ]:          0 :         if (args[0] == Py_None) {
     418                 :          0 :             encoding = NULL;
     419                 :            :         }
     420         [ #  # ]:          0 :         else if (PyUnicode_Check(args[0])) {
     421                 :            :             Py_ssize_t encoding_length;
     422                 :          0 :             encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length);
     423         [ #  # ]:          0 :             if (encoding == NULL) {
     424                 :          0 :                 goto exit;
     425                 :            :             }
     426         [ #  # ]:          0 :             if (strlen(encoding) != (size_t)encoding_length) {
     427                 :          0 :                 PyErr_SetString(PyExc_ValueError, "embedded null character");
     428                 :          0 :                 goto exit;
     429                 :            :             }
     430                 :            :         }
     431                 :            :         else {
     432                 :          0 :             _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]);
     433                 :          0 :             goto exit;
     434                 :            :         }
     435         [ #  # ]:          0 :         if (!--noptargs) {
     436                 :          0 :             goto skip_optional_pos;
     437                 :            :         }
     438                 :            :     }
     439         [ #  # ]:          0 :     if (args[1]) {
     440         [ #  # ]:          0 :         if (args[1] == Py_None) {
     441                 :          0 :             namespace_separator = NULL;
     442                 :            :         }
     443         [ #  # ]:          0 :         else if (PyUnicode_Check(args[1])) {
     444                 :            :             Py_ssize_t namespace_separator_length;
     445                 :          0 :             namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length);
     446         [ #  # ]:          0 :             if (namespace_separator == NULL) {
     447                 :          0 :                 goto exit;
     448                 :            :             }
     449         [ #  # ]:          0 :             if (strlen(namespace_separator) != (size_t)namespace_separator_length) {
     450                 :          0 :                 PyErr_SetString(PyExc_ValueError, "embedded null character");
     451                 :          0 :                 goto exit;
     452                 :            :             }
     453                 :            :         }
     454                 :            :         else {
     455                 :          0 :             _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]);
     456                 :          0 :             goto exit;
     457                 :            :         }
     458         [ #  # ]:          0 :         if (!--noptargs) {
     459                 :          0 :             goto skip_optional_pos;
     460                 :            :         }
     461                 :            :     }
     462                 :          0 :     intern = args[2];
     463                 :          0 : skip_optional_pos:
     464                 :          0 :     return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern);
     465                 :            : 
     466                 :          0 : exit:
     467                 :          0 :     return return_value;
     468                 :            : }
     469                 :            : 
     470                 :            : PyDoc_STRVAR(pyexpat_ErrorString__doc__,
     471                 :            : "ErrorString($module, code, /)\n"
     472                 :            : "--\n"
     473                 :            : "\n"
     474                 :            : "Returns string error for given number.");
     475                 :            : 
     476                 :            : #define PYEXPAT_ERRORSTRING_METHODDEF    \
     477                 :            :     {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_O, pyexpat_ErrorString__doc__},
     478                 :            : 
     479                 :            : static PyObject *
     480                 :            : pyexpat_ErrorString_impl(PyObject *module, long code);
     481                 :            : 
     482                 :            : static PyObject *
     483                 :          0 : pyexpat_ErrorString(PyObject *module, PyObject *arg)
     484                 :            : {
     485                 :          0 :     PyObject *return_value = NULL;
     486                 :            :     long code;
     487                 :            : 
     488                 :          0 :     code = PyLong_AsLong(arg);
     489   [ #  #  #  # ]:          0 :     if (code == -1 && PyErr_Occurred()) {
     490                 :          0 :         goto exit;
     491                 :            :     }
     492                 :          0 :     return_value = pyexpat_ErrorString_impl(module, code);
     493                 :            : 
     494                 :          0 : exit:
     495                 :          0 :     return return_value;
     496                 :            : }
     497                 :            : 
     498                 :            : #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
     499                 :            :     #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
     500                 :            : #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
     501                 :            : /*[clinic end generated code: output=63efc62e24a7b5a7 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14