LCOV - code coverage report
Current view: top level - Modules/clinic - _zoneinfo.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 78 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 7 0.0 %
Branches: 0 82 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(zoneinfo_ZoneInfo_from_file__doc__,
      12                 :            : "from_file($type, file_obj, /, key=None)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Create a ZoneInfo file from a file object.");
      16                 :            : 
      17                 :            : #define ZONEINFO_ZONEINFO_FROM_FILE_METHODDEF    \
      18                 :            :     {"from_file", _PyCFunction_CAST(zoneinfo_ZoneInfo_from_file), METH_METHOD|METH_FASTCALL|METH_KEYWORDS|METH_CLASS, zoneinfo_ZoneInfo_from_file__doc__},
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : zoneinfo_ZoneInfo_from_file_impl(PyTypeObject *type, PyTypeObject *cls,
      22                 :            :                                  PyObject *file_obj, PyObject *key);
      23                 :            : 
      24                 :            : static PyObject *
      25                 :          0 : zoneinfo_ZoneInfo_from_file(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      26                 :            : {
      27                 :          0 :     PyObject *return_value = NULL;
      28                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      29                 :            : 
      30                 :            :     #define NUM_KEYWORDS 1
      31                 :            :     static struct {
      32                 :            :         PyGC_Head _this_is_not_used;
      33                 :            :         PyObject_VAR_HEAD
      34                 :            :         PyObject *ob_item[NUM_KEYWORDS];
      35                 :            :     } _kwtuple = {
      36                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      37                 :            :         .ob_item = { &_Py_ID(key), },
      38                 :            :     };
      39                 :            :     #undef NUM_KEYWORDS
      40                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      41                 :            : 
      42                 :            :     #else  // !Py_BUILD_CORE
      43                 :            :     #  define KWTUPLE NULL
      44                 :            :     #endif  // !Py_BUILD_CORE
      45                 :            : 
      46                 :            :     static const char * const _keywords[] = {"", "key", NULL};
      47                 :            :     static _PyArg_Parser _parser = {
      48                 :            :         .keywords = _keywords,
      49                 :            :         .fname = "from_file",
      50                 :            :         .kwtuple = KWTUPLE,
      51                 :            :     };
      52                 :            :     #undef KWTUPLE
      53                 :            :     PyObject *argsbuf[2];
      54         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
      55                 :            :     PyObject *file_obj;
      56                 :          0 :     PyObject *key = Py_None;
      57                 :            : 
      58   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             #  #  #  # ]
      59         [ #  # ]:          0 :     if (!args) {
      60                 :          0 :         goto exit;
      61                 :            :     }
      62                 :          0 :     file_obj = args[0];
      63         [ #  # ]:          0 :     if (!noptargs) {
      64                 :          0 :         goto skip_optional_pos;
      65                 :            :     }
      66                 :          0 :     key = args[1];
      67                 :          0 : skip_optional_pos:
      68                 :          0 :     return_value = zoneinfo_ZoneInfo_from_file_impl(type, cls, file_obj, key);
      69                 :            : 
      70                 :          0 : exit:
      71                 :          0 :     return return_value;
      72                 :            : }
      73                 :            : 
      74                 :            : PyDoc_STRVAR(zoneinfo_ZoneInfo_no_cache__doc__,
      75                 :            : "no_cache($type, /, key)\n"
      76                 :            : "--\n"
      77                 :            : "\n"
      78                 :            : "Get a new instance of ZoneInfo, bypassing the cache.");
      79                 :            : 
      80                 :            : #define ZONEINFO_ZONEINFO_NO_CACHE_METHODDEF    \
      81                 :            :     {"no_cache", _PyCFunction_CAST(zoneinfo_ZoneInfo_no_cache), METH_METHOD|METH_FASTCALL|METH_KEYWORDS|METH_CLASS, zoneinfo_ZoneInfo_no_cache__doc__},
      82                 :            : 
      83                 :            : static PyObject *
      84                 :            : zoneinfo_ZoneInfo_no_cache_impl(PyTypeObject *type, PyTypeObject *cls,
      85                 :            :                                 PyObject *key);
      86                 :            : 
      87                 :            : static PyObject *
      88                 :          0 : zoneinfo_ZoneInfo_no_cache(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      89                 :            : {
      90                 :          0 :     PyObject *return_value = NULL;
      91                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      92                 :            : 
      93                 :            :     #define NUM_KEYWORDS 1
      94                 :            :     static struct {
      95                 :            :         PyGC_Head _this_is_not_used;
      96                 :            :         PyObject_VAR_HEAD
      97                 :            :         PyObject *ob_item[NUM_KEYWORDS];
      98                 :            :     } _kwtuple = {
      99                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     100                 :            :         .ob_item = { &_Py_ID(key), },
     101                 :            :     };
     102                 :            :     #undef NUM_KEYWORDS
     103                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     104                 :            : 
     105                 :            :     #else  // !Py_BUILD_CORE
     106                 :            :     #  define KWTUPLE NULL
     107                 :            :     #endif  // !Py_BUILD_CORE
     108                 :            : 
     109                 :            :     static const char * const _keywords[] = {"key", NULL};
     110                 :            :     static _PyArg_Parser _parser = {
     111                 :            :         .keywords = _keywords,
     112                 :            :         .fname = "no_cache",
     113                 :            :         .kwtuple = KWTUPLE,
     114                 :            :     };
     115                 :            :     #undef KWTUPLE
     116                 :            :     PyObject *argsbuf[1];
     117                 :            :     PyObject *key;
     118                 :            : 
     119   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     120         [ #  # ]:          0 :     if (!args) {
     121                 :          0 :         goto exit;
     122                 :            :     }
     123                 :          0 :     key = args[0];
     124                 :          0 :     return_value = zoneinfo_ZoneInfo_no_cache_impl(type, cls, key);
     125                 :            : 
     126                 :          0 : exit:
     127                 :          0 :     return return_value;
     128                 :            : }
     129                 :            : 
     130                 :            : PyDoc_STRVAR(zoneinfo_ZoneInfo_clear_cache__doc__,
     131                 :            : "clear_cache($type, /, *, only_keys=None)\n"
     132                 :            : "--\n"
     133                 :            : "\n"
     134                 :            : "Clear the ZoneInfo cache.");
     135                 :            : 
     136                 :            : #define ZONEINFO_ZONEINFO_CLEAR_CACHE_METHODDEF    \
     137                 :            :     {"clear_cache", _PyCFunction_CAST(zoneinfo_ZoneInfo_clear_cache), METH_METHOD|METH_FASTCALL|METH_KEYWORDS|METH_CLASS, zoneinfo_ZoneInfo_clear_cache__doc__},
     138                 :            : 
     139                 :            : static PyObject *
     140                 :            : zoneinfo_ZoneInfo_clear_cache_impl(PyTypeObject *type, PyTypeObject *cls,
     141                 :            :                                    PyObject *only_keys);
     142                 :            : 
     143                 :            : static PyObject *
     144                 :          0 : zoneinfo_ZoneInfo_clear_cache(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     145                 :            : {
     146                 :          0 :     PyObject *return_value = NULL;
     147                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     148                 :            : 
     149                 :            :     #define NUM_KEYWORDS 1
     150                 :            :     static struct {
     151                 :            :         PyGC_Head _this_is_not_used;
     152                 :            :         PyObject_VAR_HEAD
     153                 :            :         PyObject *ob_item[NUM_KEYWORDS];
     154                 :            :     } _kwtuple = {
     155                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
     156                 :            :         .ob_item = { &_Py_ID(only_keys), },
     157                 :            :     };
     158                 :            :     #undef NUM_KEYWORDS
     159                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
     160                 :            : 
     161                 :            :     #else  // !Py_BUILD_CORE
     162                 :            :     #  define KWTUPLE NULL
     163                 :            :     #endif  // !Py_BUILD_CORE
     164                 :            : 
     165                 :            :     static const char * const _keywords[] = {"only_keys", NULL};
     166                 :            :     static _PyArg_Parser _parser = {
     167                 :            :         .keywords = _keywords,
     168                 :            :         .fname = "clear_cache",
     169                 :            :         .kwtuple = KWTUPLE,
     170                 :            :     };
     171                 :            :     #undef KWTUPLE
     172                 :            :     PyObject *argsbuf[1];
     173         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     174                 :          0 :     PyObject *only_keys = Py_None;
     175                 :            : 
     176   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
             #  #  #  # ]
     177         [ #  # ]:          0 :     if (!args) {
     178                 :          0 :         goto exit;
     179                 :            :     }
     180         [ #  # ]:          0 :     if (!noptargs) {
     181                 :          0 :         goto skip_optional_kwonly;
     182                 :            :     }
     183                 :          0 :     only_keys = args[0];
     184                 :          0 : skip_optional_kwonly:
     185                 :          0 :     return_value = zoneinfo_ZoneInfo_clear_cache_impl(type, cls, only_keys);
     186                 :            : 
     187                 :          0 : exit:
     188                 :          0 :     return return_value;
     189                 :            : }
     190                 :            : 
     191                 :            : PyDoc_STRVAR(zoneinfo_ZoneInfo_utcoffset__doc__,
     192                 :            : "utcoffset($self, dt, /)\n"
     193                 :            : "--\n"
     194                 :            : "\n"
     195                 :            : "Retrieve a timedelta representing the UTC offset in a zone at the given datetime.");
     196                 :            : 
     197                 :            : #define ZONEINFO_ZONEINFO_UTCOFFSET_METHODDEF    \
     198                 :            :     {"utcoffset", _PyCFunction_CAST(zoneinfo_ZoneInfo_utcoffset), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zoneinfo_ZoneInfo_utcoffset__doc__},
     199                 :            : 
     200                 :            : static PyObject *
     201                 :            : zoneinfo_ZoneInfo_utcoffset_impl(PyObject *self, PyTypeObject *cls,
     202                 :            :                                  PyObject *dt);
     203                 :            : 
     204                 :            : static PyObject *
     205                 :          0 : zoneinfo_ZoneInfo_utcoffset(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     206                 :            : {
     207                 :          0 :     PyObject *return_value = NULL;
     208                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     209                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     210                 :            :     #else
     211                 :            :     #  define KWTUPLE NULL
     212                 :            :     #endif
     213                 :            : 
     214                 :            :     static const char * const _keywords[] = {"", NULL};
     215                 :            :     static _PyArg_Parser _parser = {
     216                 :            :         .keywords = _keywords,
     217                 :            :         .fname = "utcoffset",
     218                 :            :         .kwtuple = KWTUPLE,
     219                 :            :     };
     220                 :            :     #undef KWTUPLE
     221                 :            :     PyObject *argsbuf[1];
     222                 :            :     PyObject *dt;
     223                 :            : 
     224   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     225         [ #  # ]:          0 :     if (!args) {
     226                 :          0 :         goto exit;
     227                 :            :     }
     228                 :          0 :     dt = args[0];
     229                 :          0 :     return_value = zoneinfo_ZoneInfo_utcoffset_impl(self, cls, dt);
     230                 :            : 
     231                 :          0 : exit:
     232                 :          0 :     return return_value;
     233                 :            : }
     234                 :            : 
     235                 :            : PyDoc_STRVAR(zoneinfo_ZoneInfo_dst__doc__,
     236                 :            : "dst($self, dt, /)\n"
     237                 :            : "--\n"
     238                 :            : "\n"
     239                 :            : "Retrieve a timedelta representing the amount of DST applied in a zone at the given datetime.");
     240                 :            : 
     241                 :            : #define ZONEINFO_ZONEINFO_DST_METHODDEF    \
     242                 :            :     {"dst", _PyCFunction_CAST(zoneinfo_ZoneInfo_dst), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zoneinfo_ZoneInfo_dst__doc__},
     243                 :            : 
     244                 :            : static PyObject *
     245                 :            : zoneinfo_ZoneInfo_dst_impl(PyObject *self, PyTypeObject *cls, PyObject *dt);
     246                 :            : 
     247                 :            : static PyObject *
     248                 :          0 : zoneinfo_ZoneInfo_dst(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     249                 :            : {
     250                 :          0 :     PyObject *return_value = NULL;
     251                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     252                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     253                 :            :     #else
     254                 :            :     #  define KWTUPLE NULL
     255                 :            :     #endif
     256                 :            : 
     257                 :            :     static const char * const _keywords[] = {"", NULL};
     258                 :            :     static _PyArg_Parser _parser = {
     259                 :            :         .keywords = _keywords,
     260                 :            :         .fname = "dst",
     261                 :            :         .kwtuple = KWTUPLE,
     262                 :            :     };
     263                 :            :     #undef KWTUPLE
     264                 :            :     PyObject *argsbuf[1];
     265                 :            :     PyObject *dt;
     266                 :            : 
     267   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     268         [ #  # ]:          0 :     if (!args) {
     269                 :          0 :         goto exit;
     270                 :            :     }
     271                 :          0 :     dt = args[0];
     272                 :          0 :     return_value = zoneinfo_ZoneInfo_dst_impl(self, cls, dt);
     273                 :            : 
     274                 :          0 : exit:
     275                 :          0 :     return return_value;
     276                 :            : }
     277                 :            : 
     278                 :            : PyDoc_STRVAR(zoneinfo_ZoneInfo_tzname__doc__,
     279                 :            : "tzname($self, dt, /)\n"
     280                 :            : "--\n"
     281                 :            : "\n"
     282                 :            : "Retrieve a string containing the abbreviation for the time zone that applies in a zone at a given datetime.");
     283                 :            : 
     284                 :            : #define ZONEINFO_ZONEINFO_TZNAME_METHODDEF    \
     285                 :            :     {"tzname", _PyCFunction_CAST(zoneinfo_ZoneInfo_tzname), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zoneinfo_ZoneInfo_tzname__doc__},
     286                 :            : 
     287                 :            : static PyObject *
     288                 :            : zoneinfo_ZoneInfo_tzname_impl(PyObject *self, PyTypeObject *cls,
     289                 :            :                               PyObject *dt);
     290                 :            : 
     291                 :            : static PyObject *
     292                 :          0 : zoneinfo_ZoneInfo_tzname(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     293                 :            : {
     294                 :          0 :     PyObject *return_value = NULL;
     295                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     296                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     297                 :            :     #else
     298                 :            :     #  define KWTUPLE NULL
     299                 :            :     #endif
     300                 :            : 
     301                 :            :     static const char * const _keywords[] = {"", NULL};
     302                 :            :     static _PyArg_Parser _parser = {
     303                 :            :         .keywords = _keywords,
     304                 :            :         .fname = "tzname",
     305                 :            :         .kwtuple = KWTUPLE,
     306                 :            :     };
     307                 :            :     #undef KWTUPLE
     308                 :            :     PyObject *argsbuf[1];
     309                 :            :     PyObject *dt;
     310                 :            : 
     311   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             #  #  #  # ]
     312         [ #  # ]:          0 :     if (!args) {
     313                 :          0 :         goto exit;
     314                 :            :     }
     315                 :          0 :     dt = args[0];
     316                 :          0 :     return_value = zoneinfo_ZoneInfo_tzname_impl(self, cls, dt);
     317                 :            : 
     318                 :          0 : exit:
     319                 :          0 :     return return_value;
     320                 :            : }
     321                 :            : 
     322                 :            : PyDoc_STRVAR(zoneinfo_ZoneInfo__unpickle__doc__,
     323                 :            : "_unpickle($type, key, from_cache, /)\n"
     324                 :            : "--\n"
     325                 :            : "\n"
     326                 :            : "Private method used in unpickling.");
     327                 :            : 
     328                 :            : #define ZONEINFO_ZONEINFO__UNPICKLE_METHODDEF    \
     329                 :            :     {"_unpickle", _PyCFunction_CAST(zoneinfo_ZoneInfo__unpickle), METH_METHOD|METH_FASTCALL|METH_KEYWORDS|METH_CLASS, zoneinfo_ZoneInfo__unpickle__doc__},
     330                 :            : 
     331                 :            : static PyObject *
     332                 :            : zoneinfo_ZoneInfo__unpickle_impl(PyTypeObject *type, PyTypeObject *cls,
     333                 :            :                                  PyObject *key, unsigned char from_cache);
     334                 :            : 
     335                 :            : static PyObject *
     336                 :          0 : zoneinfo_ZoneInfo__unpickle(PyTypeObject *type, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     337                 :            : {
     338                 :          0 :     PyObject *return_value = NULL;
     339                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
     340                 :            :     #  define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
     341                 :            :     #else
     342                 :            :     #  define KWTUPLE NULL
     343                 :            :     #endif
     344                 :            : 
     345                 :            :     static const char * const _keywords[] = {"", "", NULL};
     346                 :            :     static _PyArg_Parser _parser = {
     347                 :            :         .keywords = _keywords,
     348                 :            :         .fname = "_unpickle",
     349                 :            :         .kwtuple = KWTUPLE,
     350                 :            :     };
     351                 :            :     #undef KWTUPLE
     352                 :            :     PyObject *argsbuf[2];
     353                 :            :     PyObject *key;
     354                 :            :     unsigned char from_cache;
     355                 :            : 
     356   [ #  #  #  #  :          0 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
             #  #  #  # ]
     357         [ #  # ]:          0 :     if (!args) {
     358                 :          0 :         goto exit;
     359                 :            :     }
     360                 :          0 :     key = args[0];
     361                 :            :     {
     362                 :          0 :         unsigned long ival = PyLong_AsUnsignedLongMask(args[1]);
     363   [ #  #  #  # ]:          0 :         if (ival == (unsigned long)-1 && PyErr_Occurred()) {
     364                 :          0 :             goto exit;
     365                 :            :         }
     366                 :            :         else {
     367                 :          0 :             from_cache = (unsigned char) ival;
     368                 :            :         }
     369                 :            :     }
     370                 :          0 :     return_value = zoneinfo_ZoneInfo__unpickle_impl(type, cls, key, from_cache);
     371                 :            : 
     372                 :          0 : exit:
     373                 :          0 :     return return_value;
     374                 :            : }
     375                 :            : /*[clinic end generated code: output=54051388dfc408af input=a9049054013a1b77]*/

Generated by: LCOV version 1.14