LCOV - code coverage report
Current view: top level - Modules/clinic - _localemodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 13 198 6.6 %
Date: 2023-03-20 08:15:36 Functions: 1 12 8.3 %
Branches: 5 132 3.8 %

           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(_locale_setlocale__doc__,
      12                 :            : "setlocale($module, category, locale=<unrepresentable>, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Activates/queries locale processing.");
      16                 :            : 
      17                 :            : #define _LOCALE_SETLOCALE_METHODDEF    \
      18                 :            :     {"setlocale", _PyCFunction_CAST(_locale_setlocale), METH_FASTCALL, _locale_setlocale__doc__},
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : _locale_setlocale_impl(PyObject *module, int category, const char *locale);
      22                 :            : 
      23                 :            : static PyObject *
      24                 :         28 : _locale_setlocale(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      25                 :            : {
      26                 :         28 :     PyObject *return_value = NULL;
      27                 :            :     int category;
      28                 :         28 :     const char *locale = NULL;
      29                 :            : 
      30   [ +  -  -  +  :         28 :     if (!_PyArg_CheckPositional("setlocale", nargs, 1, 2)) {
                   -  - ]
      31                 :          0 :         goto exit;
      32                 :            :     }
      33                 :         28 :     category = _PyLong_AsInt(args[0]);
      34   [ -  +  -  - ]:         28 :     if (category == -1 && PyErr_Occurred()) {
      35                 :          0 :         goto exit;
      36                 :            :     }
      37         [ -  + ]:         28 :     if (nargs < 2) {
      38                 :          0 :         goto skip_optional;
      39                 :            :     }
      40         [ +  - ]:         28 :     if (args[1] == Py_None) {
      41                 :         28 :         locale = NULL;
      42                 :            :     }
      43         [ #  # ]:          0 :     else if (PyUnicode_Check(args[1])) {
      44                 :            :         Py_ssize_t locale_length;
      45                 :          0 :         locale = PyUnicode_AsUTF8AndSize(args[1], &locale_length);
      46         [ #  # ]:          0 :         if (locale == NULL) {
      47                 :          0 :             goto exit;
      48                 :            :         }
      49         [ #  # ]:          0 :         if (strlen(locale) != (size_t)locale_length) {
      50                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
      51                 :          0 :             goto exit;
      52                 :            :         }
      53                 :            :     }
      54                 :            :     else {
      55                 :          0 :         _PyArg_BadArgument("setlocale", "argument 2", "str or None", args[1]);
      56                 :          0 :         goto exit;
      57                 :            :     }
      58                 :         28 : skip_optional:
      59                 :         28 :     return_value = _locale_setlocale_impl(module, category, locale);
      60                 :            : 
      61                 :         28 : exit:
      62                 :         28 :     return return_value;
      63                 :            : }
      64                 :            : 
      65                 :            : PyDoc_STRVAR(_locale_localeconv__doc__,
      66                 :            : "localeconv($module, /)\n"
      67                 :            : "--\n"
      68                 :            : "\n"
      69                 :            : "Returns numeric and monetary locale-specific parameters.");
      70                 :            : 
      71                 :            : #define _LOCALE_LOCALECONV_METHODDEF    \
      72                 :            :     {"localeconv", (PyCFunction)_locale_localeconv, METH_NOARGS, _locale_localeconv__doc__},
      73                 :            : 
      74                 :            : static PyObject *
      75                 :            : _locale_localeconv_impl(PyObject *module);
      76                 :            : 
      77                 :            : static PyObject *
      78                 :          0 : _locale_localeconv(PyObject *module, PyObject *Py_UNUSED(ignored))
      79                 :            : {
      80                 :          0 :     return _locale_localeconv_impl(module);
      81                 :            : }
      82                 :            : 
      83                 :            : #if defined(HAVE_WCSCOLL)
      84                 :            : 
      85                 :            : PyDoc_STRVAR(_locale_strcoll__doc__,
      86                 :            : "strcoll($module, os1, os2, /)\n"
      87                 :            : "--\n"
      88                 :            : "\n"
      89                 :            : "Compares two strings according to the locale.");
      90                 :            : 
      91                 :            : #define _LOCALE_STRCOLL_METHODDEF    \
      92                 :            :     {"strcoll", _PyCFunction_CAST(_locale_strcoll), METH_FASTCALL, _locale_strcoll__doc__},
      93                 :            : 
      94                 :            : static PyObject *
      95                 :            : _locale_strcoll_impl(PyObject *module, PyObject *os1, PyObject *os2);
      96                 :            : 
      97                 :            : static PyObject *
      98                 :          0 : _locale_strcoll(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      99                 :            : {
     100                 :          0 :     PyObject *return_value = NULL;
     101                 :            :     PyObject *os1;
     102                 :            :     PyObject *os2;
     103                 :            : 
     104   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("strcoll", nargs, 2, 2)) {
                   #  # ]
     105                 :          0 :         goto exit;
     106                 :            :     }
     107         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     108                 :          0 :         _PyArg_BadArgument("strcoll", "argument 1", "str", args[0]);
     109                 :          0 :         goto exit;
     110                 :            :     }
     111         [ #  # ]:          0 :     if (PyUnicode_READY(args[0]) == -1) {
     112                 :          0 :         goto exit;
     113                 :            :     }
     114                 :          0 :     os1 = args[0];
     115         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
     116                 :          0 :         _PyArg_BadArgument("strcoll", "argument 2", "str", args[1]);
     117                 :          0 :         goto exit;
     118                 :            :     }
     119         [ #  # ]:          0 :     if (PyUnicode_READY(args[1]) == -1) {
     120                 :          0 :         goto exit;
     121                 :            :     }
     122                 :          0 :     os2 = args[1];
     123                 :          0 :     return_value = _locale_strcoll_impl(module, os1, os2);
     124                 :            : 
     125                 :          0 : exit:
     126                 :          0 :     return return_value;
     127                 :            : }
     128                 :            : 
     129                 :            : #endif /* defined(HAVE_WCSCOLL) */
     130                 :            : 
     131                 :            : #if defined(HAVE_WCSXFRM)
     132                 :            : 
     133                 :            : PyDoc_STRVAR(_locale_strxfrm__doc__,
     134                 :            : "strxfrm($module, string, /)\n"
     135                 :            : "--\n"
     136                 :            : "\n"
     137                 :            : "Return a string that can be used as a key for locale-aware comparisons.");
     138                 :            : 
     139                 :            : #define _LOCALE_STRXFRM_METHODDEF    \
     140                 :            :     {"strxfrm", (PyCFunction)_locale_strxfrm, METH_O, _locale_strxfrm__doc__},
     141                 :            : 
     142                 :            : static PyObject *
     143                 :            : _locale_strxfrm_impl(PyObject *module, PyObject *str);
     144                 :            : 
     145                 :            : static PyObject *
     146                 :          0 : _locale_strxfrm(PyObject *module, PyObject *arg)
     147                 :            : {
     148                 :          0 :     PyObject *return_value = NULL;
     149                 :            :     PyObject *str;
     150                 :            : 
     151         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     152                 :          0 :         _PyArg_BadArgument("strxfrm", "argument", "str", arg);
     153                 :          0 :         goto exit;
     154                 :            :     }
     155         [ #  # ]:          0 :     if (PyUnicode_READY(arg) == -1) {
     156                 :          0 :         goto exit;
     157                 :            :     }
     158                 :          0 :     str = arg;
     159                 :          0 :     return_value = _locale_strxfrm_impl(module, str);
     160                 :            : 
     161                 :          0 : exit:
     162                 :          0 :     return return_value;
     163                 :            : }
     164                 :            : 
     165                 :            : #endif /* defined(HAVE_WCSXFRM) */
     166                 :            : 
     167                 :            : #if defined(MS_WINDOWS)
     168                 :            : 
     169                 :            : PyDoc_STRVAR(_locale__getdefaultlocale__doc__,
     170                 :            : "_getdefaultlocale($module, /)\n"
     171                 :            : "--\n"
     172                 :            : "\n");
     173                 :            : 
     174                 :            : #define _LOCALE__GETDEFAULTLOCALE_METHODDEF    \
     175                 :            :     {"_getdefaultlocale", (PyCFunction)_locale__getdefaultlocale, METH_NOARGS, _locale__getdefaultlocale__doc__},
     176                 :            : 
     177                 :            : static PyObject *
     178                 :            : _locale__getdefaultlocale_impl(PyObject *module);
     179                 :            : 
     180                 :            : static PyObject *
     181                 :            : _locale__getdefaultlocale(PyObject *module, PyObject *Py_UNUSED(ignored))
     182                 :            : {
     183                 :            :     return _locale__getdefaultlocale_impl(module);
     184                 :            : }
     185                 :            : 
     186                 :            : #endif /* defined(MS_WINDOWS) */
     187                 :            : 
     188                 :            : #if defined(HAVE_LANGINFO_H)
     189                 :            : 
     190                 :            : PyDoc_STRVAR(_locale_nl_langinfo__doc__,
     191                 :            : "nl_langinfo($module, key, /)\n"
     192                 :            : "--\n"
     193                 :            : "\n"
     194                 :            : "Return the value for the locale information associated with key.");
     195                 :            : 
     196                 :            : #define _LOCALE_NL_LANGINFO_METHODDEF    \
     197                 :            :     {"nl_langinfo", (PyCFunction)_locale_nl_langinfo, METH_O, _locale_nl_langinfo__doc__},
     198                 :            : 
     199                 :            : static PyObject *
     200                 :            : _locale_nl_langinfo_impl(PyObject *module, int item);
     201                 :            : 
     202                 :            : static PyObject *
     203                 :          0 : _locale_nl_langinfo(PyObject *module, PyObject *arg)
     204                 :            : {
     205                 :          0 :     PyObject *return_value = NULL;
     206                 :            :     int item;
     207                 :            : 
     208                 :          0 :     item = _PyLong_AsInt(arg);
     209   [ #  #  #  # ]:          0 :     if (item == -1 && PyErr_Occurred()) {
     210                 :          0 :         goto exit;
     211                 :            :     }
     212                 :          0 :     return_value = _locale_nl_langinfo_impl(module, item);
     213                 :            : 
     214                 :          0 : exit:
     215                 :          0 :     return return_value;
     216                 :            : }
     217                 :            : 
     218                 :            : #endif /* defined(HAVE_LANGINFO_H) */
     219                 :            : 
     220                 :            : #if defined(HAVE_LIBINTL_H)
     221                 :            : 
     222                 :            : PyDoc_STRVAR(_locale_gettext__doc__,
     223                 :            : "gettext($module, msg, /)\n"
     224                 :            : "--\n"
     225                 :            : "\n"
     226                 :            : "gettext(msg) -> string\n"
     227                 :            : "\n"
     228                 :            : "Return translation of msg.");
     229                 :            : 
     230                 :            : #define _LOCALE_GETTEXT_METHODDEF    \
     231                 :            :     {"gettext", (PyCFunction)_locale_gettext, METH_O, _locale_gettext__doc__},
     232                 :            : 
     233                 :            : static PyObject *
     234                 :            : _locale_gettext_impl(PyObject *module, const char *in);
     235                 :            : 
     236                 :            : static PyObject *
     237                 :          0 : _locale_gettext(PyObject *module, PyObject *arg)
     238                 :            : {
     239                 :          0 :     PyObject *return_value = NULL;
     240                 :            :     const char *in;
     241                 :            : 
     242         [ #  # ]:          0 :     if (!PyUnicode_Check(arg)) {
     243                 :          0 :         _PyArg_BadArgument("gettext", "argument", "str", arg);
     244                 :          0 :         goto exit;
     245                 :            :     }
     246                 :            :     Py_ssize_t in_length;
     247                 :          0 :     in = PyUnicode_AsUTF8AndSize(arg, &in_length);
     248         [ #  # ]:          0 :     if (in == NULL) {
     249                 :          0 :         goto exit;
     250                 :            :     }
     251         [ #  # ]:          0 :     if (strlen(in) != (size_t)in_length) {
     252                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     253                 :          0 :         goto exit;
     254                 :            :     }
     255                 :          0 :     return_value = _locale_gettext_impl(module, in);
     256                 :            : 
     257                 :          0 : exit:
     258                 :          0 :     return return_value;
     259                 :            : }
     260                 :            : 
     261                 :            : #endif /* defined(HAVE_LIBINTL_H) */
     262                 :            : 
     263                 :            : #if defined(HAVE_LIBINTL_H)
     264                 :            : 
     265                 :            : PyDoc_STRVAR(_locale_dgettext__doc__,
     266                 :            : "dgettext($module, domain, msg, /)\n"
     267                 :            : "--\n"
     268                 :            : "\n"
     269                 :            : "dgettext(domain, msg) -> string\n"
     270                 :            : "\n"
     271                 :            : "Return translation of msg in domain.");
     272                 :            : 
     273                 :            : #define _LOCALE_DGETTEXT_METHODDEF    \
     274                 :            :     {"dgettext", _PyCFunction_CAST(_locale_dgettext), METH_FASTCALL, _locale_dgettext__doc__},
     275                 :            : 
     276                 :            : static PyObject *
     277                 :            : _locale_dgettext_impl(PyObject *module, const char *domain, const char *in);
     278                 :            : 
     279                 :            : static PyObject *
     280                 :          0 : _locale_dgettext(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     281                 :            : {
     282                 :          0 :     PyObject *return_value = NULL;
     283                 :            :     const char *domain;
     284                 :            :     const char *in;
     285                 :            : 
     286   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("dgettext", nargs, 2, 2)) {
                   #  # ]
     287                 :          0 :         goto exit;
     288                 :            :     }
     289         [ #  # ]:          0 :     if (args[0] == Py_None) {
     290                 :          0 :         domain = NULL;
     291                 :            :     }
     292         [ #  # ]:          0 :     else if (PyUnicode_Check(args[0])) {
     293                 :            :         Py_ssize_t domain_length;
     294                 :          0 :         domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length);
     295         [ #  # ]:          0 :         if (domain == NULL) {
     296                 :          0 :             goto exit;
     297                 :            :         }
     298         [ #  # ]:          0 :         if (strlen(domain) != (size_t)domain_length) {
     299                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
     300                 :          0 :             goto exit;
     301                 :            :         }
     302                 :            :     }
     303                 :            :     else {
     304                 :          0 :         _PyArg_BadArgument("dgettext", "argument 1", "str or None", args[0]);
     305                 :          0 :         goto exit;
     306                 :            :     }
     307         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
     308                 :          0 :         _PyArg_BadArgument("dgettext", "argument 2", "str", args[1]);
     309                 :          0 :         goto exit;
     310                 :            :     }
     311                 :            :     Py_ssize_t in_length;
     312                 :          0 :     in = PyUnicode_AsUTF8AndSize(args[1], &in_length);
     313         [ #  # ]:          0 :     if (in == NULL) {
     314                 :          0 :         goto exit;
     315                 :            :     }
     316         [ #  # ]:          0 :     if (strlen(in) != (size_t)in_length) {
     317                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     318                 :          0 :         goto exit;
     319                 :            :     }
     320                 :          0 :     return_value = _locale_dgettext_impl(module, domain, in);
     321                 :            : 
     322                 :          0 : exit:
     323                 :          0 :     return return_value;
     324                 :            : }
     325                 :            : 
     326                 :            : #endif /* defined(HAVE_LIBINTL_H) */
     327                 :            : 
     328                 :            : #if defined(HAVE_LIBINTL_H)
     329                 :            : 
     330                 :            : PyDoc_STRVAR(_locale_dcgettext__doc__,
     331                 :            : "dcgettext($module, domain, msg, category, /)\n"
     332                 :            : "--\n"
     333                 :            : "\n"
     334                 :            : "Return translation of msg in domain and category.");
     335                 :            : 
     336                 :            : #define _LOCALE_DCGETTEXT_METHODDEF    \
     337                 :            :     {"dcgettext", _PyCFunction_CAST(_locale_dcgettext), METH_FASTCALL, _locale_dcgettext__doc__},
     338                 :            : 
     339                 :            : static PyObject *
     340                 :            : _locale_dcgettext_impl(PyObject *module, const char *domain,
     341                 :            :                        const char *msgid, int category);
     342                 :            : 
     343                 :            : static PyObject *
     344                 :          0 : _locale_dcgettext(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     345                 :            : {
     346                 :          0 :     PyObject *return_value = NULL;
     347                 :            :     const char *domain;
     348                 :            :     const char *msgid;
     349                 :            :     int category;
     350                 :            : 
     351   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("dcgettext", nargs, 3, 3)) {
                   #  # ]
     352                 :          0 :         goto exit;
     353                 :            :     }
     354         [ #  # ]:          0 :     if (args[0] == Py_None) {
     355                 :          0 :         domain = NULL;
     356                 :            :     }
     357         [ #  # ]:          0 :     else if (PyUnicode_Check(args[0])) {
     358                 :            :         Py_ssize_t domain_length;
     359                 :          0 :         domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length);
     360         [ #  # ]:          0 :         if (domain == NULL) {
     361                 :          0 :             goto exit;
     362                 :            :         }
     363         [ #  # ]:          0 :         if (strlen(domain) != (size_t)domain_length) {
     364                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
     365                 :          0 :             goto exit;
     366                 :            :         }
     367                 :            :     }
     368                 :            :     else {
     369                 :          0 :         _PyArg_BadArgument("dcgettext", "argument 1", "str or None", args[0]);
     370                 :          0 :         goto exit;
     371                 :            :     }
     372         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
     373                 :          0 :         _PyArg_BadArgument("dcgettext", "argument 2", "str", args[1]);
     374                 :          0 :         goto exit;
     375                 :            :     }
     376                 :            :     Py_ssize_t msgid_length;
     377                 :          0 :     msgid = PyUnicode_AsUTF8AndSize(args[1], &msgid_length);
     378         [ #  # ]:          0 :     if (msgid == NULL) {
     379                 :          0 :         goto exit;
     380                 :            :     }
     381         [ #  # ]:          0 :     if (strlen(msgid) != (size_t)msgid_length) {
     382                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     383                 :          0 :         goto exit;
     384                 :            :     }
     385                 :          0 :     category = _PyLong_AsInt(args[2]);
     386   [ #  #  #  # ]:          0 :     if (category == -1 && PyErr_Occurred()) {
     387                 :          0 :         goto exit;
     388                 :            :     }
     389                 :          0 :     return_value = _locale_dcgettext_impl(module, domain, msgid, category);
     390                 :            : 
     391                 :          0 : exit:
     392                 :          0 :     return return_value;
     393                 :            : }
     394                 :            : 
     395                 :            : #endif /* defined(HAVE_LIBINTL_H) */
     396                 :            : 
     397                 :            : #if defined(HAVE_LIBINTL_H)
     398                 :            : 
     399                 :            : PyDoc_STRVAR(_locale_textdomain__doc__,
     400                 :            : "textdomain($module, domain, /)\n"
     401                 :            : "--\n"
     402                 :            : "\n"
     403                 :            : "Set the C library\'s textdmain to domain, returning the new domain.");
     404                 :            : 
     405                 :            : #define _LOCALE_TEXTDOMAIN_METHODDEF    \
     406                 :            :     {"textdomain", (PyCFunction)_locale_textdomain, METH_O, _locale_textdomain__doc__},
     407                 :            : 
     408                 :            : static PyObject *
     409                 :            : _locale_textdomain_impl(PyObject *module, const char *domain);
     410                 :            : 
     411                 :            : static PyObject *
     412                 :          0 : _locale_textdomain(PyObject *module, PyObject *arg)
     413                 :            : {
     414                 :          0 :     PyObject *return_value = NULL;
     415                 :            :     const char *domain;
     416                 :            : 
     417         [ #  # ]:          0 :     if (arg == Py_None) {
     418                 :          0 :         domain = NULL;
     419                 :            :     }
     420         [ #  # ]:          0 :     else if (PyUnicode_Check(arg)) {
     421                 :            :         Py_ssize_t domain_length;
     422                 :          0 :         domain = PyUnicode_AsUTF8AndSize(arg, &domain_length);
     423         [ #  # ]:          0 :         if (domain == NULL) {
     424                 :          0 :             goto exit;
     425                 :            :         }
     426         [ #  # ]:          0 :         if (strlen(domain) != (size_t)domain_length) {
     427                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
     428                 :          0 :             goto exit;
     429                 :            :         }
     430                 :            :     }
     431                 :            :     else {
     432                 :          0 :         _PyArg_BadArgument("textdomain", "argument", "str or None", arg);
     433                 :          0 :         goto exit;
     434                 :            :     }
     435                 :          0 :     return_value = _locale_textdomain_impl(module, domain);
     436                 :            : 
     437                 :          0 : exit:
     438                 :          0 :     return return_value;
     439                 :            : }
     440                 :            : 
     441                 :            : #endif /* defined(HAVE_LIBINTL_H) */
     442                 :            : 
     443                 :            : #if defined(HAVE_LIBINTL_H)
     444                 :            : 
     445                 :            : PyDoc_STRVAR(_locale_bindtextdomain__doc__,
     446                 :            : "bindtextdomain($module, domain, dir, /)\n"
     447                 :            : "--\n"
     448                 :            : "\n"
     449                 :            : "Bind the C library\'s domain to dir.");
     450                 :            : 
     451                 :            : #define _LOCALE_BINDTEXTDOMAIN_METHODDEF    \
     452                 :            :     {"bindtextdomain", _PyCFunction_CAST(_locale_bindtextdomain), METH_FASTCALL, _locale_bindtextdomain__doc__},
     453                 :            : 
     454                 :            : static PyObject *
     455                 :            : _locale_bindtextdomain_impl(PyObject *module, const char *domain,
     456                 :            :                             PyObject *dirname_obj);
     457                 :            : 
     458                 :            : static PyObject *
     459                 :          0 : _locale_bindtextdomain(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     460                 :            : {
     461                 :          0 :     PyObject *return_value = NULL;
     462                 :            :     const char *domain;
     463                 :            :     PyObject *dirname_obj;
     464                 :            : 
     465   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("bindtextdomain", nargs, 2, 2)) {
                   #  # ]
     466                 :          0 :         goto exit;
     467                 :            :     }
     468         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     469                 :          0 :         _PyArg_BadArgument("bindtextdomain", "argument 1", "str", args[0]);
     470                 :          0 :         goto exit;
     471                 :            :     }
     472                 :            :     Py_ssize_t domain_length;
     473                 :          0 :     domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length);
     474         [ #  # ]:          0 :     if (domain == NULL) {
     475                 :          0 :         goto exit;
     476                 :            :     }
     477         [ #  # ]:          0 :     if (strlen(domain) != (size_t)domain_length) {
     478                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     479                 :          0 :         goto exit;
     480                 :            :     }
     481                 :          0 :     dirname_obj = args[1];
     482                 :          0 :     return_value = _locale_bindtextdomain_impl(module, domain, dirname_obj);
     483                 :            : 
     484                 :          0 : exit:
     485                 :          0 :     return return_value;
     486                 :            : }
     487                 :            : 
     488                 :            : #endif /* defined(HAVE_LIBINTL_H) */
     489                 :            : 
     490                 :            : #if defined(HAVE_LIBINTL_H) && defined(HAVE_BIND_TEXTDOMAIN_CODESET)
     491                 :            : 
     492                 :            : PyDoc_STRVAR(_locale_bind_textdomain_codeset__doc__,
     493                 :            : "bind_textdomain_codeset($module, domain, codeset, /)\n"
     494                 :            : "--\n"
     495                 :            : "\n"
     496                 :            : "Bind the C library\'s domain to codeset.");
     497                 :            : 
     498                 :            : #define _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF    \
     499                 :            :     {"bind_textdomain_codeset", _PyCFunction_CAST(_locale_bind_textdomain_codeset), METH_FASTCALL, _locale_bind_textdomain_codeset__doc__},
     500                 :            : 
     501                 :            : static PyObject *
     502                 :            : _locale_bind_textdomain_codeset_impl(PyObject *module, const char *domain,
     503                 :            :                                      const char *codeset);
     504                 :            : 
     505                 :            : static PyObject *
     506                 :          0 : _locale_bind_textdomain_codeset(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     507                 :            : {
     508                 :          0 :     PyObject *return_value = NULL;
     509                 :            :     const char *domain;
     510                 :            :     const char *codeset;
     511                 :            : 
     512   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("bind_textdomain_codeset", nargs, 2, 2)) {
                   #  # ]
     513                 :          0 :         goto exit;
     514                 :            :     }
     515         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
     516                 :          0 :         _PyArg_BadArgument("bind_textdomain_codeset", "argument 1", "str", args[0]);
     517                 :          0 :         goto exit;
     518                 :            :     }
     519                 :            :     Py_ssize_t domain_length;
     520                 :          0 :     domain = PyUnicode_AsUTF8AndSize(args[0], &domain_length);
     521         [ #  # ]:          0 :     if (domain == NULL) {
     522                 :          0 :         goto exit;
     523                 :            :     }
     524         [ #  # ]:          0 :     if (strlen(domain) != (size_t)domain_length) {
     525                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     526                 :          0 :         goto exit;
     527                 :            :     }
     528         [ #  # ]:          0 :     if (args[1] == Py_None) {
     529                 :          0 :         codeset = NULL;
     530                 :            :     }
     531         [ #  # ]:          0 :     else if (PyUnicode_Check(args[1])) {
     532                 :            :         Py_ssize_t codeset_length;
     533                 :          0 :         codeset = PyUnicode_AsUTF8AndSize(args[1], &codeset_length);
     534         [ #  # ]:          0 :         if (codeset == NULL) {
     535                 :          0 :             goto exit;
     536                 :            :         }
     537         [ #  # ]:          0 :         if (strlen(codeset) != (size_t)codeset_length) {
     538                 :          0 :             PyErr_SetString(PyExc_ValueError, "embedded null character");
     539                 :          0 :             goto exit;
     540                 :            :         }
     541                 :            :     }
     542                 :            :     else {
     543                 :          0 :         _PyArg_BadArgument("bind_textdomain_codeset", "argument 2", "str or None", args[1]);
     544                 :          0 :         goto exit;
     545                 :            :     }
     546                 :          0 :     return_value = _locale_bind_textdomain_codeset_impl(module, domain, codeset);
     547                 :            : 
     548                 :          0 : exit:
     549                 :          0 :     return return_value;
     550                 :            : }
     551                 :            : 
     552                 :            : #endif /* defined(HAVE_LIBINTL_H) && defined(HAVE_BIND_TEXTDOMAIN_CODESET) */
     553                 :            : 
     554                 :            : PyDoc_STRVAR(_locale_getencoding__doc__,
     555                 :            : "getencoding($module, /)\n"
     556                 :            : "--\n"
     557                 :            : "\n"
     558                 :            : "Get the current locale encoding.");
     559                 :            : 
     560                 :            : #define _LOCALE_GETENCODING_METHODDEF    \
     561                 :            :     {"getencoding", (PyCFunction)_locale_getencoding, METH_NOARGS, _locale_getencoding__doc__},
     562                 :            : 
     563                 :            : static PyObject *
     564                 :            : _locale_getencoding_impl(PyObject *module);
     565                 :            : 
     566                 :            : static PyObject *
     567                 :          0 : _locale_getencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
     568                 :            : {
     569                 :          0 :     return _locale_getencoding_impl(module);
     570                 :            : }
     571                 :            : 
     572                 :            : #ifndef _LOCALE_STRCOLL_METHODDEF
     573                 :            :     #define _LOCALE_STRCOLL_METHODDEF
     574                 :            : #endif /* !defined(_LOCALE_STRCOLL_METHODDEF) */
     575                 :            : 
     576                 :            : #ifndef _LOCALE_STRXFRM_METHODDEF
     577                 :            :     #define _LOCALE_STRXFRM_METHODDEF
     578                 :            : #endif /* !defined(_LOCALE_STRXFRM_METHODDEF) */
     579                 :            : 
     580                 :            : #ifndef _LOCALE__GETDEFAULTLOCALE_METHODDEF
     581                 :            :     #define _LOCALE__GETDEFAULTLOCALE_METHODDEF
     582                 :            : #endif /* !defined(_LOCALE__GETDEFAULTLOCALE_METHODDEF) */
     583                 :            : 
     584                 :            : #ifndef _LOCALE_NL_LANGINFO_METHODDEF
     585                 :            :     #define _LOCALE_NL_LANGINFO_METHODDEF
     586                 :            : #endif /* !defined(_LOCALE_NL_LANGINFO_METHODDEF) */
     587                 :            : 
     588                 :            : #ifndef _LOCALE_GETTEXT_METHODDEF
     589                 :            :     #define _LOCALE_GETTEXT_METHODDEF
     590                 :            : #endif /* !defined(_LOCALE_GETTEXT_METHODDEF) */
     591                 :            : 
     592                 :            : #ifndef _LOCALE_DGETTEXT_METHODDEF
     593                 :            :     #define _LOCALE_DGETTEXT_METHODDEF
     594                 :            : #endif /* !defined(_LOCALE_DGETTEXT_METHODDEF) */
     595                 :            : 
     596                 :            : #ifndef _LOCALE_DCGETTEXT_METHODDEF
     597                 :            :     #define _LOCALE_DCGETTEXT_METHODDEF
     598                 :            : #endif /* !defined(_LOCALE_DCGETTEXT_METHODDEF) */
     599                 :            : 
     600                 :            : #ifndef _LOCALE_TEXTDOMAIN_METHODDEF
     601                 :            :     #define _LOCALE_TEXTDOMAIN_METHODDEF
     602                 :            : #endif /* !defined(_LOCALE_TEXTDOMAIN_METHODDEF) */
     603                 :            : 
     604                 :            : #ifndef _LOCALE_BINDTEXTDOMAIN_METHODDEF
     605                 :            :     #define _LOCALE_BINDTEXTDOMAIN_METHODDEF
     606                 :            : #endif /* !defined(_LOCALE_BINDTEXTDOMAIN_METHODDEF) */
     607                 :            : 
     608                 :            : #ifndef _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF
     609                 :            :     #define _LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF
     610                 :            : #endif /* !defined(_LOCALE_BIND_TEXTDOMAIN_CODESET_METHODDEF) */
     611                 :            : /*[clinic end generated code: output=406842c3441559cb input=a9049054013a1b77]*/

Generated by: LCOV version 1.14