Generated by Cython 3.0.11
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: converters.c
+0001: # cython: language_level=3, embedsignature=True, initializedcheck=False
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0002: # Copyright (C) 2018-present Jesus Lara
0003: #
+0004: import re
__pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_re, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_2) < 0) __PYX_ERR(0, 4, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0005: from typing import get_args, get_origin, Union, Optional, List, NewType
__pyx_t_2 = PyList_New(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_get_args); __Pyx_GIVEREF(__pyx_n_s_get_args); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_get_args)) __PYX_ERR(0, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_get_origin); __Pyx_GIVEREF(__pyx_n_s_get_origin); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_get_origin)) __PYX_ERR(0, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Union); __Pyx_GIVEREF(__pyx_n_s_Union); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_Union)) __PYX_ERR(0, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Optional); __Pyx_GIVEREF(__pyx_n_s_Optional); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_Optional)) __PYX_ERR(0, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_List); __Pyx_GIVEREF(__pyx_n_s_List); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_List)) __PYX_ERR(0, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_NewType); __Pyx_GIVEREF(__pyx_n_s_NewType); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_NewType)) __PYX_ERR(0, 5, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_typing, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_get_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_args, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_origin, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Union); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Union, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Optional); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Optional, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_List); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_List, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_NewType); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NewType, __pyx_t_2) < 0) __PYX_ERR(0, 5, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0006: from collections.abc import Sequence, Mapping, Callable, Awaitable
__pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_Sequence); __Pyx_GIVEREF(__pyx_n_s_Sequence); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Sequence)) __PYX_ERR(0, 6, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Mapping); __Pyx_GIVEREF(__pyx_n_s_Mapping); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_Mapping)) __PYX_ERR(0, 6, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Callable); __Pyx_GIVEREF(__pyx_n_s_Callable); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_Callable)) __PYX_ERR(0, 6, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Awaitable); __Pyx_GIVEREF(__pyx_n_s_Awaitable); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_Awaitable)) __PYX_ERR(0, 6, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections_abc, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Sequence, __pyx_t_3) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Mapping); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Mapping, __pyx_t_3) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Callable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Callable, __pyx_t_3) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Awaitable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Awaitable, __pyx_t_3) < 0) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0007: import types
__pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_types, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_types, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0008: from dataclasses import _MISSING_TYPE, _FIELDS, fields
__pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_MISSING_TYPE); __Pyx_GIVEREF(__pyx_n_s_MISSING_TYPE); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_MISSING_TYPE)) __PYX_ERR(0, 8, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_FIELDS); __Pyx_GIVEREF(__pyx_n_s_FIELDS); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_FIELDS)) __PYX_ERR(0, 8, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_fields); __Pyx_GIVEREF(__pyx_n_s_fields); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_fields)) __PYX_ERR(0, 8, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_dataclasses, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_MISSING_TYPE, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_FIELDS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_FIELDS, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_fields); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fields, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0009: import ciso8601
__pyx_t_3 = __Pyx_ImportDottedModule(__pyx_n_s_ciso8601, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ciso8601, __pyx_t_3) < 0) __PYX_ERR(0, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0010: import orjson
__pyx_t_3 = __Pyx_ImportDottedModule(__pyx_n_s_orjson, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_orjson, __pyx_t_3) < 0) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0011: from decimal import Decimal, InvalidOperation
__pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_Decimal); __Pyx_GIVEREF(__pyx_n_s_Decimal); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Decimal)) __PYX_ERR(0, 11, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_InvalidOperation); __Pyx_GIVEREF(__pyx_n_s_InvalidOperation); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_InvalidOperation)) __PYX_ERR(0, 11, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_decimal, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Decimal, __pyx_t_3) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_InvalidOperation); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidOperation, __pyx_t_3) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0012: from libc.stdio cimport sprintf, snprintf
0013: from libc.stdlib cimport malloc, free
0014: from cpython.mem cimport PyMem_Malloc, PyMem_Free
0015: cimport cython
0016: from cpython cimport datetime
0017: from cpython.object cimport (
0018: PyObject_IsInstance,
0019: PyObject_IsSubclass,
0020: PyObject_HasAttr,
0021: PyObject_GetAttr,
0022: PyObject_SetAttr,
0023: PyObject_Call,
0024: PyObject_TypeCheck,
0025: PyCallable_Check
0026: )
0027: from cpython.ref cimport PyObject
+0028: from uuid import UUID
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_UUID); __Pyx_GIVEREF(__pyx_n_s_UUID); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_UUID)) __PYX_ERR(0, 28, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_uuid, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_UUID, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0029: import asyncpg.pgproto.pgproto as pgproto
__pyx_t_3 = __Pyx_ImportDottedModule(__pyx_n_s_asyncpg_pgproto_pgproto, __pyx_tuple__19); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pgproto, __pyx_t_3) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__19 = PyTuple_Pack(3, __pyx_n_s_asyncpg, __pyx_n_s_pgproto, __pyx_n_s_pgproto); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19);
+0030: from .functions import is_iterable, is_primitive
__pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_is_iterable); __Pyx_GIVEREF(__pyx_n_s_is_iterable); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_is_iterable)) __PYX_ERR(0, 30, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_is_primitive); __Pyx_GIVEREF(__pyx_n_s_is_primitive); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_is_primitive)) __PYX_ERR(0, 30, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_functions, __pyx_t_3, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_iterable, __pyx_t_3) < 0) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_primitive, __pyx_t_3) < 0) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0031: from .validation import _validation
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_validation); __Pyx_GIVEREF(__pyx_n_s_validation); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_validation)) __PYX_ERR(0, 31, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_validation_2, __pyx_t_2, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_validation); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validation, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0032: from .fields import Field
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_Field); __Pyx_GIVEREF(__pyx_n_s_Field); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Field)) __PYX_ERR(0, 32, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_fields, __pyx_t_3, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Field); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Field, __pyx_t_3) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0033: # New converter:
+0034: import datamodel.rs_parsers as rc
__pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_datamodel_rs_parsers, __pyx_tuple__20); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_rc, __pyx_t_2) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__20 = PyTuple_Pack(2, __pyx_n_s_datamodel, __pyx_n_s_rs_parsers); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20);
0035:
+0036: cdef struct ColumnDef:
struct __pyx_t_9datamodel_10converters_ColumnDef { char const *name; PyObject *field; };
0037: const char* name
0038: PyObject* field
0039:
+0040: cdef bint is_dc(object obj):
static int __pyx_f_9datamodel_10converters_is_dc(PyObject *__pyx_v_obj) { PyObject *__pyx_v_cls = NULL; int __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("datamodel.converters.is_dc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cls); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0041: """Returns True if obj is a dataclass or an instance of a
0042: dataclass."""
+0043: cls = obj if isinstance(obj, type) and not isinstance(obj, types.GenericAlias) else type(obj)
__pyx_t_3 = PyType_Check(__pyx_v_obj); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L3_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_GenericAlias); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_5); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = (!__pyx_t_3); __pyx_t_2 = __pyx_t_6; __pyx_L3_bool_binop_done:; if (__pyx_t_2) { __Pyx_INCREF(__pyx_v_obj); __pyx_t_1 = __pyx_v_obj; } else { __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_obj))); __pyx_t_1 = ((PyObject *)Py_TYPE(__pyx_v_obj)); } __pyx_v_cls = __pyx_t_1; __pyx_t_1 = 0;
+0044: return PyObject_HasAttr(cls, '__dataclass_fields__')
__pyx_r = PyObject_HasAttr(__pyx_v_cls, __pyx_n_u_dataclass_fields);
goto __pyx_L0;
0045:
+0046: cdef bint is_empty(object value):
static int __pyx_f_9datamodel_10converters_is_empty(PyObject *__pyx_v_value) { int __pyx_v_result; int __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("datamodel.converters.is_empty", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0047: cdef bint result = False
__pyx_v_result = 0;
+0048: if value is None:
__pyx_t_1 = (__pyx_v_value == Py_None); if (__pyx_t_1) { /* … */ }
+0049: return True
__pyx_r = 1; goto __pyx_L0;
+0050: if PyObject_IsInstance(value, _MISSING_TYPE) or value == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L5_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+0051: result = True
__pyx_v_result = 1;
+0052: elif PyObject_IsInstance(value, str) and value == '':
__pyx_t_3 = PyObject_IsInstance(__pyx_v_value, ((PyObject *)(&PyUnicode_Type))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 52, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L7_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_value, __pyx_kp_u__2, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 52, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L7_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+0053: result = True
__pyx_v_result = 1;
+0054: elif PyObject_IsInstance(value, (int, float)) and value == 0:
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 54, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 54, __pyx_L1_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_4); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L9_bool_binop_done; } __pyx_t_3 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_value, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 54, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+0055: result = False
__pyx_v_result = 0;
+0056: elif PyObject_IsInstance(value, dict) and value == {}:
__pyx_t_3 = PyObject_IsInstance(__pyx_v_value, ((PyObject *)(&PyDict_Type))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 56, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyObject_RichCompare(__pyx_v_value, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L11_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+0057: result = False
__pyx_v_result = 0;
+0058: elif PyObject_IsInstance(value, (list, tuple, set)) and value == []:
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF((PyObject *)(&PyList_Type)); __Pyx_GIVEREF((PyObject *)(&PyList_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyList_Type)))) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyTuple_Type)); __Pyx_GIVEREF((PyObject *)(&PyTuple_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyTuple_Type)))) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PySet_Type)); __Pyx_GIVEREF((PyObject *)(&PySet_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PySet_Type)))) __PYX_ERR(0, 58, __pyx_L1_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L13_bool_binop_done; } __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L13_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+0059: result = False
__pyx_v_result = 0;
+0060: elif PyObject_HasAttr(value, 'empty') and PyObject_GetAttr(value, 'empty') == False:
__pyx_t_3 = PyObject_HasAttr(__pyx_v_value, __pyx_n_u_empty); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L15_bool_binop_done; } __pyx_t_4 = PyObject_GetAttr(__pyx_v_value, __pyx_n_u_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+0061: result = False
__pyx_v_result = 0;
+0062: elif not value:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 62, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { /* … */ } __pyx_L4:;
+0063: result = True
__pyx_v_result = 1;
+0064: return result
__pyx_r = __pyx_v_result; goto __pyx_L0;
0065:
+0066: cpdef bint has_attribute(object obj, object attr):
static PyObject *__pyx_pw_9datamodel_10converters_1has_attribute(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static int __pyx_f_9datamodel_10converters_has_attribute(PyObject *__pyx_v_obj, PyObject *__pyx_v_attr, CYTHON_UNUSED int __pyx_skip_dispatch) { int __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_1has_attribute(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_has_attribute, "has_attribute(obj, attr) -> bool\nReturns True if obj has the attribute attr."); static PyMethodDef __pyx_mdef_9datamodel_10converters_1has_attribute = {"has_attribute", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_1has_attribute, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_has_attribute}; static PyObject *__pyx_pw_9datamodel_10converters_1has_attribute(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_attr = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("has_attribute (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_attr,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_attr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("has_attribute", 1, 2, 2, 1); __PYX_ERR(0, 66, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "has_attribute") < 0)) __PYX_ERR(0, 66, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_obj = values[0]; __pyx_v_attr = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("has_attribute", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 66, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.has_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_has_attribute(__pyx_self, __pyx_v_obj, __pyx_v_attr); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_has_attribute(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_attr) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_has_attribute(__pyx_v_obj, __pyx_v_attr, 0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("datamodel.converters.has_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__21 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_attr); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_1has_attribute, 0, __pyx_n_s_has_attribute, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_has_attribute, __pyx_t_2) < 0) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_has_attribute, 66, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 66, __pyx_L1_error)
0067: """Returns True if obj has the attribute attr."""
+0068: return PyObject_HasAttr(obj, attr)
__pyx_r = PyObject_HasAttr(__pyx_v_obj, __pyx_v_attr);
goto __pyx_L0;
0069:
+0070: cpdef str to_string(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_3to_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_string(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datamodel.converters.to_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_3to_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_2to_string, "to_string(obj) -> unicode\n\n Returns a string version of an object.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_3to_string = {"to_string", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_3to_string, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_2to_string}; static PyObject *__pyx_pw_9datamodel_10converters_3to_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_string (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 70, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_string") < 0)) __PYX_ERR(0, 70, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_string", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 70, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_2to_string(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_2to_string(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_string(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_3to_string, 0, __pyx_n_s_to_string, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_string, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_string, 70, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 70, __pyx_L1_error)
0071: """
0072: Returns a string version of an object.
0073: """
+0074: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0075: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0076: if isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0077: return obj
__Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_obj))||((__pyx_v_obj) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_obj))) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyObject*)__pyx_v_obj); goto __pyx_L0;
+0078: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0079: try:
{ /*try:*/ { /* … */ } __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L10_try_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; }
+0080: return obj.decode()
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_decode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 80, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } if (!(likely(PyUnicode_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_5))) __PYX_ERR(0, 80, __pyx_L6_error) __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L10_try_return;
+0081: except UnicodeDecodeError as e:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.to_string", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 81, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_v_e = __pyx_t_6; /*try:*/ { /* … */ /*finally:*/ { __pyx_L17_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_9 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; goto __pyx_L8_except_error; } } } goto __pyx_L8_except_error;
+0082: raise ValueError(f"Cannot decode bytes: {e}") from e
__pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 82, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Cannot_decode_bytes, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 82, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 82, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 82, __pyx_L17_error) }
+0083: if callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 83, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
0084: # its a function callable returning a value
+0085: try:
{ /*try:*/ { /* … */ } __pyx_L24_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L26_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L1_error; __pyx_L28_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L0; __pyx_L25_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); }
+0086: return str(obj())
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_6 = __pyx_v_obj; __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 86, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = __Pyx_PyObject_Unicode(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_r = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L28_try_return;
+0087: except Exception:
__pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_12) { __Pyx_ErrRestore(0,0,0); goto __pyx_L25_exception_handled; } goto __pyx_L26_except_error;
0088: pass
+0089: return str(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_Unicode(__pyx_v_obj); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L0;
0090:
+0091: cpdef object to_uuid(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_5to_uuid(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_uuid(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("datamodel.converters.to_uuid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_5to_uuid(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_4to_uuid, "to_uuid(obj)\nReturns a UUID version of a str column.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_5to_uuid = {"to_uuid", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_5to_uuid, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_4to_uuid}; static PyObject *__pyx_pw_9datamodel_10converters_5to_uuid(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_uuid (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 91, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_uuid") < 0)) __PYX_ERR(0, 91, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_uuid", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 91, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_uuid", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_4to_uuid(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_4to_uuid(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_uuid(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_uuid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_5to_uuid, 0, __pyx_n_s_to_uuid, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_uuid, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_uuid, 91, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 91, __pyx_L1_error)
0092: """Returns a UUID version of a str column.
0093: """
+0094: if isinstance(obj, pgproto.UUID):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
0095: # If it's asyncpg's UUID, convert by casting to string first
+0096: return UUID(str(obj))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_Unicode(__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0097: if isinstance(obj, UUID):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
0098: # already an uuid
+0099: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0100: elif callable(obj):
__pyx_t_3 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 100, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
0101: # its a function callable returning a value
+0102: try:
{ /*try:*/ { /* … */ } __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L9_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); }
+0103: return UUID(obj())
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_obj); __pyx_t_5 = __pyx_v_obj; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L9_try_return;
+0104: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0105: pass
+0106: try:
{ /*try:*/ { /* … */ } __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L1_error; __pyx_L15_try_return:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L0; __pyx_L14_except_return:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L0; }
+0107: return UUID(str(obj))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_Unicode(__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L15_try_return;
+0108: except ValueError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.to_uuid", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 108, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4);
+0109: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L14_except_return; } goto __pyx_L13_except_error;
0110:
0111:
+0112: cpdef str slugify_camelcase(str obj):
static PyObject *__pyx_pw_9datamodel_10converters_7slugify_camelcase(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_slugify_camelcase(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_slugified = NULL; Py_ssize_t __pyx_v_i; Py_UCS4 __pyx_v_c; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("datamodel.converters.slugify_camelcase", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_slugified); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_7slugify_camelcase(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_6slugify_camelcase, "slugify_camelcase(unicode obj) -> unicode\nslugify_camelcase.\n\n Converting CamelCase into a spaced version, but don\342\200\231t double-space\n if the string already contains spaces or uppercase letters follow\n existing spaces.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_7slugify_camelcase = {"slugify_camelcase", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_7slugify_camelcase, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_6slugify_camelcase}; static PyObject *__pyx_pw_9datamodel_10converters_7slugify_camelcase(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("slugify_camelcase (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 112, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "slugify_camelcase") < 0)) __PYX_ERR(0, 112, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("slugify_camelcase", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 112, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.slugify_camelcase", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_obj), (&PyUnicode_Type), 1, "obj", 1))) __PYX_ERR(0, 112, __pyx_L1_error) __pyx_r = __pyx_pf_9datamodel_10converters_6slugify_camelcase(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_6slugify_camelcase(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_slugify_camelcase(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.slugify_camelcase", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_7slugify_camelcase, 0, __pyx_n_s_slugify_camelcase, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_slugify_camelcase, __pyx_t_2) < 0) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_slugify_camelcase, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 112, __pyx_L1_error)
0113: """slugify_camelcase.
0114:
0115: Converting CamelCase into a spaced version, but don’t double-space
0116: if the string already contains spaces or uppercase letters follow
0117: existing spaces.
0118: """
+0119: if not obj:
__pyx_t_1 = (__pyx_v_obj != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_obj) != 0);
__pyx_t_2 = (!__pyx_t_1);
if (__pyx_t_2) {
/* … */
}
+0120: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0121:
+0122: slugified = [obj[0]]
__pyx_t_3 = __Pyx_GetItemInt_Unicode(__pyx_v_obj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == (Py_UCS4)-1)) __PYX_ERR(0, 122, __pyx_L1_error) __pyx_t_4 = __Pyx_PyUnicode_FromOrdinal(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_4)) __PYX_ERR(0, 122, __pyx_L1_error); __pyx_t_4 = 0; __pyx_v_slugified = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0123: for i in range(1, len(obj)):
if (unlikely(__pyx_v_obj == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 123, __pyx_L1_error) } __pyx_t_6 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_obj); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 123, __pyx_L1_error) __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+0124: c = obj[i]
__pyx_t_3 = __Pyx_GetItemInt_Unicode(__pyx_v_obj, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(__pyx_t_3 == (Py_UCS4)-1)) __PYX_ERR(0, 124, __pyx_L1_error) __pyx_v_c = __pyx_t_3;
0125: # Condition: if c is uppercase AND the previous character isn't a space,
0126: # insert a space before it.
+0127: if c.isupper() and not slugified[-1].isspace():
__pyx_t_1 = Py_UNICODE_ISUPPER(__pyx_v_c); if (__pyx_t_1) { } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L7_bool_binop_done; } __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_slugified, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isspace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_10, 0+__pyx_t_10); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = (!__pyx_t_1); __pyx_t_2 = __pyx_t_11; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0128: slugified.append(' ')
__pyx_t_12 = __Pyx_PyList_Append(__pyx_v_slugified, __pyx_kp_u__3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 128, __pyx_L1_error)
+0129: slugified.append(c)
__pyx_t_5 = __Pyx_PyUnicode_FromOrdinal(__pyx_v_c); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_slugified, __pyx_t_5); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
+0130: return ''.join(slugified)
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyUnicode_Join(__pyx_kp_u__2, __pyx_v_slugified); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L0;
0131:
0132:
+0133: cpdef datetime.date to_date(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_9to_date(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyDateTime_Date *__pyx_f_9datamodel_10converters_to_date(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyDateTime_Date *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_obj); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("datamodel.converters.to_date", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_9to_date(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_8to_date, "to_date(obj) -> date\nto_date.\n\n Returns obj converted to date.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_9to_date = {"to_date", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_9to_date, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_8to_date}; static PyObject *__pyx_pw_9datamodel_10converters_9to_date(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_date (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 133, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_date") < 0)) __PYX_ERR(0, 133, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_date", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 133, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_date", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_8to_date(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_8to_date(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = ((PyObject *)__pyx_f_9datamodel_10converters_to_date(__pyx_v_obj, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_date", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_9to_date, 0, __pyx_n_s_to_date, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_date, __pyx_t_2) < 0) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_date, 133, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 133, __pyx_L1_error)
0134: """to_date.
0135:
0136: Returns obj converted to date.
0137: """
+0138: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0139: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_Date *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0140: elif obj == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_v_obj, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+0141: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_Date *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0142: if isinstance(obj, datetime.date):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_date);
if (__pyx_t_1) {
/* … */
}
+0143: return obj
__Pyx_XDECREF((PyObject *)__pyx_r); if (!(likely(((__pyx_v_obj) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_date))))) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyDateTime_Date *)__pyx_v_obj); goto __pyx_L0;
+0144: elif isinstance(obj, (datetime.datetime, datetime.timedelta)):
__pyx_t_4 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_datetime); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_timedelta); __pyx_t_1 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0145: return obj.date()
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_date))))) __PYX_ERR(0, 145, __pyx_L1_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
+0146: if isinstance(obj, (bytes, bytearray)):
__pyx_t_4 = PyBytes_Check(__pyx_v_obj);
if (!__pyx_t_4) {
} else {
__pyx_t_1 = __pyx_t_4;
goto __pyx_L8_bool_binop_done;
}
__pyx_t_4 = PyByteArray_Check(__pyx_v_obj);
__pyx_t_1 = __pyx_t_4;
__pyx_L8_bool_binop_done:;
if (__pyx_t_1) {
/* … */
}
+0147: obj = obj.decode("ascii")
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_n_u_ascii}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_3); __pyx_t_3 = 0;
0148: # Handle Unix epoch via Rust's `to_timestamp`
+0149: if isinstance(obj, (int, float)):
__pyx_t_4 = PyInt_Check(__pyx_v_obj); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L11_bool_binop_done; } __pyx_t_4 = PyFloat_Check(__pyx_v_obj); __pyx_t_1 = __pyx_t_4; __pyx_L11_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0150: try:
{ /*try:*/ { /* … */ } __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L15_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L17_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; __pyx_L14_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); }
+0151: return rc.to_timestamp(obj).date()
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 151, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_to_timestamp); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 151, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_obj}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_date); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 151, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_date))))) __PYX_ERR(0, 151, __pyx_L13_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L17_try_return;
+0152: except ValueError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_ErrRestore(0,0,0); goto __pyx_L14_exception_handled; } goto __pyx_L15_except_error;
0153: pass
0154: # using rust todate function
+0155: try:
{ /*try:*/ { /* … */ } __pyx_L19_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L21_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L1_error; __pyx_L23_try_return:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L0; __pyx_L20_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); }
+0156: return rc.to_date(obj)
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_rc); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 156, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_to_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_date))))) __PYX_ERR(0, 156, __pyx_L19_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L23_try_return;
+0157: except ValueError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_ErrRestore(0,0,0); goto __pyx_L20_exception_handled; } goto __pyx_L21_except_error;
0158: pass
0159: # Fallback to Cython-native ciso8601 parsing
+0160: try:
{ /*try:*/ { /* … */ } __pyx_L25_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L27_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L29_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; }
+0161: return ciso8601.parse_datetime(obj).date()
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_ciso8601); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 161, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_parse_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 161, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_obj}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_date); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 161, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_date))))) __PYX_ERR(0, 161, __pyx_L25_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L29_try_return;
+0162: except ValueError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.to_date", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 162, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
0163: pass
+0164: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 164, __pyx_L27_except_error) } goto __pyx_L27_except_error;
+0165: f"Can't convert invalid data *{obj}* to date"
__pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 165, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Can_t_convert_invalid_data); __pyx_t_12 += 28; __Pyx_GIVEREF(__pyx_kp_u_Can_t_convert_invalid_data); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Can_t_convert_invalid_data); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 165, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_to_date_2); __pyx_t_12 += 9; __Pyx_GIVEREF(__pyx_kp_u_to_date_2); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_to_date_2); __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 165, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
0166: )
0167:
0168:
+0169: cpdef datetime.datetime to_datetime(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_11to_datetime(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyDateTime_DateTime *__pyx_f_9datamodel_10converters_to_datetime(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyDateTime_DateTime *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_obj); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("datamodel.converters.to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_11to_datetime(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_10to_datetime, "to_datetime(obj) -> datetime\nto_datetime.\n\n Returns obj converted to datetime.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_11to_datetime = {"to_datetime", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_11to_datetime, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_10to_datetime}; static PyObject *__pyx_pw_9datamodel_10converters_11to_datetime(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_datetime (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 169, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_datetime") < 0)) __PYX_ERR(0, 169, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_datetime", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 169, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_10to_datetime(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_10to_datetime(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = ((PyObject *)__pyx_f_9datamodel_10converters_to_datetime(__pyx_v_obj, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_11to_datetime, 0, __pyx_n_s_to_datetime, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_datetime, __pyx_t_2) < 0) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_datetime, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 169, __pyx_L1_error)
0170: """to_datetime.
0171:
0172: Returns obj converted to datetime.
0173: """
+0174: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0175: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_DateTime *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0176: elif obj == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_v_obj, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+0177: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_DateTime *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0178: if isinstance(obj, datetime.datetime):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_datetime);
if (__pyx_t_1) {
/* … */
}
+0179: return obj
__Pyx_XDECREF((PyObject *)__pyx_r); if (!(likely(((__pyx_v_obj) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_datetime))))) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyDateTime_DateTime *)__pyx_v_obj); goto __pyx_L0;
+0180: if isinstance(obj, (bytes, bytearray)):
__pyx_t_4 = PyBytes_Check(__pyx_v_obj);
if (!__pyx_t_4) {
} else {
__pyx_t_1 = __pyx_t_4;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_4 = PyByteArray_Check(__pyx_v_obj);
__pyx_t_1 = __pyx_t_4;
__pyx_L6_bool_binop_done:;
if (__pyx_t_1) {
/* … */
}
+0181: obj = obj.decode("ascii")
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_n_u_ascii}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_3); __pyx_t_3 = 0;
0182: # Handle Unix epoch via Rust's `to_timestamp`
+0183: if isinstance(obj, (int, float)):
__pyx_t_4 = PyInt_Check(__pyx_v_obj); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L9_bool_binop_done; } __pyx_t_4 = PyFloat_Check(__pyx_v_obj); __pyx_t_1 = __pyx_t_4; __pyx_L9_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0184: try:
{ /*try:*/ { /* … */ } __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L15_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; __pyx_L12_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); }
+0185: return rc.to_timestamp(obj)
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_to_timestamp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_datetime))))) __PYX_ERR(0, 185, __pyx_L11_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L15_try_return;
+0186: except ValueError:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_ErrRestore(0,0,0); goto __pyx_L12_exception_handled; } goto __pyx_L13_except_error;
0187: pass
+0188: try:
{ /*try:*/ { /* … */ } __pyx_L17_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L19_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L1_error; __pyx_L21_try_return:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L0; __pyx_L18_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); }
+0189: return rc.to_datetime(obj)
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_rc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_to_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_datetime))))) __PYX_ERR(0, 189, __pyx_L17_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L21_try_return;
+0190: except ValueError:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_ErrRestore(0,0,0); goto __pyx_L18_exception_handled; } goto __pyx_L19_except_error;
0191: pass
+0192: try:
{ /*try:*/ { /* … */ } __pyx_L23_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L25_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L27_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; }
+0193: return ciso8601.parse_datetime(obj)
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ciso8601); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_parse_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_8datetime_datetime))))) __PYX_ERR(0, 193, __pyx_L23_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L27_try_return;
+0194: except ValueError:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 194, __pyx_L25_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
+0195: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 195, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 195, __pyx_L25_except_error) } goto __pyx_L25_except_error;
+0196: f"Can't convert invalid data *{obj}* to datetime"
__pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 196, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Can_t_convert_invalid_data); __pyx_t_12 += 28; __Pyx_GIVEREF(__pyx_kp_u_Can_t_convert_invalid_data); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Can_t_convert_invalid_data); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 196, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_to_datetime_2); __pyx_t_12 += 13; __Pyx_GIVEREF(__pyx_kp_u_to_datetime_2); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_to_datetime_2); __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_11, 3, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 196, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0197: )
0198:
+0199: cpdef object to_integer(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_13to_integer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_integer(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_obj); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datamodel.converters.to_integer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_obj); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_13to_integer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_12to_integer, "to_integer(obj)\nto_integer.\n\n Returns object converted to integer.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_13to_integer = {"to_integer", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_13to_integer, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_12to_integer}; static PyObject *__pyx_pw_9datamodel_10converters_13to_integer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_integer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_integer") < 0)) __PYX_ERR(0, 199, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_integer", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 199, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_integer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_12to_integer(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_12to_integer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_integer(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_integer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_13to_integer, 0, __pyx_n_s_to_integer, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_integer, __pyx_t_2) < 0) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_integer, 199, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 199, __pyx_L1_error)
0200: """to_integer.
0201:
0202: Returns object converted to integer.
0203: """
+0204: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0205: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0206: if isinstance(obj, int):
__pyx_t_1 = PyInt_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0207: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0208: if isinstance(obj, unicode):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0209: obj = obj.encode("ascii")
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_n_u_ascii}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_2); __pyx_t_2 = 0;
+0210: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0211: try:
{ /*try:*/ { /* … */ } __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L11_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; }
+0212: return int(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L11_try_return;
+0213: except (TypeError, ValueError) as e:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.to_integer", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 213, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L18_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_9 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; goto __pyx_L9_except_error; } } } goto __pyx_L9_except_error;
+0214: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0215: f"Invalid conversion to Integer of {obj}"
__pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 215, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Invalid_conversion_to_Integer_of, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 215, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0216: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 214, __pyx_L18_error) }
+0217: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 217, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L6; }
0218: # its a function callable returning a value
+0219: try:
{ /*try:*/ { /* … */ } __pyx_L24_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L28_try_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L0; __pyx_L25_exception_handled:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); }
+0220: return obj()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_3 = __pyx_v_obj; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L28_try_return;
+0221: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L25_exception_handled;
}
0222: pass
0223: else:
+0224: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L30_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L32_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L34_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; } } __pyx_L6:;
+0225: return int(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L34_try_return;
+0226: except (TypeError, ValueError) as e:
__pyx_t_12 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_12) { __Pyx_AddTraceback("datamodel.converters.to_integer", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 226, __pyx_L32_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L41_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_14); __pyx_t_12 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_20 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_15, __pyx_t_14); } __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_19, __pyx_t_18, __pyx_t_17); __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_20; goto __pyx_L32_except_error; } } } goto __pyx_L32_except_error;
+0227: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 227, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0228: f"Invalid conversion to Integer of {obj}"
__pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 228, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Invalid_conversion_to_Integer_of, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 228, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0229: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 227, __pyx_L41_error) }
0230:
+0231: cpdef object to_float(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_15to_float(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_float(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("datamodel.converters.to_float", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_15to_float(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_14to_float, "to_float(obj)\nto_float.\n\n Returns object converted to float.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_15to_float = {"to_float", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_15to_float, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_14to_float}; static PyObject *__pyx_pw_9datamodel_10converters_15to_float(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_float (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 231, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_float") < 0)) __PYX_ERR(0, 231, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_float", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 231, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_float", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_14to_float(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_14to_float(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_float(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_float", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_15to_float, 0, __pyx_n_s_to_float, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_float, __pyx_t_2) < 0) __PYX_ERR(0, 231, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_float, 231, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 231, __pyx_L1_error)
0232: """to_float.
0233:
0234: Returns object converted to float.
0235: """
+0236: if isinstance(obj, (float, Decimal)):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyFloat_Check(__pyx_v_obj); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_1); __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0237: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0238: elif isinstance(obj, _MISSING_TYPE):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0239: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0240: elif callable(obj):
__pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 240, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L3; }
0241: # its a function callable returning a value
+0242: try:
{ /*try:*/ { /* … */ } __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L10_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L0; __pyx_L7_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); }
+0243: return obj()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_7 = __pyx_v_obj; __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L10_try_return;
+0244: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L7_exception_handled;
}
0245: pass
0246: else:
+0247: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L12_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L14_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L1_error; __pyx_L16_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L0; __pyx_L15_except_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L0; } } __pyx_L3:;
+0248: return float(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Float(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L16_try_return;
+0249: except (TypeError, ValueError):
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.to_float", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 249, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8);
+0250: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L15_except_return; } goto __pyx_L14_except_error;
0251:
+0252: cpdef object to_decimal(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_17to_decimal(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_decimal(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_ex = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datamodel.converters.to_decimal", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ex); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_17to_decimal(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_16to_decimal, "to_decimal(obj)\nto_decimal.\n\n Returns a Decimal version of object.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_17to_decimal = {"to_decimal", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_17to_decimal, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_16to_decimal}; static PyObject *__pyx_pw_9datamodel_10converters_17to_decimal(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_decimal (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_decimal") < 0)) __PYX_ERR(0, 252, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_decimal", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 252, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_decimal", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_16to_decimal(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_16to_decimal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_decimal(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_decimal", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_17to_decimal, 0, __pyx_n_s_to_decimal, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_decimal, __pyx_t_2) < 0) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_decimal, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 252, __pyx_L1_error)
0253: """to_decimal.
0254:
0255: Returns a Decimal version of object.
0256: """
+0257: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0258: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0259: if isinstance(obj, Decimal):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0260: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0261: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 261, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0262: # its a function callable returning a value
+0263: try:
{ /*try:*/ { /* … */ } __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L9_try_return:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L0; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); }
+0264: return obj()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_6 = __pyx_v_obj; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L9_try_return;
+0265: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0266: pass
0267: else:
+0268: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3); goto __pyx_L1_error; __pyx_L15_try_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3); goto __pyx_L0; __pyx_L14_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3); goto __pyx_L0; } } __pyx_L4:;
+0269: return Decimal(obj)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 269, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_obj}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L15_try_return;
+0270: except InvalidOperation as ex:
__Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_6, &__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_InvalidOperation); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 270, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ErrRestore(__pyx_t_2, __pyx_t_6, __pyx_t_7); __pyx_t_2 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.to_decimal", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_2) < 0) __PYX_ERR(0, 270, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_v_ex = __pyx_t_6; /*try:*/ { /* … */ /*finally:*/ { __pyx_L22_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_10 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; goto __pyx_L13_except_error; } } }
+0271: raise ValueError(
__pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 271, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0272: f"Invalid Decimal conversion of {obj}"
__pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 272, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Invalid_Decimal_conversion_of, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0273: ) from ex
__Pyx_Raise(__pyx_t_9, 0, 0, __pyx_v_ex); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 271, __pyx_L22_error) }
+0274: except (TypeError, ValueError):
__pyx_t_12 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_12) { __Pyx_AddTraceback("datamodel.converters.to_decimal", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 274, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+0275: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L14_except_return; } goto __pyx_L13_except_error;
0276:
+0277: TIMEDELTA_RE = re.compile(r"(-)?(\d{1,3}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?")
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEDELTA_RE, __pyx_t_2) < 0) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_u_d_1_3_d_1_2_d_1_2_d_1_6); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 277, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32);
0278:
+0279: cdef int _convert_second_fraction(s):
static int __pyx_f_9datamodel_10converters__convert_second_fraction(PyObject *__pyx_v_s) { int __pyx_r; __Pyx_INCREF(__pyx_v_s); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("datamodel.converters._convert_second_fraction", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0280: if not s:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_s); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 280, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0281: return 0
__pyx_r = 0; goto __pyx_L0;
0282: # Pad zeros to ensure the fraction length in microseconds
+0283: s = s.ljust(6, "0")
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_ljust); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_tuple__4 = PyTuple_Pack(2, __pyx_int_6, __pyx_kp_u_0); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4);
+0284: return int(s[:6])
__pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_s, 0, 6, NULL, NULL, &__pyx_slice__5, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; goto __pyx_L0; /* … */ __pyx_slice__5 = PySlice_New(Py_None, __pyx_int_6, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__5); __Pyx_GIVEREF(__pyx_slice__5);
0285:
+0286: cpdef object to_timedelta(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_19to_timedelta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_timedelta(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_m = NULL; PyObject *__pyx_v_groups = NULL; PyObject *__pyx_v_negate = NULL; PyObject *__pyx_v_hours = NULL; PyObject *__pyx_v_minutes = NULL; PyObject *__pyx_v_seconds = NULL; PyObject *__pyx_v_microseconds = NULL; PyObject *__pyx_v_tdelta = NULL; PyObject *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_obj); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("datamodel.converters.to_timedelta", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_m); __Pyx_XDECREF(__pyx_v_groups); __Pyx_XDECREF(__pyx_v_negate); __Pyx_XDECREF(__pyx_v_hours); __Pyx_XDECREF(__pyx_v_minutes); __Pyx_XDECREF(__pyx_v_seconds); __Pyx_XDECREF(__pyx_v_microseconds); __Pyx_XDECREF(__pyx_v_tdelta); __Pyx_XDECREF(__pyx_v_obj); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_19to_timedelta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_18to_timedelta, "to_timedelta(obj)"); static PyMethodDef __pyx_mdef_9datamodel_10converters_19to_timedelta = {"to_timedelta", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_19to_timedelta, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_18to_timedelta}; static PyObject *__pyx_pw_9datamodel_10converters_19to_timedelta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_timedelta (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_timedelta") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_timedelta", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_timedelta", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_18to_timedelta(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_18to_timedelta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_timedelta(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_timedelta", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_19to_timedelta, 0, __pyx_n_s_to_timedelta, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_timedelta, __pyx_t_2) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_timedelta, 286, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 286, __pyx_L1_error)
0287:
+0288: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0289: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0290: if isinstance(obj, datetime.timedelta):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_timedelta);
if (__pyx_t_1) {
/* … */
}
+0291: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0292:
+0293: if isinstance(obj, (bytes, bytearray)):
__pyx_t_2 = PyBytes_Check(__pyx_v_obj);
if (!__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_2 = PyByteArray_Check(__pyx_v_obj);
__pyx_t_1 = __pyx_t_2;
__pyx_L6_bool_binop_done:;
if (__pyx_t_1) {
/* … */
}
+0294: obj = obj.decode("ascii")
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_n_u_ascii}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_3); __pyx_t_3 = 0;
0295:
+0296: m = TIMEDELTA_RE.match(obj)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_TIMEDELTA_RE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_match); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_m = __pyx_t_3; __pyx_t_3 = 0;
+0297: if not m:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_m); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 297, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0298: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0299:
+0300: try:
{ /*try:*/ { /* … */ } __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L11_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L13_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; }
+0301: groups = list(m.groups())
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_m, __pyx_n_s_groups); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 301, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_groups = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0302: groups[-1] = _convert_second_fraction(groups[-1])
__pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_groups, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 302, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __pyx_f_9datamodel_10converters__convert_second_fraction(__pyx_t_5); if (unlikely(__pyx_t_10 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 302, __pyx_L9_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 302, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely((__Pyx_SetItemInt(__pyx_v_groups, -1L, __pyx_t_5, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0))) __PYX_ERR(0, 302, __pyx_L9_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0303: negate = -1 if groups[0] else 1
__pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_groups, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 303, __pyx_L9_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { __Pyx_INCREF(__pyx_int_neg_1); __pyx_t_5 = __pyx_int_neg_1; } else { __Pyx_INCREF(__pyx_int_1); __pyx_t_5 = __pyx_int_1; } __pyx_v_negate = __pyx_t_5; __pyx_t_5 = 0;
+0304: hours, minutes, seconds, microseconds = groups[1:]
__pyx_t_5 = __Pyx_PyList_GetSlice(__pyx_v_groups, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); if (1) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 304, __pyx_L9_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); __pyx_t_11 = PyList_GET_ITEM(sequence, 2); __pyx_t_12 = PyList_GET_ITEM(sequence, 3); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_11,&__pyx_t_12}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 304, __pyx_L9_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_hours = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_minutes = __pyx_t_4; __pyx_t_4 = 0; __pyx_v_seconds = __pyx_t_11; __pyx_t_11 = 0; __pyx_v_microseconds = __pyx_t_12; __pyx_t_12 = 0;
0305: tdelta = (
+0306: datetime.timedelta(
__pyx_t_12 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7cpython_8datetime_timedelta), __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 306, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0307: hours=int(hours),
__pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_hours); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 307, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_hours, __pyx_t_12) < 0) __PYX_ERR(0, 307, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0308: minutes=int(minutes),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_minutes); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_minutes, __pyx_t_12) < 0) __PYX_ERR(0, 307, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0309: seconds=int(seconds),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_seconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 309, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_seconds, __pyx_t_12) < 0) __PYX_ERR(0, 307, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0310: microseconds=int(microseconds),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_microseconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 310, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_microseconds, __pyx_t_12) < 0) __PYX_ERR(0, 307, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
0311: )
+0312: * negate
__pyx_t_5 = PyNumber_Multiply(__pyx_t_12, __pyx_v_negate); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 312, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_v_tdelta = __pyx_t_5; __pyx_t_5 = 0;
0313: )
+0314: return tdelta
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_tdelta); __pyx_r = __pyx_v_tdelta; goto __pyx_L13_try_return;
+0315: except ValueError:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.to_timedelta", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_12, &__pyx_t_11) < 0) __PYX_ERR(0, 315, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_11);
+0316: raise ValueError(
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 316, __pyx_L11_except_error) } goto __pyx_L11_except_error;
+0317: f"Invalid timedelta Object: {obj}"
__pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Invalid_timedelta_Object, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0318: )
0319:
+0320: TIME_RE = re.compile(r"(\d{1,2}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?")
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIME_RE, __pyx_t_2) < 0) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_u_d_1_2_d_1_2_d_1_2_d_1_6); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34);
0321:
+0322: cpdef object to_time(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_21to_time(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_time(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_m = NULL; PyObject *__pyx_v_groups = NULL; PyObject *__pyx_v_hours = NULL; PyObject *__pyx_v_minutes = NULL; PyObject *__pyx_v_seconds = NULL; PyObject *__pyx_v_microseconds = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("datamodel.converters.to_time", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_m); __Pyx_XDECREF(__pyx_v_groups); __Pyx_XDECREF(__pyx_v_hours); __Pyx_XDECREF(__pyx_v_minutes); __Pyx_XDECREF(__pyx_v_seconds); __Pyx_XDECREF(__pyx_v_microseconds); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_21to_time(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_20to_time, "to_time(obj)\nto_time.\n\n Returns obj converted to datetime.time.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_21to_time = {"to_time", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_21to_time, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_20to_time}; static PyObject *__pyx_pw_9datamodel_10converters_21to_time(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_time (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 322, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_time") < 0)) __PYX_ERR(0, 322, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_time", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 322, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_time", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_20to_time(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_20to_time(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_time(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_time", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_21to_time, 0, __pyx_n_s_to_time, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_time, __pyx_t_2) < 0) __PYX_ERR(0, 322, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_time, 322, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 322, __pyx_L1_error)
0323: """to_time.
0324:
0325: Returns obj converted to datetime.time.
0326: """
+0327: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0328: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0329: if isinstance(obj, datetime.time):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_time);
if (__pyx_t_1) {
/* … */
}
+0330: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0331: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 331, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0332: # its a function callable returning a value
+0333: try:
{ /*try:*/ { /* … */ } __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L9_try_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); }
+0334: return obj()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_6 = __pyx_v_obj; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L9_try_return;
+0335: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0336: pass
0337: else:
+0338: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L1_error; __pyx_L15_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L0; __pyx_L12_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); }
+0339: return datetime.time(*map(int, obj.split(':')))
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_u__6}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 339, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 339, __pyx_L11_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5)) __PYX_ERR(0, 339, __pyx_L11_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 339, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7cpython_8datetime_time), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 339, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L15_try_return;
+0340: except (ValueError, TypeError):
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError);
if (__pyx_t_9) {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L12_exception_handled;
}
goto __pyx_L13_except_error;
0341: pass
+0342: m = TIME_RE.match(obj)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_TIME_RE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_match); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_obj}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_v_m = __pyx_t_5; __pyx_t_5 = 0;
+0343: if not m:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_m); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 343, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_1); if (__pyx_t_10) { /* … */ }
+0344: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0345: try:
{ /*try:*/ { /* … */ } __pyx_L18_error:; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L20_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L22_try_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; } } __pyx_L4:;
+0346: groups = list(m.groups())
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_m, __pyx_n_s_groups); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 346, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PySequence_ListKeepNew(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 346, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_groups = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0;
+0347: groups[-1] = _convert_second_fraction(groups[-1])
__pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_groups, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 347, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __pyx_f_9datamodel_10converters__convert_second_fraction(__pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L18_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 347, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely((__Pyx_SetItemInt(__pyx_v_groups, -1L, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0))) __PYX_ERR(0, 347, __pyx_L18_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0348: hours, minutes, seconds, microseconds = groups
if (1) { PyObject* sequence = __pyx_v_groups; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 348, __pyx_L18_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); __pyx_t_6 = PyList_GET_ITEM(sequence, 2); __pyx_t_11 = PyList_GET_ITEM(sequence, 3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_11); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_5,&__pyx_t_6,&__pyx_t_11}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 348, __pyx_L18_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif } __pyx_v_hours = __pyx_t_7; __pyx_t_7 = 0; __pyx_v_minutes = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_seconds = __pyx_t_6; __pyx_t_6 = 0; __pyx_v_microseconds = __pyx_t_11; __pyx_t_11 = 0;
+0349: return datetime.time(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7cpython_8datetime_time), __pyx_empty_tuple, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L22_try_return;
+0350: hour=int(hours),
__pyx_t_11 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 350, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_hours); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_hour, __pyx_t_6) < 0) __PYX_ERR(0, 350, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0351: minute=int(minutes),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_minutes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 351, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_minute, __pyx_t_6) < 0) __PYX_ERR(0, 350, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0352: second=int(seconds),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_seconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 352, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_second, __pyx_t_6) < 0) __PYX_ERR(0, 350, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0353: microsecond=int(microseconds),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 353, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_microsecond, __pyx_t_6) < 0) __PYX_ERR(0, 350, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0354: )
+0355: except (TypeError, ValueError) as e:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.to_time", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_11, &__pyx_t_5) < 0) __PYX_ERR(0, 355, __pyx_L20_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_v_e = __pyx_t_11; /*try:*/ { /* … */ /*finally:*/ { __pyx_L29_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_9 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L20_except_error; } } } goto __pyx_L20_except_error;
+0356: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 356, __pyx_L29_error) }
+0357: f"Invalid Time/Timestamp Object {obj}: {e}"
__pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 357, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_Time_Timestamp_Object); __pyx_t_12 += 30; __Pyx_GIVEREF(__pyx_kp_u_Invalid_Time_Timestamp_Object); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Invalid_Time_Timestamp_Object); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 357, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u__7); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 357, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_7, 4, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 357, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0358: )
0359:
0360:
+0361: cpdef object strtobool(str val):
static PyObject *__pyx_pw_9datamodel_10converters_23strtobool(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_strtobool(PyObject *__pyx_v_val, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_val); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("datamodel.converters.strtobool", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_val); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_23strtobool(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_22strtobool, "strtobool(unicode val)\nConvert a string representation of truth to true (1) or false (0).\n\n True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values\n are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if\n 'val' is anything else.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_23strtobool = {"strtobool", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_23strtobool, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_22strtobool}; static PyObject *__pyx_pw_9datamodel_10converters_23strtobool(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_val = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("strtobool (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_val,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_val)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 361, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "strtobool") < 0)) __PYX_ERR(0, 361, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_val = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("strtobool", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 361, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.strtobool", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_val), (&PyUnicode_Type), 1, "val", 1))) __PYX_ERR(0, 361, __pyx_L1_error) __pyx_r = __pyx_pf_9datamodel_10converters_22strtobool(__pyx_self, __pyx_v_val); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_22strtobool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_val) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_strtobool(__pyx_v_val, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.strtobool", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_n_s_val); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_23strtobool, 0, __pyx_n_s_strtobool, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_strtobool, __pyx_t_2) < 0) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_strtobool, 361, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 361, __pyx_L1_error)
0362: """Convert a string representation of truth to true (1) or false (0).
0363:
0364: True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
0365: are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
0366: 'val' is anything else.
0367: """
+0368: val = val.lower()
__pyx_t_1 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_lower, __pyx_v_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_val, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+0369: if val in ('y', 'yes', 't', 'true', 'on', '1', 'T'):
__Pyx_INCREF(__pyx_v_val); __pyx_t_2 = __pyx_v_val; __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_y, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_yes, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_t, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_true, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_on, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_kp_u_1, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_T, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 369, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_3; if (__pyx_t_4) { /* … */ }
+0370: return True
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
+0371: elif val in ('n', 'no', 'f', 'false', 'off', '0', 'none', 'null'):
__Pyx_INCREF(__pyx_v_val); __pyx_t_2 = __pyx_v_val; __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_n, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_no, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_f, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_false, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_off, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_kp_u_0, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_none, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_null, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) __pyx_t_4 = __pyx_t_3; __pyx_L11_bool_binop_done:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_4; if (likely(__pyx_t_3)) { /* … */ }
+0372: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
0373: else:
+0374: raise ValueError(
/*else*/ { /* … */ __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 374, __pyx_L1_error) }
+0375: f"Invalid truth value for **'{val}'**"
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_truth_value_for); __pyx_t_5 += 27; __Pyx_GIVEREF(__pyx_kp_u_Invalid_truth_value_for); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Invalid_truth_value_for); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_val); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_6; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u__8); __pyx_t_5 += 3; __Pyx_GIVEREF(__pyx_kp_u__8); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__8); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0376: )
0377:
+0378: cpdef object to_boolean(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_25to_boolean(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_boolean(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_obj); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("datamodel.converters.to_boolean", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_25to_boolean(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_24to_boolean, "to_boolean(obj)\nto_boolean.\n\n Convert and returns any object value to boolean version.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_25to_boolean = {"to_boolean", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_25to_boolean, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_24to_boolean}; static PyObject *__pyx_pw_9datamodel_10converters_25to_boolean(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_boolean (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_boolean") < 0)) __PYX_ERR(0, 378, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_boolean", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 378, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_boolean", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_24to_boolean(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_24to_boolean(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_boolean(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_boolean", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_25to_boolean, 0, __pyx_n_s_to_boolean, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_boolean, __pyx_t_2) < 0) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_boolean, 378, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 378, __pyx_L1_error)
0379: """to_boolean.
0380:
0381: Convert and returns any object value to boolean version.
0382: """
+0383: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0384: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0385: if isinstance(obj, bool):
__pyx_t_2 = ((PyObject*)&PyBool_Type); __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0386: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0387: if isinstance(obj, (bytes, bytearray)):
__pyx_t_3 = PyBytes_Check(__pyx_v_obj);
if (!__pyx_t_3) {
} else {
__pyx_t_1 = __pyx_t_3;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_3 = PyByteArray_Check(__pyx_v_obj);
__pyx_t_1 = __pyx_t_3;
__pyx_L6_bool_binop_done:;
if (__pyx_t_1) {
/* … */
}
+0388: obj = obj.decode("ascii")
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_decode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_n_u_ascii}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_2); __pyx_t_2 = 0;
+0389: if isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0390: return strtobool(obj)
__Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_obj))||((__pyx_v_obj) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_obj))) __PYX_ERR(0, 390, __pyx_L1_error) __pyx_t_2 = __pyx_f_9datamodel_10converters_strtobool(((PyObject*)__pyx_v_obj), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0391: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 391, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L8; }
0392: # its a function callable returning a value
+0393: try:
{ /*try:*/ { /* … */ } __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L13_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L0; __pyx_L10_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); }
+0394: return obj()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_4 = __pyx_v_obj; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 394, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L13_try_return;
+0395: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L10_exception_handled;
}
0396: pass
0397: else:
+0398: return bool(obj)
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 398, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } __pyx_L8:;
0399:
+0400: cpdef object to_object(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_27to_object(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_object(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("datamodel.converters.to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_27to_object(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_26to_object, "to_object(obj)"); static PyMethodDef __pyx_mdef_9datamodel_10converters_27to_object = {"to_object", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_27to_object, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_26to_object}; static PyObject *__pyx_pw_9datamodel_10converters_27to_object(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_object (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_object") < 0)) __PYX_ERR(0, 400, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_object", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 400, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_26to_object(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_26to_object(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_object(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_27to_object, 0, __pyx_n_s_to_object, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_object, __pyx_t_2) < 0) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_object, 400, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 400, __pyx_L1_error)
+0401: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0402: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0403: if isinstance(obj, (list, dict,tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_obj); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = PyDict_Check(__pyx_v_obj); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_obj); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0404: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0405: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 405, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0406: # its a function callable returning a value
+0407: try:
{ /*try:*/ { /* … */ } __pyx_L8_error:; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L12_try_return:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L0; __pyx_L9_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); }
+0408: return obj()
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_t_7 = __pyx_v_obj; __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 408, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L12_try_return;
+0409: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L9_exception_handled;
}
0410: pass
+0411: elif isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (likely(__pyx_t_1)) {
/* … */
}
+0412: try:
{ /*try:*/ { /* … */ } __pyx_L14_error:; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L16_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3); goto __pyx_L1_error; __pyx_L18_try_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3); goto __pyx_L0; __pyx_L17_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3); goto __pyx_L0; }
+0413: return orjson.loads(obj)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_orjson); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 413, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_loads); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 413, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_obj}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 413, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L18_try_return;
+0414: except (TypeError, ValueError):
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_8, &__pyx_t_7) < 0) __PYX_ERR(0, 414, __pyx_L16_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7);
+0415: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L17_except_return; } goto __pyx_L16_except_error;
0416: else:
+0417: raise ValueError(
/*else*/ { /* … */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 417, __pyx_L1_error) } __pyx_L4:;
+0418: f"Can't convert invalid data {obj} to Object"
__pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Can_t_convert_invalid_data_2); __pyx_t_11 += 27; __Pyx_GIVEREF(__pyx_kp_u_Can_t_convert_invalid_data_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Can_t_convert_invalid_data_2); __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u_to_Object); __pyx_t_11 += 10; __Pyx_GIVEREF(__pyx_kp_u_to_Object); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u_to_Object); __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0419: )
0420:
+0421: cpdef bytes to_bytes(object obj):
static PyObject *__pyx_pw_9datamodel_10converters_29to_bytes(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_to_bytes(PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datamodel.converters.to_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_29to_bytes(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_28to_bytes, "to_bytes(obj) -> bytes\n\n Convert the given object to bytes.\n\n - If the object is already bytes, return it directly.\n - If the object is a string, encode it (using UTF-8).\n - If the object is callable, call it and convert its result.\n - Otherwise, attempt to convert the object to bytes.\n If conversion fails, raise a ValueError.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_29to_bytes = {"to_bytes", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_29to_bytes, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_28to_bytes}; static PyObject *__pyx_pw_9datamodel_10converters_29to_bytes(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_bytes (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 421, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_bytes") < 0)) __PYX_ERR(0, 421, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_bytes", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 421, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.to_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_28to_bytes(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_28to_bytes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_to_bytes(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.to_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_29to_bytes, 0, __pyx_n_s_to_bytes, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_bytes, __pyx_t_2) < 0) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_bytes, 421, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 421, __pyx_L1_error)
0422: """
0423: Convert the given object to bytes.
0424:
0425: - If the object is already bytes, return it directly.
0426: - If the object is a string, encode it (using UTF-8).
0427: - If the object is callable, call it and convert its result.
0428: - Otherwise, attempt to convert the object to bytes.
0429: If conversion fails, raise a ValueError.
0430: """
+0431: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (unlikely(__pyx_t_1)) { /* … */ }
+0432: raise ValueError("Cannot convert None to bytes")
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 432, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 432, __pyx_L1_error) /* … */ __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Cannot_convert_None_to_bytes); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 432, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9);
0433:
0434: # 1. If already bytes, return as is.
+0435: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0436: return obj
__Pyx_XDECREF(__pyx_r); if (!(likely(PyBytes_CheckExact(__pyx_v_obj))||((__pyx_v_obj) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_v_obj))) __PYX_ERR(0, 436, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyObject*)__pyx_v_obj); goto __pyx_L0;
0437:
0438: # 2. If it's a string, encode it to bytes.
+0439: elif isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0440: return obj.encode("utf-8")
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_kp_u_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_2))) __PYX_ERR(0, 440, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0;
0441:
0442: # 3. If it's callable, attempt to call it and convert its result.
+0443: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 443, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0444: try:
{ /*try:*/ { /* … */ } __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L9_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; }
+0445: result = obj()
__Pyx_INCREF(__pyx_v_obj); __pyx_t_3 = __pyx_v_obj; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 445, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_result = __pyx_t_2; __pyx_t_2 = 0;
0446: # Recursively convert the result.
+0447: return to_bytes(result)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __pyx_f_9datamodel_10converters_to_bytes(__pyx_v_result, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 447, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L9_try_return;
+0448: except Exception as e:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.to_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 448, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L16_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_9 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13; goto __pyx_L7_except_error; } } } goto __pyx_L7_except_error;
+0449: raise ValueError("Failed to convert callable to bytes: %s" % e)
__pyx_t_10 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Failed_to_convert_callable_to_by, __pyx_v_e); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 449, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 449, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 449, __pyx_L16_error) }
0450:
0451: # 4. Try converting the object into bytes using Python's built-in conversion.
+0452: try:
{ /*try:*/ { /* … */ } __pyx_L22_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L24_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L1_error; __pyx_L26_try_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L0; }
+0453: return bytes(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 453, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L26_try_return;
+0454: except Exception as e:
__pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_12) { __Pyx_AddTraceback("datamodel.converters.to_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 454, __pyx_L24_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L33_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_14); __pyx_t_12 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_20 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_15, __pyx_t_14); } __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_19, __pyx_t_18, __pyx_t_17); __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_20; goto __pyx_L24_except_error; } } } goto __pyx_L24_except_error;
+0455: raise ValueError("Invalid conversion to bytes: %s" % e)
__pyx_t_11 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Invalid_conversion_to_bytes_s, __pyx_v_e); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 455, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 455, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 455, __pyx_L33_error) }
0456:
+0457: cdef bint is_callable(object value) nogil:
static int __pyx_f_9datamodel_10converters_is_callable(PyObject *__pyx_v_value) { int __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; #ifdef WITH_THREAD __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_AddTraceback("datamodel.converters.is_callable", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __pyx_L0:; return __pyx_r; }
0458: """
0459: Check if `value` is callable by calling Python's callable(...)
0460: but reacquire the GIL inside.
0461: """
+0462: with gil:
{ #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif /*try:*/ { /* … */ /*finally:*/ { __pyx_L3_return: { #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif goto __pyx_L0; } __pyx_L4_error: { #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif goto __pyx_L1_error; } } }
+0463: return callable(value)
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_value); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 463, __pyx_L4_error) __pyx_r = __pyx_t_1; goto __pyx_L3_return; }
0464:
0465:
0466: # Encoder List:
0467: encoders = {
+0468: str: to_string,
__pyx_t_2 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_to_string); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)(&PyUnicode_Type)), __pyx_t_3) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0469: UUID: to_uuid,
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_uuid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0470: pgproto.UUID: to_uuid,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_UUID); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_uuid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, __pyx_t_3, __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0471: bool: to_boolean,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_boolean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject*)&PyBool_Type), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0472: int: to_integer,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_integer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)(&PyInt_Type)), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0473: float: to_float,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_float); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)(&PyFloat_Type)), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0474: datetime.date: to_date,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_date); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_ptype_7cpython_8datetime_date), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0475: datetime.datetime: to_datetime,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_ptype_7cpython_8datetime_datetime), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0476: datetime.timedelta: to_timedelta,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_timedelta); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_ptype_7cpython_8datetime_timedelta), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0477: datetime.time: to_time,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_ptype_7cpython_8datetime_time), __pyx_t_4) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0478: Decimal: to_decimal,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_to_decimal); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_2, __pyx_t_4, __pyx_t_3) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0479: bytes: to_bytes,
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_to_bytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_2, ((PyObject *)(&PyBytes_Type)), __pyx_t_3) < 0) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_encoders, __pyx_t_2) < 0) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0480: # dict: to_object,
0481: # list: to_object,
0482: # tuple: to_object,
0483: }
0484:
0485:
0486: # Maps a type to a conversion callable
+0487: cdef dict TYPE_PARSERS = {}
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_v_9datamodel_10converters_TYPE_PARSERS); __Pyx_DECREF_SET(__pyx_v_9datamodel_10converters_TYPE_PARSERS, ((PyObject*)__pyx_t_2)); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
0488:
0489:
+0490: cpdef object register_parser(object _type, object parser_func):
static PyObject *__pyx_pw_9datamodel_10converters_31register_parser(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_register_parser(PyObject *__pyx_v__type, PyObject *__pyx_v_parser_func, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("datamodel.converters.register_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_31register_parser(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_30register_parser, "register_parser(_type, parser_func)\nregister_parser.\n\n Register a new Parser function for a given type.\n\n Parameters:\n _type (type): The type for which the parser function is registered.\n parser_func (function): The parser function to convert the given type.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_31register_parser = {"register_parser", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_31register_parser, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_30register_parser}; static PyObject *__pyx_pw_9datamodel_10converters_31register_parser(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v__type = 0; PyObject *__pyx_v_parser_func = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("register_parser (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_type,&__pyx_n_s_parser_func,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_type)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 490, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_parser_func)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 490, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("register_parser", 1, 2, 2, 1); __PYX_ERR(0, 490, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "register_parser") < 0)) __PYX_ERR(0, 490, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v__type = values[0]; __pyx_v_parser_func = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("register_parser", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 490, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.register_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_30register_parser(__pyx_self, __pyx_v__type, __pyx_v_parser_func); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_30register_parser(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v__type, PyObject *__pyx_v_parser_func) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_register_parser(__pyx_v__type, __pyx_v_parser_func, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.register_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__41 = PyTuple_Pack(2, __pyx_n_s_type, __pyx_n_s_parser_func); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__41); __Pyx_GIVEREF(__pyx_tuple__41); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_31register_parser, 0, __pyx_n_s_register_parser, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_register_parser, __pyx_t_2) < 0) __PYX_ERR(0, 490, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_register_parser, 490, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 490, __pyx_L1_error)
0491: """register_parser.
0492:
0493: Register a new Parser function for a given type.
0494:
0495: Parameters:
0496: _type (type): The type for which the parser function is registered.
0497: parser_func (function): The parser function to convert the given type.
0498: """
+0499: TYPE_PARSERS[_type] = parser_func
if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 499, __pyx_L1_error) } if (unlikely((PyDict_SetItem(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v__type, __pyx_v_parser_func) < 0))) __PYX_ERR(0, 499, __pyx_L1_error)
0500:
0501:
0502: ## Parsing Functions
0503:
+0504: cdef object _parse_dict_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_dict_type(PyObject *__pyx_v_field, CYTHON_UNUSED PyObject *__pyx_v_T, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder, PyObject *__pyx_v_args) { PyObject *__pyx_v_val_type = 0; PyObject *__pyx_v_new_dict = 0; PyObject *__pyx_v_k = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("datamodel.converters._parse_dict_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_val_type); __Pyx_XDECREF(__pyx_v_new_dict); __Pyx_XDECREF(__pyx_v_k); __Pyx_XDECREF(__pyx_v_v); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0505: object field,
0506: object T,
0507: object data,
0508: object encoder,
0509: object args
0510: ):
+0511: cdef object val_type = args[1]
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_val_type = __pyx_t_1; __pyx_t_1 = 0;
+0512: cdef dict new_dict = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_new_dict = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0513: for k, v in data.items():
__pyx_t_2 = 0; if (unlikely(__pyx_v_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 513, __pyx_L1_error) } __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_data, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; while (1) { __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4); if (unlikely(__pyx_t_7 == 0)) break; if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6); __pyx_t_6 = 0;
+0514: new_dict[k] = _parse_typing(field, val_type, v, encoder, False)
__pyx_t_8.__pyx_n = 2; __pyx_t_8.encoder = __pyx_v_encoder; __pyx_t_8.as_objects = Py_False; __pyx_t_6 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_val_type, __pyx_v_v, &__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_6) < 0))) __PYX_ERR(0, 514, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0515: return new_dict
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_dict); __pyx_r = __pyx_v_new_dict; goto __pyx_L0;
0516:
+0517: cdef object _parse_list_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_list_type(PyObject *__pyx_v_field, CYTHON_UNUSED PyObject *__pyx_v_T, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder, PyObject *__pyx_v_args, struct __pyx_opt_args_9datamodel_10converters__parse_list_type *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arg_type); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_converter); __Pyx_XDECREF(__pyx_v_inner_type); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__parse_list_type { int __pyx_n; PyObject *_parent; };
0518: object field,
0519: object T,
0520: object data,
0521: object encoder,
0522: object args,
+0523: object _parent = None
PyObject *__pyx_v__parent = ((PyObject *)Py_None);
PyObject *__pyx_v_arg_type = 0;
PyObject *__pyx_v_result = 0;
PyObject *__pyx_v_key = 0;
PyObject *__pyx_v_converter = 0;
PyObject *__pyx_v_inner_type = 0;
PyObject *__pyx_v_d = NULL;
PyObject *__pyx_v_item = NULL;
PyObject *__pyx_v_e = NULL;
PyObject *__pyx_r = NULL;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v__parent = __pyx_optional_args->_parent;
}
}
__Pyx_INCREF(__pyx_v_data);
0524: ):
0525: """
0526: Parse a list of items to a typing type.
0527: """
+0528: cdef object arg_type = args[0]
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+0529: cdef list result = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0530: cdef tuple key = (arg_type, field.name)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_arg_type); __Pyx_GIVEREF(__pyx_v_arg_type); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_arg_type)) __PYX_ERR(0, 530, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error); __pyx_t_1 = 0; __pyx_v_key = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+0531: cdef object converter = TYPE_PARSERS.get(key) or TYPE_PARSERS.get(arg_type)
if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 531, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 531, __pyx_L1_error) if (!__pyx_t_3) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3_bool_binop_done; } if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 531, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v_arg_type, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_L3_bool_binop_done:; __pyx_v_converter = __pyx_t_2; __pyx_t_2 = 0;
+0532: cdef object inner_type = field._inner_type or arg_type
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 532, __pyx_L1_error) if (!__pyx_t_3) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L5_bool_binop_done; } __Pyx_INCREF(__pyx_v_arg_type); __pyx_t_2 = __pyx_v_arg_type; __pyx_L5_bool_binop_done:; __pyx_v_inner_type = __pyx_t_2; __pyx_t_2 = 0;
0533:
+0534: if data is None:
__pyx_t_3 = (__pyx_v_data == Py_None); if (__pyx_t_3) { /* … */ }
+0535: return [] # short-circuit
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0536:
+0537: if not isinstance(data, (list, tuple)):
__pyx_t_4 = PyList_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L9_bool_binop_done; } __pyx_t_4 = PyTuple_Check(__pyx_v_data); __pyx_t_3 = __pyx_t_4; __pyx_L9_bool_binop_done:; __pyx_t_4 = (!__pyx_t_3); if (__pyx_t_4) { /* … */ }
+0538: data = [data]
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_data)) __PYX_ERR(0, 538, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
0539:
0540: # If it's a dataclass
+0541: if is_dc(inner_type):
__pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_inner_type); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 541, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+0542: for d in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_2 = __pyx_v_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 542, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 542, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 542, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 542, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 542, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 542, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0543: if is_dc(d):
__pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_d); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 543, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+0544: result.append(d)
__pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_d); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 544, __pyx_L1_error)
+0545: if converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 545, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L15; }
+0546: result.append(
__pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0547: converter(field.name, d, inner_type, _parent)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 547, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_converter); __pyx_t_9 = __pyx_v_converter; __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_10, __pyx_t_8, __pyx_v_d, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_11, 4+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; }
0548: )
0549: else:
+0550: if isinstance(d, dict):
/*else*/ {
__pyx_t_4 = PyDict_Check(__pyx_v_d);
if (__pyx_t_4) {
/* … */
goto __pyx_L16;
}
+0551: result.append(inner_type(**d))
if (unlikely(__pyx_v_d == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 551, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_d))) { __pyx_t_1 = PyDict_Copy(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 551, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_9 = __Pyx_PyObject_Call(__pyx_v_inner_type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 551, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 551, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0552: elif isinstance(d, (list, tuple)):
__pyx_t_3 = PyList_Check(__pyx_v_d); if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L17_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_d); __pyx_t_4 = __pyx_t_3; __pyx_L17_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L16; }
+0553: result.append(inner_type(*d))
__pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_inner_type, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0554: else:
+0555: result.append(inner_type(d))
/*else*/ { __Pyx_INCREF(__pyx_v_inner_type); __pyx_t_9 = __pyx_v_inner_type; __pyx_t_8 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_d}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 555, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L16:; } __pyx_L15:;
+0556: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+0557: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 557, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L11; }
+0558: for item in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_2 = __pyx_v_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 558, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 558, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 558, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 558, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 558, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 558, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0559: result.append(
__pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 559, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0560: converter(field.name, item, inner_type, _parent)
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_converter); __pyx_t_8 = __pyx_v_converter; __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_10, __pyx_t_9, __pyx_v_item, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_11, 4+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
0561: )
+0562: elif is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_inner_type}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_4) { /* … */ goto __pyx_L11; }
+0563: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L28_try_end; __pyx_L23_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L25_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L1_error; __pyx_L28_try_end:; }
+0564: result = rc.to_list(inner_type, data)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_to_list); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 564, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_v_inner_type, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_11, 2+__pyx_t_11); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_2))) __PYX_ERR(0, 564, __pyx_L23_error) __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
0565: # return data
+0566: except Exception as e:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_8, &__pyx_t_1) < 0) __PYX_ERR(0, 566, __pyx_L25_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __pyx_v_e = __pyx_t_8; /*try:*/ { /* … */ /*finally:*/ { __pyx_L34_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __pyx_t_15 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24); } __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21); __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18; goto __pyx_L25_except_error; } } } goto __pyx_L25_except_error;
+0567: raise ValueError(
__pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 567, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0568: f"Error parsing list of {inner_type}: {e}"
__pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 568, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = 0; __pyx_t_16 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_list_of); __pyx_t_5 += 22; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_list_of); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Error_parsing_list_of); __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_inner_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 568, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_16; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_5 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__7); __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 568, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_16; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_9, 4, __pyx_t_5, __pyx_t_16); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 568, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0569: ) from e
__Pyx_Raise(__pyx_t_9, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 567, __pyx_L34_error) }
0570: else:
+0571: for item in data:
/*else*/ { if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 571, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 571, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 571, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 571, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 571, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_6(__pyx_t_1); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 571, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_8); __pyx_t_8 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L11:;
+0572: result.append(
__pyx_t_7 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_8); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+0573: _parse_typing(field, T=inner_type, data=item, encoder=encoder, as_objects=False)
__pyx_t_25.__pyx_n = 2; __pyx_t_25.encoder = __pyx_v_encoder; __pyx_t_25.as_objects = Py_False; __pyx_t_8 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, &__pyx_t_25); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 573, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8);
0574: )
+0575: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0576:
+0577: cdef object _parse_dataclass_type(object T, object data):
static PyObject *__pyx_f_9datamodel_10converters__parse_dataclass_type(PyObject *__pyx_v_T, PyObject *__pyx_v_data) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("datamodel.converters._parse_dataclass_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0578: if isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0579: return T(**data)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 579, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_2 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_2 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_T, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+0580: elif isinstance(data, (list, tuple)):
__pyx_t_4 = PyList_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = PyTuple_Check(__pyx_v_data); __pyx_t_1 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0581: return T(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_T, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0582: else:
+0583: return T(data)
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_T); __pyx_t_3 = __pyx_v_T; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; }
0584:
+0585: cdef object _parse_builtin_type(object field, object T, object data, object encoder):
static PyObject *__pyx_f_9datamodel_10converters__parse_builtin_type(PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder) { PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_data); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_23); __Pyx_AddTraceback("datamodel.converters._parse_builtin_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0586: if encoder is not None:
__pyx_t_1 = (__pyx_v_encoder != Py_None); if (__pyx_t_1) { /* … */ }
+0587: try:
{ /*try:*/ { /* … */ } __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L8_try_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; }
+0588: return encoder(data)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_encoder); __pyx_t_6 = __pyx_v_encoder; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_data}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 588, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L8_try_return;
+0589: except ValueError as e:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._parse_builtin_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 589, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_v_e = __pyx_t_6; /*try:*/ { /* … */ /*finally:*/ { __pyx_L15_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_9 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15; goto __pyx_L6_except_error; } } } goto __pyx_L6_except_error;
+0590: raise ValueError(f"Error parsing type {T}, {e}")
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 590, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_type); __pyx_t_11 += 19; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_type); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Error_parsing_type); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 590, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__10); __pyx_t_11 += 2; __Pyx_GIVEREF(__pyx_kp_u__10); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u__10); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 590, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 590, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 590, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 590, __pyx_L15_error) }
+0591: if T == str:
__pyx_t_7 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 591, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 591, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0592: return to_string(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __pyx_f_9datamodel_10converters_to_string(__pyx_v_data, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0593: if T == datetime.date:
__pyx_t_7 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)__pyx_ptype_7cpython_8datetime_date), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 593, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0594: return to_date(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = ((PyObject *)__pyx_f_9datamodel_10converters_to_date(__pyx_v_data, 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0595: if T == datetime.datetime:
__pyx_t_7 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)__pyx_ptype_7cpython_8datetime_datetime), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 595, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 595, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0596: return to_datetime(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = ((PyObject *)__pyx_f_9datamodel_10converters_to_datetime(__pyx_v_data, 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0597: if T == UUID:
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_UUID); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyObject_RichCompare(__pyx_v_T, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { /* … */ }
+0598: return to_uuid(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __pyx_f_9datamodel_10converters_to_uuid(__pyx_v_data, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0599: elif is_dc(T):
__pyx_t_1 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_T); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 599, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0600: return _parse_dataclass_type(T, data)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __pyx_f_9datamodel_10converters__parse_dataclass_type(__pyx_v_T, __pyx_v_data); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0601: elif T == dict:
__pyx_t_6 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 601, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 601, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { /* … */ }
+0602: if not isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
__pyx_t_22 = (!__pyx_t_1);
if (unlikely(__pyx_t_22)) {
/* … */
}
+0603: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 603, __pyx_L1_error)
+0604: f"Expected dict, got {type(data).__name__}"
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_6, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expected_dict_got, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0605: )
+0606: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0607: elif T == list:
__pyx_t_7 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 607, __pyx_L1_error) __pyx_t_22 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_22 < 0))) __PYX_ERR(0, 607, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_22) { /* … */ }
+0608: if not isinstance(data, (list, tuple)):
__pyx_t_1 = PyList_Check(__pyx_v_data); if (!__pyx_t_1) { } else { __pyx_t_22 = __pyx_t_1; goto __pyx_L27_bool_binop_done; } __pyx_t_1 = PyTuple_Check(__pyx_v_data); __pyx_t_22 = __pyx_t_1; __pyx_L27_bool_binop_done:; __pyx_t_1 = (!__pyx_t_22); if (__pyx_t_1) { /* … */ }
+0609: data = [data]
__pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 609, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_v_data)) __PYX_ERR(0, 609, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_7); __pyx_t_7 = 0;
+0610: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0611: else:
0612: # Try encoders dict:
+0613: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L29_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L31_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L1_error; __pyx_L33_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L0; __pyx_L32_except_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L0; } }
+0614: if field._encoder_fn is None:
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_encoder_fn); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 614, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = (__pyx_t_7 == Py_None); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0615: field._encoder_fn = encoders[T]
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_encoders); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 615, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_v_T); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 615, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_encoder_fn, __pyx_t_6) < 0) __PYX_ERR(0, 615, __pyx_L29_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0616: return field._encoder_fn(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_encoder_fn); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 616, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_data}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 616, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L33_try_return;
+0617: except KeyError:
__pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_14) { __Pyx_AddTraceback("datamodel.converters._parse_builtin_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 617, __pyx_L31_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5);
0618: # attempt direct construction:
+0619: if isinstance(T, type):
__pyx_t_1 = PyType_Check(__pyx_v_T);
if (__pyx_t_1) {
/* … */
}
+0620: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L46_try_end; __pyx_L39_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; /* … */ __pyx_L41_except_error:; __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19); goto __pyx_L31_except_error; __pyx_L43_try_return:; __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19); goto __pyx_L32_except_return; __pyx_L40_exception_handled:; __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19); __pyx_L46_try_end:; }
+0621: if isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0622: return T(**data)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 622, __pyx_L39_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_10 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 622, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_10); } else { __pyx_t_10 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_data); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 622, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_10); } __pyx_t_13 = __Pyx_PyObject_Call(__pyx_v_T, __pyx_empty_tuple, __pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 622, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_r = __pyx_t_13; __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L43_try_return;
+0623: elif isinstance(data, (list, tuple)):
__pyx_t_22 = PyList_Check(__pyx_v_data); if (!__pyx_t_22) { } else { __pyx_t_1 = __pyx_t_22; goto __pyx_L48_bool_binop_done; } __pyx_t_22 = PyTuple_Check(__pyx_v_data); __pyx_t_1 = __pyx_t_22; __pyx_L48_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0624: return T(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 624, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_v_T, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 624, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L43_try_return;
+0625: elif isinstance(data, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0626: return T(data)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_T); __pyx_t_13 = __pyx_v_T; __pyx_t_23 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_23)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_23); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_v_data}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 626, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L43_try_return;
+0627: except (TypeError, ValueError):
__pyx_t_14 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError);
if (__pyx_t_14) {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L40_exception_handled;
}
goto __pyx_L41_except_error;
0628: pass
+0629: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L32_except_return; }
+0630: except (TypeError) as e:
__pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_14) { __Pyx_AddTraceback("datamodel.converters._parse_builtin_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 630, __pyx_L31_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_v_e = __pyx_t_7; /*try:*/ { /* … */ /*finally:*/ { __pyx_L55_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_16); __pyx_t_14 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_24 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16); } __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21); __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_24; goto __pyx_L31_except_error; } } }
+0631: raise TypeError(f"Error type {T}: {e}") from e
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 631, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Error_type); __pyx_t_11 += 11; __Pyx_GIVEREF(__pyx_kp_u_Error_type); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Error_type); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 631, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_11 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u__7); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 631, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 631, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 631, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 631, __pyx_L55_error) }
+0632: except (ValueError) as e:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._parse_builtin_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 632, __pyx_L31_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_v_e = __pyx_t_7; /*try:*/ { /* … */ /*finally:*/ { __pyx_L66_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __pyx_t_9 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_25 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_20, __pyx_t_19); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_25; goto __pyx_L31_except_error; } } } goto __pyx_L31_except_error;
+0633: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 633, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+0634: f"Error parsing type {T}: {e}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 634, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_type); __pyx_t_11 += 19; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_type); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Error_parsing_type); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 634, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_11 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u__7); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 634, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 634, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0635: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 633, __pyx_L66_error) }
0636:
+0637: cpdef object parse_basic(object T, object data, object encoder = None):
static PyObject *__pyx_pw_9datamodel_10converters_33parse_basic(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_parse_basic(PyObject *__pyx_v_T, PyObject *__pyx_v_data, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_9datamodel_10converters_parse_basic *__pyx_optional_args) { PyObject *__pyx_v_encoder = ((PyObject *)Py_None); PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_encoder = __pyx_optional_args->encoder; } } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_33parse_basic(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_32parse_basic, "parse_basic(T, data, encoder=None)\nparse_basic.\n\n Parse a value to primitive types as str or int.\n --- (int, float, str, bool, bytes)\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_33parse_basic = {"parse_basic", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_33parse_basic, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_32parse_basic}; static PyObject *__pyx_pw_9datamodel_10converters_33parse_basic(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_T = 0; PyObject *__pyx_v_data = 0; PyObject *__pyx_v_encoder = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("parse_basic (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_T,&__pyx_n_s_data,&__pyx_n_s_encoder,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_T)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 637, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 637, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_basic", 0, 2, 3, 1); __PYX_ERR(0, 637, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoder); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 637, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "parse_basic") < 0)) __PYX_ERR(0, 637, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_T = values[0]; __pyx_v_data = values[1]; __pyx_v_encoder = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parse_basic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 637, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_32parse_basic(__pyx_self, __pyx_v_T, __pyx_v_data, __pyx_v_encoder); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_32parse_basic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_T, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.encoder = __pyx_v_encoder; __pyx_t_1 = __pyx_f_9datamodel_10converters_parse_basic(__pyx_v_T, __pyx_v_data, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_tuple__43 = PyTuple_Pack(3, __pyx_n_s_T, __pyx_n_s_data, __pyx_n_s_encoder); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__43); __Pyx_GIVEREF(__pyx_tuple__43); __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_parse_basic, 637, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 637, __pyx_L1_error) /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_33parse_basic, 0, __pyx_n_s_parse_basic, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__45); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_basic, __pyx_t_2) < 0) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__45 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__45); __Pyx_GIVEREF(__pyx_tuple__45); /* … */ struct __pyx_opt_args_9datamodel_10converters_parse_basic { int __pyx_n; PyObject *encoder; };
0638: """parse_basic.
0639:
0640: Parse a value to primitive types as str or int.
0641: --- (int, float, str, bool, bytes)
0642: """
+0643: if T == str:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0644: if isinstance(data, str):
__pyx_t_2 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0645: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0646: elif data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0647: return str(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_Unicode(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0648: if T == int:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0649: if isinstance(data, int):
__pyx_t_2 = PyInt_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0650: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0651: elif data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0652: return int(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0653: if T == bytes:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyBytes_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 653, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0654: if data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0655: return bytes(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0656: if T == UUID or T == pgproto.UUID:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_RichCompare(__pyx_v_T, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L10_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_RichCompare(__pyx_v_T, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __pyx_L10_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0657: return to_uuid(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_f_9datamodel_10converters_to_uuid(__pyx_v_data, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+0658: if T == bool:
__pyx_t_3 = PyObject_RichCompare(__pyx_v_T, ((PyObject*)&PyBool_Type), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 658, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0659: if isinstance(data, bool):
__pyx_t_3 = ((PyObject*)&PyBool_Type); __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = PyObject_IsInstance(__pyx_v_data, __pyx_t_3); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 659, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0660: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0661: # function encoder:
+0662: if encoder:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 662, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+0663: if is_callable(encoder):
__pyx_t_2 = __pyx_f_9datamodel_10converters_is_callable(__pyx_v_encoder); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 663, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
0664: # using a function encoder:
+0665: try:
{ /*try:*/ { /* … */ } __pyx_L16_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L18_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L20_try_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L0; __pyx_L19_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L0; }
+0666: return encoder(data)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_encoder); __pyx_t_1 = __pyx_v_encoder; __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_data}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L20_try_return;
+0667: except TypeError as e:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_8) < 0) __PYX_ERR(0, 667, __pyx_L18_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L27_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_10 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L18_except_error; } } }
+0668: raise TypeError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 668, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0669: f"Type Error for Encoder {encoder!s} for type {T}: {e}"
__pyx_t_11 = PyTuple_New(6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 669, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Type_Error_for_Encoder); __pyx_t_12 += 23; __Pyx_GIVEREF(__pyx_kp_u_Type_Error_for_Encoder); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Type_Error_for_Encoder); __pyx_t_14 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_encoder), __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 669, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_for_type); __pyx_t_12 += 10; __Pyx_GIVEREF(__pyx_kp_u_for_type); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_for_type); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 669, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_kp_u__7); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 669, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_11, 6, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 669, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0670: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 668, __pyx_L27_error) }
+0671: except ValueError as e:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 671, __pyx_L18_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L38_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_15 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_23 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ErrRestore(__pyx_t_22, __pyx_t_21, __pyx_t_20); __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_23; goto __pyx_L18_except_error; } } }
+0672: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 672, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 672, __pyx_L38_error) }
+0673: f"Error parsing type {T}, {e}"
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 673, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_type); __pyx_t_12 += 19; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_type); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Error_parsing_type); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 673, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__10); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__10); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u__10); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 673, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_11, 4, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 673, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0674: )
+0675: except AttributeError as e:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_8) < 0) __PYX_ERR(0, 675, __pyx_L18_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L49_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_10 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_24 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_24; goto __pyx_L18_except_error; } __pyx_L48_return: { __pyx_t_22 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; __pyx_r = __pyx_t_22; __pyx_t_22 = 0; goto __pyx_L19_except_return; } } } goto __pyx_L18_except_error;
+0676: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+0677: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L48_return;
+0678: raise AttributeError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 678, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0679: f"Attribute Error for Encoder {encoder!s} for type {T}: {e}"
__pyx_t_11 = PyTuple_New(6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 679, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Attribute_Error_for_Encoder); __pyx_t_12 += 28; __Pyx_GIVEREF(__pyx_kp_u_Attribute_Error_for_Encoder); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Attribute_Error_for_Encoder); __pyx_t_14 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_encoder), __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 679, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_for_type); __pyx_t_12 += 10; __Pyx_GIVEREF(__pyx_kp_u_for_type); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_for_type); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 679, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_kp_u__7); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 679, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_11, 6, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 679, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0680: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 678, __pyx_L49_error) }
0681: # Using the encoders for basic types:
+0682: try:
{ /*try:*/ { /* … */ } __pyx_L56_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L58_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5); goto __pyx_L1_error; __pyx_L60_try_return:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5); goto __pyx_L0; __pyx_L57_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5); }
+0683: return encoders[T](data)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_encoders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L56_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 683, __pyx_L56_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_data}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 683, __pyx_L56_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_8; __pyx_t_8 = 0; goto __pyx_L60_try_return;
+0684: except KeyError:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_15) { __Pyx_ErrRestore(0,0,0); goto __pyx_L57_exception_handled; }
0685: pass
+0686: except TypeError as e:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 686, __pyx_L58_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L67_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_15 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_25 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ErrRestore(__pyx_t_22, __pyx_t_21, __pyx_t_20); __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_25; goto __pyx_L58_except_error; } } }
+0687: raise TypeError(f"Error type {T}: {e}") from e
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 687, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Error_type); __pyx_t_12 += 11; __Pyx_GIVEREF(__pyx_kp_u_Error_type); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Error_type); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 687, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u__7); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 687, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_11, 4, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 687, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 687, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 687, __pyx_L67_error) }
+0688: except ValueError as e:
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_AddTraceback("datamodel.converters.parse_basic", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_8) < 0) __PYX_ERR(0, 688, __pyx_L58_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L78_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_10 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_26 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_26; goto __pyx_L58_except_error; } } } goto __pyx_L58_except_error;
+0689: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0690: f"Error parsing type {T}: {e}"
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 690, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_type); __pyx_t_12 += 19; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_type); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Error_parsing_type); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 690, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u__7); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 690, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_11, 4, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 690, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0691: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 689, __pyx_L78_error) }
0692:
0693:
+0694: cdef object _parse_typing_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_typing_type(PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_name, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder, PyObject *__pyx_v_origin, PyObject *__pyx_v_args, struct __pyx_opt_args_9datamodel_10converters__parse_typing_type *__pyx_optional_args) { struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *__pyx_cur_scope; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("datamodel.converters._parse_typing_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator1); __Pyx_XDECREF(__pyx_v_data); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__parse_typing_type { int __pyx_n; PyObject *as_objects; }; /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type { PyObject_HEAD PyObject *__pyx_v_encoder; PyObject *__pyx_v_field; PyObject *__pyx_v_type_args; };
0695: object field,
0696: object T,
0697: object name,
0698: object data,
0699: object encoder,
0700: object origin,
0701: object args,
+0702: object as_objects=False
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False); PyObject *__pyx_7genexpr__pyx_v_k = NULL; PyObject *__pyx_7genexpr__pyx_v_v = NULL; PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator = 0; PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator1 = 0; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type(__pyx_ptype_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 694, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_as_objects = __pyx_optional_args->as_objects; } } __pyx_cur_scope->__pyx_v_field = __pyx_v_field; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_field); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_field); __pyx_cur_scope->__pyx_v_encoder = __pyx_v_encoder; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_encoder); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_encoder); __Pyx_INCREF(__pyx_v_data);
0703: ):
0704: """
0705: Handle field_type='typing' scenario.
0706: """
+0707: cdef tuple type_args = getattr(T, '__args__', ())
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_T, __pyx_n_u_args, __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_type_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
0708:
+0709: if field.origin in {dict, Mapping} or name in {'Dict', 'Mapping'}:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L6_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Mapping); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __pyx_t_5; __pyx_L6_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_3; if (!__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __Pyx_INCREF(__pyx_v_name); __pyx_t_1 = __pyx_v_name; __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_Dict, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 709, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_5 = __pyx_t_3; goto __pyx_L8_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_Mapping, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 709, __pyx_L1_error) __pyx_t_5 = __pyx_t_3; __pyx_L8_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_5; __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0710: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (likely(__pyx_t_2)) {
/* … */
}
+0711: if type_args:
__pyx_t_2 = (__pyx_cur_scope->__pyx_v_type_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_cur_scope->__pyx_v_type_args) != 0);
if (__pyx_t_2) {
/* … */
}
0712: # e.g. Dict[K, V]
+0713: return {k: _parse_type(field, type_args[1], v, None, False) for k, v in data.items()}
__Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; if (unlikely(__pyx_v_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 713, __pyx_L14_error) } __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_data, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = __pyx_t_4; __pyx_t_4 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_8, &__pyx_t_7, &__pyx_t_4, &__pyx_t_10, NULL, __pyx_t_9); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_k, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_v, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __pyx_cur_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_10); if (unlikely(__pyx_cur_scope->__pyx_v_type_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 713, __pyx_L14_error) } __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_type_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_13.__pyx_n = 2; __pyx_t_13.encoder = Py_None; __pyx_t_13.as_objects = Py_False; __pyx_t_12 = __pyx_f_9datamodel_10converters__parse_type(__pyx_t_10, __pyx_t_4, __pyx_7genexpr__pyx_v_v, &__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_7genexpr__pyx_v_k, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __pyx_7genexpr__pyx_v_k = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0; goto __pyx_L17_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __pyx_7genexpr__pyx_v_k = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L17_exit_scope:; } /* exit inner scope */ __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0714: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0715: else:
+0716: raise TypeError(f"Expected dict, got {type(data).__name__}")
/*else*/ { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expected_dict_got, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 716, __pyx_L1_error) }
0717:
+0718: if name == 'Tuple' or field.origin == tuple:
__pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_Tuple, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 718, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L19_bool_binop_done; } __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, ((PyObject *)(&PyTuple_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L19_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0719: if isinstance(data, (list, tuple)):
__pyx_t_3 = PyList_Check(__pyx_v_data); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L22_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_3; __pyx_L22_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0720: if len(data) == len(type_args):
__pyx_t_8 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 720, __pyx_L1_error) __pyx_t_1 = __pyx_cur_scope->__pyx_v_type_args; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 720, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = (__pyx_t_8 == __pyx_t_7); if (__pyx_t_2) { /* … */ }
+0721: return tuple(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0722: _parse_type(field, typ, datum, encoder, False)
static PyObject *__pyx_pf_9datamodel_10converters_18_parse_typing_type_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) { struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_1_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_1_genexpr *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_1_genexpr(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_1_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 722, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *) __pyx_self; __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_parse_typing_type_locals_genexp, __pyx_n_s_datamodel_converters); if (unlikely(!gen)) __PYX_ERR(0, 722, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("datamodel.converters._parse_typing_type.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 722, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 722, __pyx_L1_error) } __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_4); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_encoder)) { __Pyx_RaiseClosureNameError("encoder"); __PYX_ERR(0, 722, __pyx_L1_error) } __pyx_t_6 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_6); __pyx_t_9.__pyx_n = 2; __pyx_t_9.encoder = __pyx_t_6; __pyx_t_9.as_objects = Py_False; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_type(__pyx_t_4, __pyx_cur_scope->__pyx_v_typ, __pyx_cur_scope->__pyx_v_datum, &__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L8_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 722, __pyx_L1_error) /* … */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_t_1 = __pyx_pf_9datamodel_10converters_18_parse_typing_type_genexpr(((PyObject*)__pyx_cur_scope), __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_1_genexpr { PyObject_HEAD struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *__pyx_outer_scope; PyObject *__pyx_genexpr_arg_0; PyObject *__pyx_v_datum; PyObject *__pyx_v_typ; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
+0723: for typ, datum in zip(type_args, data)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 723, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 723, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 723, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 723, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 723, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 723, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 723, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 723, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 723, __pyx_L1_error) __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_typ); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_typ, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_datum); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_datum, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* … */ __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_type_args); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_type_args); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_type_args)) __PYX_ERR(0, 723, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_data)) __PYX_ERR(0, 723, __pyx_L1_error); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0724: )
0725: else:
+0726: if len(type_args) == 2 and type_args[1] is Ellipsis:
/*else*/ { __pyx_t_6 = __pyx_cur_scope->__pyx_v_type_args; __Pyx_INCREF(__pyx_t_6); if (unlikely(__pyx_t_6 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 726, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 726, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = (__pyx_t_7 == 2); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L26_bool_binop_done; } if (unlikely(__pyx_cur_scope->__pyx_v_type_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 726, __pyx_L1_error) } __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_type_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = (__pyx_t_6 == __pyx_builtin_Ellipsis); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L26_bool_binop_done:; if (__pyx_t_2) { /* … */ } }
0727: # e.g. Tuple[str, ...]
+0728: return tuple(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 728, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0729: _parse_type(field, type_args[0], datum, None, False)
static PyObject *__pyx_pf_9datamodel_10converters_18_parse_typing_type_3genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) { struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2_genexpr *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_2_genexpr(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 729, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *) __pyx_self; __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_parse_typing_type_locals_genexp, __pyx_n_s_datamodel_converters); if (unlikely(!gen)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("datamodel.converters._parse_typing_type.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 729, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 729, __pyx_L1_error) } __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_4); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_type_args)) { __Pyx_RaiseClosureNameError("type_args"); __PYX_ERR(0, 729, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_type_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 729, __pyx_L1_error) } __pyx_t_5 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_type_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7.__pyx_n = 2; __pyx_t_7.encoder = Py_None; __pyx_t_7.as_objects = Py_False; __pyx_t_6 = __pyx_f_9datamodel_10converters__parse_type(__pyx_t_4, __pyx_t_5, __pyx_cur_scope->__pyx_v_datum, &__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 729, __pyx_L1_error) /* … */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_6 = __pyx_pf_9datamodel_10converters_18_parse_typing_type_3genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_data); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2_genexpr { PyObject_HEAD struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_typing_type *__pyx_outer_scope; PyObject *__pyx_genexpr_arg_0; PyObject *__pyx_v_datum; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
+0730: for datum in data
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 730, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 730, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 730, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 730, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 730, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 730, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 730, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_datum); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_datum, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
0731: )
+0732: return tuple(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0733:
+0734: if name in {'List', 'Sequence'} or field.origin in {list, Sequence}:
__Pyx_INCREF(__pyx_v_name); __pyx_t_1 = __pyx_v_name; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_List, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 734, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L31_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_Sequence, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 734, __pyx_L1_error) __pyx_t_3 = __pyx_t_5; __pyx_L31_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_3; if (!__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L29_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 734, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 734, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!__pyx_t_3) { } else { __pyx_t_5 = __pyx_t_3; goto __pyx_L33_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 734, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_12 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 734, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 734, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_5 = __pyx_t_3; __pyx_L33_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_5; __pyx_t_2 = __pyx_t_3; __pyx_L29_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0735: if not isinstance(data, (list, tuple)):
__pyx_t_3 = PyList_Check(__pyx_v_data); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L36_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_3; __pyx_L36_bool_binop_done:; __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { /* … */ }
+0736: data = [data]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 736, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_data)) __PYX_ERR(0, 736, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+0737: return _parse_list_typing(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_14.__pyx_n = 1; __pyx_t_14.as_objects = __pyx_v_as_objects; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_list_typing(__pyx_t_1, ((PyObject*)__pyx_t_12), __pyx_v_data, __pyx_t_6, __pyx_v_origin, __pyx_v_args, &__pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+0738: field,
__pyx_t_1 = __pyx_cur_scope->__pyx_v_field;
__Pyx_INCREF(__pyx_t_1);
+0739: type_args,
__pyx_t_12 = __pyx_cur_scope->__pyx_v_type_args;
__Pyx_INCREF(__pyx_t_12);
0740: data,
+0741: encoder,
__pyx_t_6 = __pyx_cur_scope->__pyx_v_encoder;
__Pyx_INCREF(__pyx_t_6);
0742: origin,
0743: args,
0744: as_objects=as_objects
0745: )
0746:
0747: # handle None, Optional, Union:
+0748: if name is None or name in ('Optional', 'Union'):
__pyx_t_2 = (__pyx_v_name == Py_None); if (!__pyx_t_2) { } else { __pyx_t_3 = __pyx_t_2; goto __pyx_L39_bool_binop_done; } __Pyx_INCREF(__pyx_v_name); __pyx_t_4 = __pyx_v_name; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_Optional, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 748, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L41_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_Union, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 748, __pyx_L1_error) __pyx_t_2 = __pyx_t_5; __pyx_L41_bool_binop_done:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __pyx_t_2; __pyx_t_3 = __pyx_t_5; __pyx_L39_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+0749: return _parse_optional_union(field, T, data, encoder, origin, args)
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __pyx_cur_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = __pyx_cur_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_6); __pyx_t_12 = __pyx_f_9datamodel_10converters__parse_optional_union(__pyx_t_4, __pyx_v_T, __pyx_v_data, __pyx_t_6, __pyx_v_origin, __pyx_v_args); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0;
0750:
+0751: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0752:
+0753: cdef object _parse_list_typing(
static PyObject *__pyx_f_9datamodel_10converters__parse_list_typing(PyObject *__pyx_v_field, PyObject *__pyx_v_type_args, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder, CYTHON_UNUSED PyObject *__pyx_v_origin, CYTHON_UNUSED PyObject *__pyx_v_args, struct __pyx_opt_args_9datamodel_10converters__parse_list_typing *__pyx_optional_args) { PyObject *__pyx_v_result = 0; CYTHON_UNUSED PyObject *__pyx_v_out = 0; PyObject *__pyx_v_arg_type = 0; PyObject *__pyx_v_arg_module = 0; int __pyx_v_is_nested_typing; PyObject *__pyx_v_subT = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("datamodel.converters._parse_list_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_out); __Pyx_XDECREF(__pyx_v_arg_type); __Pyx_XDECREF(__pyx_v_arg_module); __Pyx_XDECREF(__pyx_v_subT); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__parse_list_typing { int __pyx_n; PyObject *as_objects; PyObject *typeinfo; };
0754: object field,
0755: tuple type_args,
0756: object data,
0757: object encoder,
0758: object origin,
0759: object args,
0760: object as_objects=False,
0761: dict typeinfo=None
0762: ):
0763: """
0764: Handle List[T] logic, trying to reduce overhead from repeated lookups.
0765: """
+0766: cdef list result = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0767: cdef list out = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_out = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0768: cdef object arg_type = type_args[0] if type_args else None
__pyx_t_2 = (__pyx_v_type_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_type_args) != 0); if (__pyx_t_2) { if (unlikely(__pyx_v_type_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 768, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_type_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_1 = Py_None; } __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+0769: cdef object arg_module = getattr(arg_type, '__module__', None)
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_arg_type, __pyx_n_u_module, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_module = __pyx_t_1; __pyx_t_1 = 0;
+0770: cdef bint is_nested_typing = (arg_module == 'typing')
__pyx_t_1 = PyObject_RichCompare(__pyx_v_arg_module, __pyx_n_u_typing, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 770, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_is_nested_typing = __pyx_t_2;
0771:
0772: # If no type args, we can't proceed with further logic
+0773: if not type_args:
__pyx_t_2 = (__pyx_v_type_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_type_args) != 0);
__pyx_t_4 = (!__pyx_t_2);
if (__pyx_t_4) {
/* … */
}
+0774: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0775:
+0776: if is_nested_typing:
if (__pyx_v_is_nested_typing) { /* … */ }
0777: # nested typing: e.g. List[List[Foo]] or List[Optional[Foo]] etc.
+0778: try:
{ /*try:*/ { /* … */ } __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L9_try_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L0; __pyx_L8_except_return:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L0; }
+0779: subT = arg_type.__args__[0]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 779, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 779, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_subT = __pyx_t_3; __pyx_t_3 = 0;
+0780: if is_dc(subT):
__pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_subT); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 780, __pyx_L5_error) if (__pyx_t_4) { /* … */ }
+0781: for x in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_3 = __pyx_v_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 781, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 781, __pyx_L5_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 781, __pyx_L5_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 781, __pyx_L5_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 781, __pyx_L5_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 781, __pyx_L5_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 781, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0782: result.append(_instantiate_dataclass(subT, x))
__pyx_t_1 = __pyx_f_9datamodel_10converters__instantiate_dataclass(__pyx_v_subT, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 782, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0783: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
0784: else:
0785: # fallback
+0786: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L9_try_return; }
+0787: except AttributeError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._parse_list_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_12) < 0) __PYX_ERR(0, 787, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_12);
+0788: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L8_except_return; } goto __pyx_L7_except_error;
+0789: elif arg_type is not None and is_dc(arg_type):
__pyx_t_2 = (__pyx_v_arg_type != Py_None); if (__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L17_bool_binop_done; } __pyx_t_2 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_arg_type); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 789, __pyx_L1_error) __pyx_t_4 = __pyx_t_2; __pyx_L17_bool_binop_done:; if (__pyx_t_4) { /* … */ }
0790: # build list of dataclasses
+0791: for d in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_12 = __pyx_v_data; __Pyx_INCREF(__pyx_t_12); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 791, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_12))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_12); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 791, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0792: result.append(_instantiate_dataclass(arg_type, d))
__pyx_t_1 = __pyx_f_9datamodel_10converters__instantiate_dataclass(__pyx_v_arg_type, __pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 792, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 792, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0793: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0794: else:
0795: # parse each item
+0796: for item in data:
/*else*/ { if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_12 = __pyx_v_data; __Pyx_INCREF(__pyx_t_12); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 796, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_12))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 796, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 796, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 796, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 796, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_12); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 796, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0797: result.append(
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 797, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0798: _parse_type(field, arg_type, item, encoder, False)
__pyx_t_13.__pyx_n = 2; __pyx_t_13.encoder = __pyx_v_encoder; __pyx_t_13.as_objects = Py_False; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_item, &__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
0799: )
+0800: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; }
0801:
+0802: cdef object _instantiate_dataclass(object cls, object val):
static PyObject *__pyx_f_9datamodel_10converters__instantiate_dataclass(PyObject *__pyx_v_cls, PyObject *__pyx_v_val) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("datamodel.converters._instantiate_dataclass", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
0803: """
0804: Helper for instantiating a dataclass.
0805: """
+0806: if is_dc(val):
__pyx_t_1 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_val); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 806, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0807: return val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_val); __pyx_r = __pyx_v_val; goto __pyx_L0;
+0808: if isinstance(val, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_val);
if (__pyx_t_1) {
/* … */
}
+0809: return cls(**val)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_val == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 809, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_val))) { __pyx_t_2 = PyDict_Copy(__pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_2 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_cls, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+0810: elif isinstance(val, (list, tuple)):
__pyx_t_4 = PyList_Check(__pyx_v_val); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = PyTuple_Check(__pyx_v_val); __pyx_t_1 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0811: return cls(*val)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_cls, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0812: else:
+0813: return cls(val)
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_cls); __pyx_t_3 = __pyx_v_cls; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_val}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; }
0814:
+0815: cdef object _parse_optional_union(
static PyObject *__pyx_f_9datamodel_10converters__parse_optional_union(PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder, PyObject *__pyx_v_origin, PyObject *__pyx_v_args) { PyObject *__pyx_v_non_none_arg = 0; PyObject *__pyx_v_t = 0; int __pyx_v_matched; PyObject *__pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator2 = 0; PyObject *__pyx_r = NULL; __Pyx_INCREF(__pyx_v_args); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("datamodel.converters._parse_optional_union", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_non_none_arg); __Pyx_XDECREF(__pyx_v_t); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator2); __Pyx_XDECREF(__pyx_v_args); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
0816: object field,
0817: object T,
0818: object data,
0819: object encoder,
0820: object origin,
0821: object args
0822: ):
0823: """
0824: Handle Optional or Union logic.
0825: """
0826: cdef object non_none_arg
+0827: cdef object t = args[0] if args else None
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 827, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_1 = Py_None; } __pyx_v_t = __pyx_t_1; __pyx_t_1 = 0;
+0828: cdef bint matched = False
__pyx_v_matched = 0;
0829:
+0830: for t in args:
if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) { __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 830, __pyx_L1_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 830, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 830, __pyx_L1_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 830, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 830, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0831: if PyObject_IsInstance(data, t):
__pyx_t_2 = PyObject_IsInstance(__pyx_v_data, __pyx_v_t); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 831, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+0832: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0;
0833:
0834: # e.g. Optional[T] is Union[T, NoneType]
+0835: if origin == Union and type(None) in args:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Union); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_RichCompare(__pyx_v_origin, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 835, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 835, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { } else { __pyx_t_2 = __pyx_t_6; goto __pyx_L8_bool_binop_done; } __pyx_t_6 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_args, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 835, __pyx_L1_error) __pyx_t_2 = __pyx_t_6; __pyx_L8_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0836: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+0837: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
0838: # Pick the non-None type (assumes only two types in the Union)
+0839: non_none_arg = args[0] if args[1] is type(None) else args[1]
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__pyx_t_1 == ((PyObject *)Py_TYPE(Py_None))); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } else { __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } __pyx_v_non_none_arg = __pyx_t_3; __pyx_t_3 = 0;
+0840: return _parse_type(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_7.__pyx_n = 2; __pyx_t_7.encoder = __pyx_v_encoder; __pyx_t_7.as_objects = Py_False; __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_v_non_none_arg, __pyx_v_data, &__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
0841: field,
0842: T=non_none_arg,
0843: data=data,
0844: encoder=encoder,
0845: as_objects=False
0846: )
0847: # Remove None from args.
+0848: args = tuple(t for t in args if t is not type(None))
static PyObject *__pyx_pf_9datamodel_10converters_21_parse_optional_union_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) { struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_3_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_3_genexpr *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_3_genexpr(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_3_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 848, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_parse_optional_union_locals_gen, __pyx_n_s_datamodel_converters); if (unlikely(!gen)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("datamodel.converters._parse_optional_union.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 848, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 848, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 848, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 848, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 848, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 848, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 848, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 848, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_t); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_t, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = (__pyx_cur_scope->__pyx_v_t != ((PyObject *)Py_TYPE(Py_None))); if (__pyx_t_5) { __Pyx_INCREF(__pyx_cur_scope->__pyx_v_t); __pyx_r = __pyx_cur_scope->__pyx_v_t; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L7_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 848, __pyx_L1_error) } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_3 = __pyx_pf_9datamodel_10converters_21_parse_optional_union_genexpr(NULL, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_1); __pyx_t_1 = 0; /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_3_genexpr { PyObject_HEAD PyObject *__pyx_genexpr_arg_0; PyObject *__pyx_v_t; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
0849: # If there are no non-None types left, simply return data.
+0850: if not args:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 850, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_2); if (__pyx_t_6) { /* … */ }
+0851: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0852:
+0853: for t in args:
if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) { __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 853, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 853, __pyx_L1_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 853, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 853, __pyx_L1_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 853, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 853, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L15_for_end; __pyx_L13_break:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L15_for_end; __pyx_L15_for_end:;
+0854: if isinstance(data, t):
__pyx_t_6 = PyObject_IsInstance(__pyx_v_data, __pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 854, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+0855: matched = True
__pyx_v_matched = 1;
+0856: break
goto __pyx_L13_break;
+0857: if not matched:
__pyx_t_6 = (!__pyx_v_matched); if (unlikely(__pyx_t_6)) { /* … */ }
+0858: raise ValueError(
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 858, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 858, __pyx_L1_error)
+0859: f"Invalid type for *{field.name}* with {type(data)}, expected {T}"
__pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for); __pyx_t_4 += 18; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Invalid_type_for); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_8; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_with); __pyx_t_4 += 7; __Pyx_GIVEREF(__pyx_kp_u_with); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_with); __pyx_t_9 = __Pyx_PyObject_FormatSimple(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_8; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_expected); __pyx_t_4 += 11; __Pyx_GIVEREF(__pyx_kp_u_expected); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_expected); __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_8; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0860: )
+0861: try:
{ /*try:*/ { /* … */ } __pyx_L17_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L19_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L1_error; __pyx_L21_try_return:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L0; __pyx_L18_exception_handled:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); }
+0862: if is_dc(t):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 862, __pyx_L17_error) if (__pyx_t_6) { /* … */ }
+0863: if isinstance(data, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
}
+0864: return t(**data)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 864, __pyx_L17_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_1 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_9 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 864, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L21_try_return;
+0865: elif isinstance(data, (list, tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_data); if (!__pyx_t_2) { } else { __pyx_t_6 = __pyx_t_2; goto __pyx_L25_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_data); __pyx_t_6 = __pyx_t_2; __pyx_L25_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+0866: return t(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 866, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 866, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L21_try_return;
0867: else:
+0868: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L21_try_return; }
+0869: elif callable(t):
__pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 869, __pyx_L17_error) if (__pyx_t_6) { /* … */ }
+0870: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L21_try_return;
+0871: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L21_try_return;
+0872: except KeyError:
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_13) { __Pyx_ErrRestore(0,0,0); goto __pyx_L18_exception_handled; } goto __pyx_L19_except_error;
0873: pass
+0874: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0875:
+0876: cdef object _parse_union_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_union_type(PyObject *__pyx_v_field, CYTHON_UNUSED PyObject *__pyx_v_T, CYTHON_UNUSED PyObject *__pyx_v_name, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder, PyObject *__pyx_v_origin, PyObject *__pyx_v_targs) { PyObject *__pyx_v_field_name = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_non_none_arg = 0; CYTHON_UNUSED PyObject *__pyx_v_inner_targs = 0; int __pyx_v_is_typing; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_v_arg_type = NULL; PyObject *__pyx_v_subtype_origin = NULL; PyObject *__pyx_v_exc = NULL; PyObject *__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator3 = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_field_name); __Pyx_XDECREF(__pyx_v_error); __Pyx_XDECREF(__pyx_v_non_none_arg); __Pyx_XDECREF(__pyx_v_inner_targs); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XDECREF(__pyx_v_arg_type); __Pyx_XDECREF(__pyx_v_subtype_origin); __Pyx_XDECREF(__pyx_v_exc); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator3); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0877: object field,
0878: object T,
0879: object name,
0880: object data,
0881: object encoder,
0882: object origin,
0883: object targs
0884: ):
0885: """
0886: Attempt each type in the Union until one parses successfully
0887: or raise an error if all fail.
0888: If T is Optional[...] (i.e. a Union with NoneType), unwrap it.
0889: """
+0890: cdef str field_name = field.name
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 890, __pyx_L1_error) __pyx_v_field_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0891: cdef str error = None
__Pyx_INCREF(Py_None);
__pyx_v_error = ((PyObject*)Py_None);
+0892: cdef object non_none_arg = None
__Pyx_INCREF(Py_None);
__pyx_v_non_none_arg = Py_None;
+0893: cdef tuple inner_targs = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_targs = ((PyObject*)Py_None);
+0894: cdef bint is_typing = False
__pyx_v_is_typing = 0;
0895:
0896: # If the union includes NoneType, unwrap it and use only the non-None type.
+0897: if origin == Union and type(None) in targs:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Union); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_RichCompare(__pyx_v_origin, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_targs, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 897, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0898: for arg in targs:
if (likely(PyList_CheckExact(__pyx_v_targs)) || PyTuple_CheckExact(__pyx_v_targs)) { __pyx_t_3 = __pyx_v_targs; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_targs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 898, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 898, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 898, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 898, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 898, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 898, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L9_for_end; __pyx_L7_break:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L9_for_end; __pyx_L9_for_end:;
+0899: if arg is not type(None):
__pyx_t_2 = (__pyx_v_arg != ((PyObject *)Py_TYPE(Py_None))); if (__pyx_t_2) { /* … */ }
+0900: non_none_arg = arg
__Pyx_INCREF(__pyx_v_arg); __Pyx_DECREF_SET(__pyx_v_non_none_arg, __pyx_v_arg);
+0901: break
goto __pyx_L7_break;
+0902: is_typing = hasattr(non_none_arg, '__module__') and non_none_arg.__module__ == 'typing'
__pyx_t_4 = __Pyx_HasAttr(__pyx_v_non_none_arg, __pyx_n_u_module); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 902, __pyx_L1_error) if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L10_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_non_none_arg, __pyx_n_s_module); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 902, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __pyx_L10_bool_binop_done:; __pyx_v_is_typing = __pyx_t_2;
0903:
+0904: if non_none_arg is not None and is_typing is True:
__pyx_t_4 = (__pyx_v_non_none_arg != Py_None); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L13_bool_binop_done; } __pyx_t_4 = (__pyx_v_is_typing == 1); __pyx_t_2 = __pyx_t_4; __pyx_L13_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L12; }
0905: # Invoke the parse_typing_type
+0906: field.args = get_args(non_none_arg)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_non_none_arg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_t_3) < 0) __PYX_ERR(0, 906, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0907: field.origin = get_origin(non_none_arg)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_non_none_arg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_origin, __pyx_t_3) < 0) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0908: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0909: return _parse_typing(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_9.__pyx_n = 2; __pyx_t_9.encoder = __pyx_v_encoder; __pyx_t_9.as_objects = Py_False; __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_non_none_arg, __pyx_v_data, &__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
0910: field,
0911: non_none_arg,
0912: data,
0913: encoder,
0914: False
0915: )
0916: else:
+0917: pass
/*else*/ { } __pyx_L12:;
+0918: for arg_type in targs:
if (likely(PyList_CheckExact(__pyx_v_targs)) || PyTuple_CheckExact(__pyx_v_targs)) { __pyx_t_3 = __pyx_v_targs; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_targs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 918, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 918, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 918, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 918, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 918, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 918, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_arg_type, __pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_L16_continue:; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0919: # Iterate over all subtypes of Union:
+0920: subtype_origin = get_origin(arg_type)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_arg_type}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_subtype_origin, __pyx_t_1); __pyx_t_1 = 0;
+0921: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L25_try_end; __pyx_L18_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L20_except_error:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L1_error; __pyx_L24_try_continue:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L16_continue; __pyx_L22_try_return:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L0; __pyx_L19_exception_handled:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); __pyx_L25_try_end:; }
+0922: if subtype_origin is list or subtype_origin is tuple:
__pyx_t_4 = (__pyx_v_subtype_origin == ((PyObject *)(&PyList_Type))); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L27_bool_binop_done; } __pyx_t_4 = (__pyx_v_subtype_origin == ((PyObject *)(&PyTuple_Type))); __pyx_t_2 = __pyx_t_4; __pyx_L27_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0923: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0924: return _parse_list_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 924, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return;
0925: else:
+0926: error = f"Invalid type for {field_name}: Expected a list, got {type(data).__name__}"
/*else*/ { __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_14 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 926, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_list_got); __pyx_t_14 += 23; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_list_got); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Expected_a_list_got); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 926, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 926, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 926, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_10)); __pyx_t_10 = 0;
+0927: continue
goto __pyx_L24_try_continue; }
+0928: elif subtype_origin is dict:
__pyx_t_2 = (__pyx_v_subtype_origin == ((PyObject *)(&PyDict_Type))); if (__pyx_t_2) { /* … */ }
+0929: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0930: return _parse_dict_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_10 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 930, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return;
0931: else:
+0932: error = f"Invalid type for {field_name} Expected a dict, got {type(data).__name__}"
/*else*/ { __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 932, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_14 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_14 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_dict_got); __pyx_t_14 += 22; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_dict_got); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_Expected_a_dict_got); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 932, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 932, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
+0933: continue
goto __pyx_L24_try_continue; }
+0934: elif arg_type is list:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ goto __pyx_L26; }
+0935: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
goto __pyx_L31;
}
+0936: if arg_type is str:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyUnicode_Type))); if (__pyx_t_2) { /* … */ goto __pyx_L32; }
0937: # Ensure all elements in the list are strings
+0938: if all(isinstance(item, str) for item in data):
static PyObject *__pyx_pf_9datamodel_10converters_17_parse_union_type_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) { struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_4_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_4_genexpr *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_4_genexpr(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_4_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_4_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 938, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9datamodel_10converters_17_parse_union_type_2generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_parse_union_type_locals_genexpr, __pyx_n_s_datamodel_converters); if (unlikely(!gen)) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("datamodel.converters._parse_union_type.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 938, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 938, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 938, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 938, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_item); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_item, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = PyUnicode_Check(__pyx_cur_scope->__pyx_v_item); __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0; } CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_7 = __pyx_pf_9datamodel_10converters_17_parse_union_type_genexpr(NULL, __pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 938, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_Generator_Next(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 938, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 938, __pyx_L18_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_2) { /* … */ }
+0939: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return;
0940: else:
+0941: return _parse_list_type(field, arg_type, data, encoder, targs)
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_10 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 941, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return; } __pyx_L32:;
0942: else:
+0943: error = f"Invalid type for {field_name}: Expected a list, got {type(data).__name__}"
/*else*/ { __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 943, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_14 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_14 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 943, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_list_got); __pyx_t_14 += 23; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_list_got); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_Expected_a_list_got); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 943, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 943, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 943, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+0944: continue
goto __pyx_L24_try_continue; } __pyx_L31:;
+0945: elif arg_type is dict:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyDict_Type))); if (__pyx_t_2) { /* … */ }
+0946: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0947: return _parse_dict_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 947, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return;
0948: else:
+0949: error = f"Invalid type for {field_name} Expected a dict, got {type(data).__name__}"
/*else*/ { __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_14 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_10 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 949, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_dict_got); __pyx_t_14 += 22; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_dict_got); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Expected_a_dict_got); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 949, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 949, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 949, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
+0950: continue
goto __pyx_L24_try_continue; }
+0951: elif subtype_origin is None:
__pyx_t_2 = (__pyx_v_subtype_origin == Py_None); if (__pyx_t_2) { /* … */ }
+0952: if isinstance(data, arg_type):
__pyx_t_2 = PyObject_IsInstance(__pyx_v_data, __pyx_v_arg_type); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 952, __pyx_L18_error) if (__pyx_t_2) { /* … */ }
+0953: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return;
0954: else:
0955: # Not matching => record an error
+0956: error = f"Invalid type for {field_name}, Data {data!r} is not an instance of {arg_type}"
/*else*/ { __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 956, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_14 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_14 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_Data); __pyx_t_14 += 7; __Pyx_GIVEREF(__pyx_kp_u_Data); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u_Data); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_data), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_is_not_an_instance_of); __pyx_t_14 += 23; __Pyx_GIVEREF(__pyx_kp_u_is_not_an_instance_of); PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_kp_u_is_not_an_instance_of); __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_arg_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_7, 6, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 956, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+0957: continue
goto __pyx_L24_try_continue; }
0958: else:
0959: # fallback to builtin parse
+0960: return _parse_typing(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_9.__pyx_n = 2; __pyx_t_9.encoder = __pyx_v_encoder; __pyx_t_9.as_objects = Py_False; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 960, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L22_try_return; } __pyx_L26:;
0961: field,
0962: arg_type,
0963: data,
0964: encoder,
0965: False
0966: )
+0967: except ValueError as exc:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_10) < 0) __PYX_ERR(0, 967, __pyx_L20_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_v_exc = __pyx_t_7; /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L42; } __pyx_L41_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_26); __Pyx_XGOTREF(__pyx_t_27); __pyx_t_16 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_25); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_26, __pyx_t_27); } __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_ErrRestore(__pyx_t_22, __pyx_t_23, __pyx_t_24); __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21; goto __pyx_L20_except_error; } __pyx_L42:; } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L19_exception_handled; }
+0968: error = f"{field.name}: {exc}"
__pyx_t_17 = PyTuple_New(3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 968, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_14 = 0; __pyx_t_15 = 127; __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 968, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_t_18, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 968, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_14 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_kp_u__7); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 968, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_17, 3, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 968, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_19)); __pyx_t_19 = 0; }
+0969: except Exception as exc:
__pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_20) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_7, &__pyx_t_1) < 0) __PYX_ERR(0, 969, __pyx_L20_except_error) __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_v_exc = __pyx_t_7; /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L53; } __pyx_L52_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_26, &__pyx_t_25); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_26); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_20 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_28 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_23, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ErrRestore(__pyx_t_27, __pyx_t_26, __pyx_t_25); __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_20; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_28; goto __pyx_L20_except_error; } __pyx_L53:; } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L19_exception_handled; } goto __pyx_L20_except_error;
+0970: error = f"Parse Error on {field.name}, {arg_type}: {exc}"
__pyx_t_19 = PyTuple_New(6); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 970, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_14 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Parse_Error_on); __pyx_t_14 += 15; __Pyx_GIVEREF(__pyx_kp_u_Parse_Error_on); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_kp_u_Parse_Error_on); __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 970, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_17, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 970, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__10); __pyx_t_14 += 2; __Pyx_GIVEREF(__pyx_kp_u__10); PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_kp_u__10); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_arg_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 970, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_14 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_kp_u__7); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 970, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_19, 6, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 970, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_18)); __pyx_t_18 = 0; }
0971:
0972: # If we get here, all union attempts failed
+0973: raise ValueError(
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 973, __pyx_L1_error)
+0974: f"Invalid type for {field.name} with data={data}, error = {error}"
__pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_15 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_5 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_with_data); __pyx_t_5 += 11; __Pyx_GIVEREF(__pyx_kp_u_with_data); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_with_data); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_data, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_error); __pyx_t_5 += 10; __Pyx_GIVEREF(__pyx_kp_u_error); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u_error); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_3, 6, __pyx_t_5, __pyx_t_15); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0975: )
0976:
+0977: cdef object _parse_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_type(PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_data, struct __pyx_opt_args_9datamodel_10converters__parse_type *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("datamodel.converters._parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_origin); __Pyx_XDECREF(__pyx_v_targs); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_sub); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_isdc); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__parse_type { int __pyx_n; PyObject *encoder; PyObject *as_objects; };
0978: object field,
0979: object T,
0980: object data,
+0981: object encoder=None,
PyObject *__pyx_v_encoder = ((PyObject *)Py_None);
+0982: object as_objects=False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False); PyObject *__pyx_v_origin = 0; PyObject *__pyx_v_targs = 0; PyObject *__pyx_v_name = 0; CYTHON_UNUSED PyObject *__pyx_v_sub = 0; PyObject *__pyx_v_result = 0; PyObject *__pyx_v_isdc = 0; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_encoder = __pyx_optional_args->encoder; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_as_objects = __pyx_optional_args->as_objects; } } }
0983: ):
0984: """
0985: Parse a value to a typing type.
0986: """
0987: # local cdef variables:
+0988: cdef object origin = get_origin(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 988, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_T}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 988, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+0989: cdef object targs = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_T}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_targs = __pyx_t_1; __pyx_t_1 = 0;
+0990: cdef object name = getattr(T, '_name', None) # T._name or None if not present
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_T, __pyx_n_u_name_3, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_name = __pyx_t_1; __pyx_t_1 = 0;
+0991: cdef object sub = None # for subtypes, local cache
__Pyx_INCREF(Py_None);
__pyx_v_sub = Py_None;
+0992: cdef object result = None
__Pyx_INCREF(Py_None);
__pyx_v_result = Py_None;
+0993: cdef object isdc = is_dc(T)
__pyx_t_5 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_T); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 993, __pyx_L1_error) __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 993, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_isdc = __pyx_t_1; __pyx_t_1 = 0;
0994:
+0995: if data is None:
__pyx_t_5 = (__pyx_v_data == Py_None); if (__pyx_t_5) { /* … */ }
+0996: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
0997:
+0998: if isdc:
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_isdc); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 998, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+0999: return _handle_dataclass_type(None, name, data, T, as_objects, None)
__Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_name))) __PYX_ERR(0, 999, __pyx_L1_error) __pyx_t_6.__pyx_n = 2; __pyx_t_6.as_objects = __pyx_v_as_objects; __pyx_t_6.parent = Py_None; __pyx_t_1 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, ((PyObject*)__pyx_v_name), __pyx_v_data, __pyx_v_T, &__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1000: # Field type shortcuts
+1001: elif origin is dict and isinstance(data, dict):
__pyx_t_7 = (__pyx_v_origin == ((PyObject *)(&PyDict_Type)));
if (__pyx_t_7) {
} else {
__pyx_t_5 = __pyx_t_7;
goto __pyx_L5_bool_binop_done;
}
__pyx_t_7 = PyDict_Check(__pyx_v_data);
__pyx_t_5 = __pyx_t_7;
__pyx_L5_bool_binop_done:;
if (__pyx_t_5) {
/* … */
}
+1002: return _parse_dict_type(field, T, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1003: elif origin is list:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_5) { /* … */ }
+1004: return _parse_list_type(field, T, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1004, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1005: elif origin is not None:
__pyx_t_5 = (__pyx_v_origin != Py_None); if (__pyx_t_5) { /* … */ }
1006: # other advanced generics
+1007: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1008: else:
1009: # fallback to builtin parse
+1010: result = _parse_builtin_type(field, T, data, encoder)
/*else*/ { __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); __pyx_t_1 = 0;
+1011: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; }
1012:
+1013: cdef object _parse_typing(
static PyObject *__pyx_f_9datamodel_10converters__parse_typing(PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_data, struct __pyx_opt_args_9datamodel_10converters__parse_typing *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("datamodel.converters._parse_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_origin); __Pyx_XDECREF(__pyx_v_targs); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_sub); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_inner_type); __Pyx_XDECREF(__pyx_v_inner_origin); __Pyx_XDECREF(__pyx_v_real_type); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__parse_typing { int __pyx_n; PyObject *encoder; PyObject *as_objects; PyObject *parent; };
1014: object field,
1015: object T,
1016: object data,
+1017: object encoder=None,
PyObject *__pyx_v_encoder = ((PyObject *)Py_None);
+1018: object as_objects=False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False);
+1019: object parent=None,
PyObject *__pyx_v_parent = ((PyObject *)Py_None); PyObject *__pyx_v_origin = 0; PyObject *__pyx_v_targs = 0; PyObject *__pyx_v_name = 0; CYTHON_UNUSED PyObject *__pyx_v_sub = 0; CYTHON_UNUSED PyObject *__pyx_v_result = 0; PyObject *__pyx_v_inner_type = 0; int __pyx_v_inner_is_dc; CYTHON_UNUSED PyObject *__pyx_v_inner_origin = NULL; PyObject *__pyx_v_real_type = NULL; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_encoder = __pyx_optional_args->encoder; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_as_objects = __pyx_optional_args->as_objects; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_parent = __pyx_optional_args->parent; } } } }
1020: ):
1021: """
1022: Parse a value to a typing type.
1023: """
1024: # local cdef variables:
1025: cdef object origin, targs
+1026: cdef object name = getattr(T, '_name', None) # T._name or None if not present
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_T, __pyx_n_u_name_3, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1026, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_name = __pyx_t_1; __pyx_t_1 = 0;
+1027: cdef object sub = None # for subtypes, local cache
__Pyx_INCREF(Py_None);
__pyx_v_sub = Py_None;
+1028: cdef object result = None
__Pyx_INCREF(Py_None);
__pyx_v_result = Py_None;
+1029: cdef object inner_type = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_type = Py_None;
+1030: cdef bint inner_is_dc = 0 # field._inner_is_dc or is_dataclass(inner_type)
__pyx_v_inner_is_dc = 0;
1031:
1032: # Use cached values only if T is exactly the field's declared type.
+1033: if T == field.type:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_type_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_v_T, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+1034: origin = field.origin
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1034, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_origin = __pyx_t_2; __pyx_t_2 = 0;
+1035: targs = field.args
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_args_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_targs = __pyx_t_2; __pyx_t_2 = 0;
+1036: elif field._inner_type and field._inner_type == inner_type:
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_v_inner_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+1037: origin = field._inner_origin
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1037, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+1038: targs = field._inner_args
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_targs = __pyx_t_1; __pyx_t_1 = 0;
1039: else:
+1040: origin = get_origin(T)
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_T}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+1041: targs = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1041, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_T}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1041, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_targs = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L3:;
1042:
1043: # For generic (typing) fields, reuse cached inner type info if available.
+1044: if origin is list and targs:
__pyx_t_4 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L7_bool_binop_done; } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_targs); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1044, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L7_bool_binop_done:; if (__pyx_t_3) { /* … */ goto __pyx_L6; }
+1045: if field._inner_type is not None:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = (__pyx_t_1 != Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L9; }
+1046: inner_type = field._inner_type
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0;
+1047: inner_origin = field._inner_origin
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_inner_origin = __pyx_t_1; __pyx_t_1 = 0;
1048: # Optionally, also use cached type arguments for the inner type.
1049: else:
+1050: inner_type = targs[0]
/*else*/ { __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0;
+1051: inner_origin = get_origin(inner_type)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_inner_type}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_inner_origin = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L9:;
1052: else:
+1053: inner_type = None
/*else*/ { __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_inner_type, Py_None);
+1054: inner_origin = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_origin = Py_None;
}
__pyx_L6:;
1055:
+1056: inner_is_dc = field._inner_is_dc or is_dc(inner_type)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1056, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L10_bool_binop_done; } __pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_inner_type); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1056, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L10_bool_binop_done:; __pyx_v_inner_is_dc = __pyx_t_3;
1057:
+1058: if data is None:
__pyx_t_3 = (__pyx_v_data == Py_None); if (__pyx_t_3) { /* … */ }
+1059: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1060:
1061: # Put more frequently cases first:
+1062: if field.is_dc:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_is_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ }
+1063: return _handle_dataclass_type(None, name, data, T, as_objects, None)
__Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_name))) __PYX_ERR(0, 1063, __pyx_L1_error) __pyx_t_7.__pyx_n = 2; __pyx_t_7.as_objects = __pyx_v_as_objects; __pyx_t_7.parent = Py_None; __pyx_t_1 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, ((PyObject*)__pyx_v_name), __pyx_v_data, __pyx_v_T, &__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1064:
1065: # If the field is a Union and data is a list, use _parse_union_type.
+1066: if origin is Union:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Union); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = (__pyx_v_origin == __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ }
1067: # e.g. Optional[...] or Union[A, B]
+1068: if len(targs) == 2 and type(None) in targs:
__pyx_t_8 = PyObject_Length(__pyx_v_targs); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1068, __pyx_L1_error) __pyx_t_4 = (__pyx_t_8 == 2); if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L16_bool_binop_done; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_targs, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1068, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L16_bool_binop_done:; if (__pyx_t_3) { /* … */ }
1069: # Handle Optional[...] that is Union[..., None] cases first:
+1070: if field._inner_priv:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_priv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1070, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ }
1071: # If Optional but non-None is a primitive
+1072: return _parse_builtin_type(field, field._inner_type, data, encoder)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_t_1, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+1073: elif field._inner_is_dc:
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
1074: # non-None is a Optional Dataclass:
+1075: return _handle_dataclass_type(None, name, data, field._inner_type, as_objects, None)
__Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_name))) __PYX_ERR(0, 1075, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7.__pyx_n = 2; __pyx_t_7.as_objects = __pyx_v_as_objects; __pyx_t_7.parent = Py_None; __pyx_t_1 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, ((PyObject*)__pyx_v_name), __pyx_v_data, __pyx_t_2, &__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1076: else:
+1077: real_type = targs[0] if targs[1] is type(None) else targs[1]
/*else*/ { __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_targs, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = (__pyx_t_2 == ((PyObject *)Py_TYPE(Py_None))); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } else { __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_targs, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_v_real_type = __pyx_t_1; __pyx_t_1 = 0;
1078: # Recursively parse the real_type exactly as if it weren't wrapped in Optional[…].
+1079: return _parse_typing(field, real_type, data, encoder, as_objects, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_9.__pyx_n = 3; __pyx_t_9.encoder = __pyx_v_encoder; __pyx_t_9.as_objects = __pyx_v_as_objects; __pyx_t_9.parent = __pyx_v_parent; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_real_type, __pyx_v_data, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
+1080: elif isinstance(data, list):
__pyx_t_3 = PyList_Check(__pyx_v_data);
if (__pyx_t_3) {
/* … */
}
+1081: return _parse_union_type(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_union_type(__pyx_v_field, __pyx_v_T, __pyx_v_name, __pyx_v_data, __pyx_v_encoder, __pyx_v_origin, __pyx_v_targs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1082: field,
1083: T,
1084: name,
1085: data,
1086: encoder,
1087: origin,
1088: targs
1089: )
1090: else:
+1091: return _parse_union_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_union_type(__pyx_v_field, __pyx_v_T, __pyx_v_name, __pyx_v_data, __pyx_v_encoder, __pyx_v_origin, __pyx_v_targs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1092: field,
1093: T,
1094: name,
1095: data,
1096: encoder,
1097: origin,
1098: targs
1099: )
1100: # Field type shortcuts
+1101: if field._type_category == 'typing':
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_type_category); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ }
1102: # For example, if the origin is list and the inner type is a dataclass,
1103: # use _handle_dataclass_type on each element.
+1104: if origin is list:
__pyx_t_3 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_3) { /* … */ }
+1105: if inner_is_dc:
if (__pyx_v_inner_is_dc) { /* … */ }
+1106: return _parse_list_type(field, T, data, encoder, targs, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_10.__pyx_n = 1; __pyx_t_10._parent = __pyx_v_parent; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, &__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1107: else:
+1108: return _parse_typing_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_11.__pyx_n = 1; __pyx_t_11.as_objects = __pyx_v_as_objects; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_typing_type(__pyx_v_field, __pyx_v_T, __pyx_v_name, __pyx_v_data, __pyx_v_encoder, __pyx_v_origin, __pyx_v_targs, &__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1109: field, T, name, data, encoder, origin, targs, as_objects
1110: )
1111: else:
+1112: return _parse_typing_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_11.__pyx_n = 1; __pyx_t_11.as_objects = __pyx_v_as_objects; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_typing_type(__pyx_v_field, __pyx_v_T, __pyx_v_name, __pyx_v_data, __pyx_v_encoder, __pyx_v_origin, __pyx_v_targs, &__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1113: field, T, name, data, encoder, origin, targs, as_objects
1114: )
+1115: if origin is dict and isinstance(data, dict):
__pyx_t_4 = (__pyx_v_origin == ((PyObject *)(&PyDict_Type)));
if (__pyx_t_4) {
} else {
__pyx_t_3 = __pyx_t_4;
goto __pyx_L23_bool_binop_done;
}
__pyx_t_4 = PyDict_Check(__pyx_v_data);
__pyx_t_3 = __pyx_t_4;
__pyx_L23_bool_binop_done:;
if (__pyx_t_3) {
/* … */
}
+1116: return _parse_dict_type(field, T, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1117: if origin is list:
__pyx_t_3 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_3) { /* … */ }
+1118: return _parse_list_type(field, T, data, encoder, targs, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_10.__pyx_n = 1; __pyx_t_10._parent = __pyx_v_parent; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, &__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1119: if origin is not None:
__pyx_t_3 = (__pyx_v_origin != Py_None); if (__pyx_t_3) { /* … */ }
1120: # other advanced generics
+1121: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1122: else:
1123: # fallback to builtin parse
+1124: return _parse_builtin_type(field, T, data, encoder)
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1125:
+1126: cdef object _handle_dataclass_type(
static PyObject *__pyx_f_9datamodel_10converters__handle_dataclass_type(PyObject *__pyx_v_field, PyObject *__pyx_v_name, PyObject *__pyx_v_value, PyObject *__pyx_v__type, struct __pyx_opt_args_9datamodel_10converters__handle_dataclass_type *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_AddTraceback("datamodel.converters._handle_dataclass_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_converter); __Pyx_XDECREF(__pyx_v_field_metadata); __Pyx_XDECREF(__pyx_v_alias); __Pyx_XDECREF(__pyx_v_exc); __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_v); __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__handle_dataclass_type { int __pyx_n; PyObject *as_objects; PyObject *parent; };
1127: object field,
1128: str name,
1129: object value,
1130: object _type,
+1131: object as_objects = False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False);
+1132: object parent = None
PyObject *__pyx_v_parent = ((PyObject *)Py_None);
PyObject *__pyx_v_key = 0;
PyObject *__pyx_v_converter = 0;
int __pyx_v_isdc;
PyObject *__pyx_v_field_metadata = 0;
PyObject *__pyx_v_alias = 0;
PyObject *__pyx_v_exc = NULL;
PyObject *__pyx_8genexpr5__pyx_v_k = NULL;
PyObject *__pyx_8genexpr5__pyx_v_v = NULL;
PyObject *__pyx_r = NULL;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_as_objects = __pyx_optional_args->as_objects;
if (__pyx_optional_args->__pyx_n > 1) {
__pyx_v_parent = __pyx_optional_args->parent;
}
}
}
__Pyx_INCREF(__pyx_v_value);
1133: ):
1134: """
1135: _handle_dataclass_type.
1136:
1137: Process a field that is annotated as SomeDataclass.
1138: If there's a registered converter for the dataclass, call it;
1139: otherwise, build the dataclass using default logic.
1140: """
+1141: cdef tuple key = (_type, name)
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v__type); __Pyx_GIVEREF(__pyx_v__type); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__type)) __PYX_ERR(0, 1141, __pyx_L1_error); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_name)) __PYX_ERR(0, 1141, __pyx_L1_error); __pyx_v_key = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1142: cdef object converter = TYPE_PARSERS.get(key) or TYPE_PARSERS.get(_type)
if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 1142, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1142, __pyx_L1_error) if (!__pyx_t_3) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L3_bool_binop_done; } if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 1142, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v__type, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_L3_bool_binop_done:; __pyx_v_converter = __pyx_t_1; __pyx_t_1 = 0;
+1143: cdef bint isdc = field.is_dc if field else is_dc(_type)
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_field); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1143, __pyx_L1_error) if (__pyx_t_4) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_is_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_5; } else { __pyx_t_5 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v__type); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1143, __pyx_L1_error) __pyx_t_3 = __pyx_t_5; } __pyx_v_isdc = __pyx_t_3;
+1144: cdef object field_metadata = field.metadata if field else {}
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_field); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1144, __pyx_L1_error) if (__pyx_t_3) { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_metadata); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } else { __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_v_field_metadata = __pyx_t_1; __pyx_t_1 = 0;
+1145: cdef str alias = field_metadata.get('alias')
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field_metadata, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_n_u_alias}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1145, __pyx_L1_error) __pyx_v_alias = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1146:
+1147: if value is None or is_dc(value):
__pyx_t_4 = (__pyx_v_value == Py_None); if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L6_bool_binop_done; } __pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_value); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1147, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L6_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1148: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
+1149: if PyObject_IsInstance(value, dict):
__pyx_t_3 = PyObject_IsInstance(__pyx_v_value, ((PyObject *)(&PyDict_Type))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1149, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+1150: try:
{ /*try:*/ { /* … */ } __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L11_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L13_try_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L0; __pyx_L12_except_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L0; }
1151: # If alias exists, adjust the key passed to the dataclass
+1152: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
1153: # if alias exists on type, preserve the alias:
+1154: if alias not in value and name in value:
__pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_alias, __pyx_v_value, Py_NE)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1154, __pyx_L9_error) if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L17_bool_binop_done; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_name, __pyx_v_value, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1154, __pyx_L9_error) __pyx_t_3 = __pyx_t_4; __pyx_L17_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1155: value = value.copy()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1155, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1155, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_1); __pyx_t_1 = 0;
+1156: value[alias] = value.pop(name)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1156, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_name}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1156, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_value, __pyx_v_alias, __pyx_t_1) < 0))) __PYX_ERR(0, 1156, __pyx_L9_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1157: # convert the dictionary to the dataclass
+1158: return _type(**value)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_value == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1158, __pyx_L9_error) } if (likely(PyDict_CheckExact(__pyx_v_value))) { __pyx_t_1 = PyDict_Copy(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1158, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1158, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v__type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1158, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L13_try_return;
+1159: except TypeError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._handle_dataclass_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) __PYX_ERR(0, 1159, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_6);
1160: # Ensure keys are strings
+1161: value = {str(k): v for k, v in value.items()}
{ /* enter inner scope */ __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1161, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = 0; if (unlikely(__pyx_v_value == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1161, __pyx_L23_error) } __pyx_t_16 = __Pyx_dict_iterator(__pyx_v_value, 0, __pyx_n_s_items, (&__pyx_t_15), (&__pyx_t_11)); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1161, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = __pyx_t_16; __pyx_t_16 = 0; while (1) { __pyx_t_18 = __Pyx_dict_iter_next(__pyx_t_13, __pyx_t_15, &__pyx_t_14, &__pyx_t_16, &__pyx_t_17, NULL, __pyx_t_11); if (unlikely(__pyx_t_18 == 0)) break; if (unlikely(__pyx_t_18 == -1)) __PYX_ERR(0, 1161, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GOTREF(__pyx_t_17); __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_k, __pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_v, __pyx_t_17); __pyx_t_17 = 0; __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_8genexpr5__pyx_v_k); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1161, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_17); if (unlikely(PyDict_SetItem(__pyx_t_12, (PyObject*)__pyx_t_17, (PyObject*)__pyx_8genexpr5__pyx_v_v))) __PYX_ERR(0, 1161, __pyx_L23_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_k); __pyx_8genexpr5__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_v); __pyx_8genexpr5__pyx_v_v = 0; goto __pyx_L26_exit_scope; __pyx_L23_error:; __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_k); __pyx_8genexpr5__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_v); __pyx_8genexpr5__pyx_v_v = 0; goto __pyx_L11_except_error; __pyx_L26_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_12); __pyx_t_12 = 0;
+1162: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
+1163: value = value.copy()
__pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1163, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_17 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_13))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1163, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_12); __pyx_t_12 = 0;
+1164: value[name] = value.pop(alias, None)
__pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_pop); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1164, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_17 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_13))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_v_alias, Py_None}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1164, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_value, __pyx_v_name, __pyx_t_12) < 0))) __PYX_ERR(0, 1164, __pyx_L11_except_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1165: return _type(**value)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_value == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1165, __pyx_L11_except_error) } if (likely(PyDict_CheckExact(__pyx_v_value))) { __pyx_t_12 = PyDict_Copy(__pyx_v_value); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1165, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); } else { __pyx_t_12 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_value); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1165, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); } __pyx_t_13 = __Pyx_PyObject_Call(__pyx_v__type, __pyx_empty_tuple, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1165, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_r = __pyx_t_13; __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L12_except_return; }
+1166: except ValueError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._handle_dataclass_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 1166, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2);
1167: # replace in "value" dictionary the current "name" for "alias"
+1168: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
+1169: value = value.copy()
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1169, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_17 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1169, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_13); __pyx_t_13 = 0;
+1170: value[alias] = value.pop(name, None)
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_pop); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1170, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_17 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_v_name, Py_None}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1170, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_value, __pyx_v_alias, __pyx_t_13) < 0))) __PYX_ERR(0, 1170, __pyx_L11_except_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+1171: return _type(**value)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_value == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1171, __pyx_L11_except_error) } if (likely(PyDict_CheckExact(__pyx_v_value))) { __pyx_t_13 = PyDict_Copy(__pyx_v_value); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1171, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); } else { __pyx_t_13 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_value); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1171, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_13); } __pyx_t_12 = __Pyx_PyObject_Call(__pyx_v__type, __pyx_empty_tuple, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1171, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_r = __pyx_t_12; __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L12_except_return; }
+1172: except Exception as exc:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._handle_dataclass_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) __PYX_ERR(0, 1172, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L36_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_26); __pyx_t_11 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_20 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26); } __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23); __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_20; goto __pyx_L11_except_error; } } } goto __pyx_L11_except_error;
+1173: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1173, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 1173, __pyx_L36_error) }
+1174: f"Invalid value for {name}:{_type} == {value}, error: {exc}"
__pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1174, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = 0; __pyx_t_19 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_value_for); __pyx_t_15 += 18; __Pyx_GIVEREF(__pyx_kp_u_Invalid_value_for); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Invalid_value_for); __pyx_t_13 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1174, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__6); __pyx_t_15 += 1; __Pyx_GIVEREF(__pyx_kp_u__6); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_kp_u__6); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v__type, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1174, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__11); __pyx_t_15 += 4; __Pyx_GIVEREF(__pyx_kp_u__11); PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_kp_u__11); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1174, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u_error_2); __pyx_t_15 += 9; __Pyx_GIVEREF(__pyx_kp_u_error_2); PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_kp_u_error_2); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1174, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 7, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_12, 8, __pyx_t_15, __pyx_t_19); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1174, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1175: )
+1176: try:
{ /*try:*/ { /* … */ } __pyx_L42_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L44_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_9, __pyx_t_8); goto __pyx_L1_error; __pyx_L46_try_return:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_9, __pyx_t_8); goto __pyx_L0; }
+1177: if PyObject_IsInstance(value, (list, tuple)):
__pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1177, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF((PyObject *)(&PyList_Type)); __Pyx_GIVEREF((PyObject *)(&PyList_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyList_Type)))) __PYX_ERR(0, 1177, __pyx_L42_error); __Pyx_INCREF((PyObject *)(&PyTuple_Type)); __Pyx_GIVEREF((PyObject *)(&PyTuple_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)(&PyTuple_Type)))) __PYX_ERR(0, 1177, __pyx_L42_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1177, __pyx_L42_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { /* … */ }
+1178: return _type(*value)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1178, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v__type, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1178, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L46_try_return;
1179: else:
1180: # If a converter exists for this type, use it:
+1181: if converter:
/*else*/ { __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1181, __pyx_L42_error) if (__pyx_t_3) { /* … */ }
+1182: return converter(name, value, _type, parent)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_converter); __pyx_t_6 = __pyx_v_converter; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_2, __pyx_v_name, __pyx_v_value, __pyx_v__type, __pyx_v_parent}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1182, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L46_try_return;
+1183: if as_objects:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_as_objects); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1183, __pyx_L42_error) if (__pyx_t_3) { /* … */ }
1184: # If alias exists, adjust the key passed to the dataclass
+1185: if not alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
__pyx_t_4 = (!__pyx_t_3);
if (__pyx_t_4) {
/* … */
}
+1186: alias = name
__Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_alias, __pyx_v_name);
1187: # convert the list to the dataclass
+1188: return _type(**{alias: value})
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1188, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyDict_Contains(__pyx_t_1, __pyx_v_alias))) { __Pyx_RaiseDoubleKeywordsError("function", __pyx_v_alias); __PYX_ERR(0, 1188, __pyx_L42_error) } else { if (PyDict_SetItem(__pyx_t_1, __pyx_v_alias, __pyx_v_value) < 0) __PYX_ERR(0, 1188, __pyx_L42_error) } __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v__type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1188, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L46_try_return;
+1189: if PyObject_IsInstance(value, (int, str, UUID)):
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_UUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1189, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1189, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 1189, __pyx_L42_error); __Pyx_INCREF((PyObject *)(&PyUnicode_Type)); __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 1189, __pyx_L42_error); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_6)) __PYX_ERR(0, 1189, __pyx_L42_error); __pyx_t_6 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_v_value, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1189, __pyx_L42_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* … */ }
+1190: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L46_try_return;
+1191: if isdc:
if (__pyx_v_isdc) { /* … */ }
+1192: if not alias:
__pyx_t_4 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
__pyx_t_3 = (!__pyx_t_4);
if (__pyx_t_3) {
/* … */
}
+1193: alias = name
__Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_alias, __pyx_v_name);
+1194: return _type(**{alias: value})
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1194, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(PyDict_Contains(__pyx_t_1, __pyx_v_alias))) { __Pyx_RaiseDoubleKeywordsError("function", __pyx_v_alias); __PYX_ERR(0, 1194, __pyx_L42_error) } else { if (PyDict_SetItem(__pyx_t_1, __pyx_v_alias, __pyx_v_value) < 0) __PYX_ERR(0, 1194, __pyx_L42_error) } __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v__type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1194, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L46_try_return;
1195: else:
+1196: return _type(value)
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v__type); __pyx_t_1 = __pyx_v__type; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_value}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1196, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L46_try_return; } }
+1197: except Exception as exc:
__pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_18) { __Pyx_AddTraceback("datamodel.converters._handle_dataclass_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 1197, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L60_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24); __Pyx_XGOTREF(__pyx_t_26); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_18 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_27 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_22, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_ErrRestore(__pyx_t_26, __pyx_t_25, __pyx_t_24); __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_27; goto __pyx_L44_except_error; } } } goto __pyx_L44_except_error;
+1198: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1198, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 1198, __pyx_L60_error) }
+1199: f"Invalid value for {name}:{_type} == {value}, error: {exc}"
__pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1199, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = 0; __pyx_t_19 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_value_for); __pyx_t_15 += 18; __Pyx_GIVEREF(__pyx_kp_u_Invalid_value_for); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Invalid_value_for); __pyx_t_13 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1199, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__6); __pyx_t_15 += 1; __Pyx_GIVEREF(__pyx_kp_u__6); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_kp_u__6); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v__type, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1199, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u__11); __pyx_t_15 += 4; __Pyx_GIVEREF(__pyx_kp_u__11); PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_kp_u__11); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1199, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u_error_2); __pyx_t_15 += 9; __Pyx_GIVEREF(__pyx_kp_u_error_2); PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_kp_u_error_2); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1199, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 7, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_12, 8, __pyx_t_15, __pyx_t_19); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1199, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1200: )
1201:
+1202: cdef object _handle_list_of_dataclasses(
static PyObject *__pyx_f_9datamodel_10converters__handle_list_of_dataclasses(CYTHON_UNUSED PyObject *__pyx_v_field, PyObject *__pyx_v_name, PyObject *__pyx_v_value, PyObject *__pyx_v__type, struct __pyx_opt_args_9datamodel_10converters__handle_list_of_dataclasses *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("datamodel.converters._handle_list_of_dataclasses", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_sub_type); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_converter); __Pyx_XDECREF(__pyx_v_new_list); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__handle_list_of_dataclasses { int __pyx_n; PyObject *parent; };
1203: object field,
1204: str name,
1205: object value,
1206: object _type,
+1207: object parent = None
PyObject *__pyx_v_parent = ((PyObject *)Py_None); PyObject *__pyx_v_sub_type = NULL; PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_converter = NULL; PyObject *__pyx_v_new_list = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_parent = __pyx_optional_args->parent; } }
1208: ):
1209: """
1210: _handle_list_of_dataclasses.
1211:
1212: Process a list field that is annotated as List[SomeDataclass].
1213: If there's a registered converter for the sub-dataclass, call it;
1214: otherwise, build the sub-dataclass using default logic.
1215: """
+1216: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_L8_try_end:; }
+1217: sub_type = _type.__args__[0]
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v__type, __pyx_n_s_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1217, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1217, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_sub_type = __pyx_t_5; __pyx_t_5 = 0;
+1218: if is_dc(sub_type):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_sub_type); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1218, __pyx_L3_error) if (__pyx_t_6) { /* … */ }
+1219: key = (sub_type, name)
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1219, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_sub_type); __Pyx_GIVEREF(__pyx_v_sub_type); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_sub_type)) __PYX_ERR(0, 1219, __pyx_L3_error); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_name)) __PYX_ERR(0, 1219, __pyx_L3_error); __pyx_v_key = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1220: converter = TYPE_PARSERS.get(key) or TYPE_PARSERS.get(_type)
if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 1220, __pyx_L3_error) } __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1220, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1220, __pyx_L3_error) if (!__pyx_t_6) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = __pyx_t_4; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L10_bool_binop_done; } if (unlikely(__pyx_v_9datamodel_10converters_TYPE_PARSERS == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 1220, __pyx_L3_error) } __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v__type, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1220, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = __pyx_t_4; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_L10_bool_binop_done:; __pyx_v_converter = __pyx_t_5; __pyx_t_5 = 0;
+1221: new_list = []
__pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1221, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_new_list = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1222: for item in value:
if (likely(PyList_CheckExact(__pyx_v_value)) || PyTuple_CheckExact(__pyx_v_value)) { __pyx_t_5 = __pyx_v_value; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1222, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1222, __pyx_L3_error) } for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_5))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1222, __pyx_L3_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1222, __pyx_L3_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1222, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1222, __pyx_L3_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1222, __pyx_L3_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1222, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_8(__pyx_t_5); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1222, __pyx_L3_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4); __pyx_t_4 = 0; /* … */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1223: if converter:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1223, __pyx_L3_error) if (__pyx_t_6) { /* … */ goto __pyx_L14; }
+1224: new_list.append(converter(name, item, sub_type, parent))
__Pyx_INCREF(__pyx_v_converter); __pyx_t_9 = __pyx_v_converter; __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_10, __pyx_v_name, __pyx_v_item, __pyx_v_sub_type, __pyx_v_parent}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_11, 4+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1224, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_new_list, __pyx_t_4); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1224, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1225: elif isinstance(item, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_item);
if (__pyx_t_6) {
/* … */
goto __pyx_L14;
}
+1226: new_list.append(sub_type(**item))
if (unlikely(__pyx_v_item == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1226, __pyx_L3_error) } if (likely(PyDict_CheckExact(__pyx_v_item))) { __pyx_t_4 = PyDict_Copy(__pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1226, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); } else { __pyx_t_4 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1226, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); } __pyx_t_9 = __Pyx_PyObject_Call(__pyx_v_sub_type, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1226, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_new_list, __pyx_t_9); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1226, __pyx_L3_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1227: else:
+1228: new_list.append(item)
/*else*/ { __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_new_list, __pyx_v_item); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1228, __pyx_L3_error) } __pyx_L14:;
+1229: return new_list
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_list); __pyx_r = __pyx_v_new_list; goto __pyx_L7_try_return;
+1230: except AttributeError:
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_13) { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error;
1231: pass
+1232: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1233:
+1234: cdef object _handle_default_value(
static PyObject *__pyx_f_9datamodel_10converters__handle_default_value(PyObject *__pyx_v_obj, PyObject *__pyx_v_name, PyObject *__pyx_v_value, PyObject *__pyx_v_default_func, PyObject *__pyx_v_default_is_callable) { PyObject *__pyx_v_new_val = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("datamodel.converters._handle_default_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_new_val); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1235: object obj,
1236: str name,
1237: object value,
1238: object default_func,
1239: object default_is_callable
1240: ):
1241: """Handle default value of fields."""
1242: # If value is callable, try calling it directly
+1243: if PyCallable_Check(value):
__pyx_t_1 = PyCallable_Check(__pyx_v_value);
if (__pyx_t_1) {
/* … */
}
+1244: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L5_exception_handled:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); __pyx_L9_try_end:; }
+1245: new_val = value()
__Pyx_INCREF(__pyx_v_value); __pyx_t_6 = __pyx_v_value; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1245, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_v_new_val = __pyx_t_5; __pyx_t_5 = 0;
+1246: except TypeError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._handle_default_value", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 1246, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+1247: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L19_try_end; __pyx_L12_error:; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; /* … */ __pyx_L14_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L6_except_error; __pyx_L13_exception_handled:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_L19_try_end:; } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L5_exception_handled; } goto __pyx_L6_except_error;
+1248: new_val = default_func()
__Pyx_INCREF(__pyx_v_default_func); __pyx_t_14 = __pyx_v_default_func; __pyx_t_15 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1248, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __Pyx_XDECREF_SET(__pyx_v_new_val, __pyx_t_13); __pyx_t_13 = 0;
+1249: except TypeError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._handle_default_value", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0) __PYX_ERR(0, 1249, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15);
+1250: new_val = None
__Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_new_val, Py_None); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L13_exception_handled; } goto __pyx_L14_except_error;
+1251: setattr(obj, name, new_val)
__pyx_t_16 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_name, __pyx_v_new_val); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1251, __pyx_L1_error)
+1252: return new_val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_val); __pyx_r = __pyx_v_new_val; goto __pyx_L0;
1253:
1254: # If f.default is callable and value is None
+1255: if default_is_callable and value is None:
__pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_v_default_is_callable); if (unlikely((__pyx_t_17 < 0))) __PYX_ERR(0, 1255, __pyx_L1_error) if (__pyx_t_17) { } else { __pyx_t_1 = __pyx_t_17; goto __pyx_L23_bool_binop_done; } __pyx_t_17 = (__pyx_v_value == Py_None); __pyx_t_1 = __pyx_t_17; __pyx_L23_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+1256: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L30_try_end; __pyx_L25_error:; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L27_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L1_error; __pyx_L26_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); __pyx_L30_try_end:; }
+1257: new_val = default_func()
__Pyx_INCREF(__pyx_v_default_func); __pyx_t_6 = __pyx_v_default_func; __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1257, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_v_new_val = __pyx_t_7; __pyx_t_7 = 0;
+1258: except (AttributeError, RuntimeError, TypeError):
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_RuntimeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._handle_default_value", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 1258, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+1259: new_val = None
__Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_new_val, Py_None); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L26_exception_handled; } goto __pyx_L27_except_error;
+1260: setattr(obj, name, new_val)
__pyx_t_16 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_name, __pyx_v_new_val); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1260, __pyx_L1_error)
+1261: return new_val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_val); __pyx_r = __pyx_v_new_val; goto __pyx_L0;
1262:
1263: # If there's a non-missing default and no value
+1264: if not isinstance(default_func, _MISSING_TYPE) and value is None:
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_17 = PyObject_IsInstance(__pyx_v_default_func, __pyx_t_5); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_18 = (!__pyx_t_17); if (__pyx_t_18) { } else { __pyx_t_1 = __pyx_t_18; goto __pyx_L34_bool_binop_done; } __pyx_t_18 = (__pyx_v_value == Py_None); __pyx_t_1 = __pyx_t_18; __pyx_L34_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+1265: setattr(obj, name, default_func)
__pyx_t_16 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_name, __pyx_v_default_func); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1265, __pyx_L1_error)
+1266: return default_func
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default_func); __pyx_r = __pyx_v_default_func; goto __pyx_L0;
1267:
1268: # Otherwise, return value as-is
+1269: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1270:
+1271: cdef dict _build_error(str name, str message, object exp):
static PyObject *__pyx_f_9datamodel_10converters__build_error(PyObject *__pyx_v_name, PyObject *__pyx_v_message, PyObject *__pyx_v_exp) { PyObject *__pyx_v_error_message = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("datamodel.converters._build_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_error_message); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1272: """
1273: _build_error.
1274:
1275: Build a tuple containing an error message and the name of the field.
1276: """
+1277: cdef str error_message = message + name + ", Error: " + str(exp)
__pyx_t_1 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_message, __pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_1, __pyx_kp_u_Error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Unicode(__pyx_v_exp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_error_message = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1278: return {name: error_message}
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_v_name, __pyx_v_error_message) < 0) __PYX_ERR(0, 1278, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
1279:
+1280: cpdef dict processing_fields(object obj, list columns):
static PyObject *__pyx_pw_9datamodel_10converters_35processing_fields(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_processing_fields(PyObject *__pyx_v_obj, PyObject *__pyx_v_columns, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v__encoder = 0; PyObject *__pyx_v__default = 0; PyObject *__pyx_v__type = 0; PyObject *__pyx_v_meta = 0; int __pyx_v_as_objects; int __pyx_v_no_nesting; PyObject *__pyx_v_type_args = 0; PyObject *__pyx_v_errors = 0; CYTHON_UNUSED PyObject *__pyx_v__typeinfo = 0; PyObject *__pyx_v_c_col = 0; PyObject *__pyx_v_name = 0; PyObject *__pyx_v_f = 0; PyObject *__pyx_v_value = 0; PyObject *__pyx_v_newval = 0; PyObject *__pyx_v_field_category = NULL; PyObject *__pyx_v_e = NULL; CYTHON_UNUSED PyObject *__pyx_v_typeinfo = NULL; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_v_ex = NULL; PyObject *__pyx_v_error = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_37); __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v__encoder); __Pyx_XDECREF(__pyx_v__default); __Pyx_XDECREF(__pyx_v__type); __Pyx_XDECREF(__pyx_v_meta); __Pyx_XDECREF(__pyx_v_type_args); __Pyx_XDECREF(__pyx_v_errors); __Pyx_XDECREF(__pyx_v__typeinfo); __Pyx_XDECREF(__pyx_v_c_col); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_f); __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_newval); __Pyx_XDECREF(__pyx_v_field_category); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_typeinfo); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XDECREF(__pyx_v_error); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_35processing_fields(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_34processing_fields, "processing_fields(obj, list columns) -> dict\n\n Process the fields (columns) of a dataclass object.\n\n For each field, if a custom parser is attached (i.e. f.parser is not None),\n it is used to convert the value. Otherwise, the standard conversion logic\n (parse_basic, parse_typing, etc.) is applied.\n "); static PyMethodDef __pyx_mdef_9datamodel_10converters_35processing_fields = {"processing_fields", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_35processing_fields, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_34processing_fields}; static PyObject *__pyx_pw_9datamodel_10converters_35processing_fields(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_columns = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("processing_fields (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_columns,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1280, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1280, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("processing_fields", 1, 2, 2, 1); __PYX_ERR(0, 1280, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "processing_fields") < 0)) __PYX_ERR(0, 1280, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_obj = values[0]; __pyx_v_columns = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("processing_fields", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1280, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_columns), (&PyList_Type), 1, "columns", 1))) __PYX_ERR(0, 1280, __pyx_L1_error) __pyx_r = __pyx_pf_9datamodel_10converters_34processing_fields(__pyx_self, __pyx_v_obj, __pyx_v_columns); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_34processing_fields(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_columns) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters_processing_fields(__pyx_v_obj, __pyx_v_columns, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__46 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_columns); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_35processing_fields, 0, __pyx_n_s_processing_fields, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_processing_fields, __pyx_t_2) < 0) __PYX_ERR(0, 1280, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_processing_fields, 1280, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 1280, __pyx_L1_error)
1281: """
1282: Process the fields (columns) of a dataclass object.
1283:
1284: For each field, if a custom parser is attached (i.e. f.parser is not None),
1285: it is used to convert the value. Otherwise, the standard conversion logic
1286: (parse_basic, parse_typing, etc.) is applied.
1287: """
1288: cdef object new_val
+1289: cdef object _encoder = None
__Pyx_INCREF(Py_None);
__pyx_v__encoder = Py_None;
+1290: cdef object _default = None
__Pyx_INCREF(Py_None);
__pyx_v__default = Py_None;
+1291: cdef object _type = None
__Pyx_INCREF(Py_None);
__pyx_v__type = Py_None;
+1292: cdef object meta = obj.Meta
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_Meta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_meta = __pyx_t_1; __pyx_t_1 = 0;
+1293: cdef bint as_objects = meta.as_objects
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_meta, __pyx_n_s_as_objects); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1293, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_as_objects = __pyx_t_2;
+1294: cdef bint no_nesting = meta.no_nesting
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_meta, __pyx_n_s_no_nesting); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_no_nesting = __pyx_t_2;
+1295: cdef tuple type_args = ()
__Pyx_INCREF(__pyx_empty_tuple);
__pyx_v_type_args = __pyx_empty_tuple;
1296: # Error handling
+1297: cdef dict errors = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_errors = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1298: # Type Information
+1299: cdef dict _typeinfo = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__typeinfo = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1300: # Column information:
1301: cdef tuple c_col
1302: cdef str name
1303: cdef object f
1304: cdef object value
1305: cdef object newval
1306:
+1307: for c_col in columns:
if (unlikely(__pyx_v_columns == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1307, __pyx_L1_error) } __pyx_t_1 = __pyx_v_columns; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1307, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 1307, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif if (!(likely(PyTuple_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_4))) __PYX_ERR(0, 1307, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_c_col, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* … */ __pyx_L3_continue:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1308: name = c_col[0]
if (unlikely(__pyx_v_c_col == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1308, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_c_col, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_4))) __PYX_ERR(0, 1308, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_name, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+1309: f = c_col[1]
if (unlikely(__pyx_v_c_col == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1309, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_c_col, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_4); __pyx_t_4 = 0;
+1310: value = getattr(obj, name)
__pyx_t_4 = __Pyx_GetAttr(__pyx_v_obj, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0;
1311: # Use the precomputed field type category:
+1312: field_category = f._type_category
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_category); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_field_category, __pyx_t_4); __pyx_t_4 = 0;
1313:
+1314: if field_category == 'descriptor':
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_field_category, __pyx_n_u_descriptor, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1314, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
1315: # Handle descriptor-specific logic
+1316: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L13_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L7_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); __pyx_L13_try_end:; }
+1317: value = f.__get__(obj, type(obj)) # Get the descriptor value
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_get_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1317, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_v_obj, ((PyObject *)Py_TYPE(__pyx_v_obj))}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_10, 2+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1317, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0;
+1318: PyObject_SetAttr(obj, name, value)
__pyx_t_11 = PyObject_SetAttr(__pyx_v_obj, __pyx_v_name, __pyx_v_value); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1318, __pyx_L6_error)
+1319: except Exception as e:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 1319, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_8); /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L20; } __pyx_L19_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23); } __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20); __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17; goto __pyx_L8_except_error; } __pyx_L20:; } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_exception_handled; } goto __pyx_L8_except_error;
+1320: errors.update(_build_error(name, f"Descriptor Error on {name}: ", e))
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1320, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Descriptor_Error_on); __pyx_t_13 += 20; __Pyx_GIVEREF(__pyx_kp_u_Descriptor_Error_on); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Descriptor_Error_on); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1320, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_15); __pyx_t_15 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_kp_u__7); __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_12, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1320, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_15), __pyx_v_e); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1320, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1320, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; }
+1321: continue
goto __pyx_L3_continue;
1322:
1323: # get type and default:
+1324: _type = f.type
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v__type, __pyx_t_9); __pyx_t_9 = 0;
+1325: _default = f.default
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_default); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v__default, __pyx_t_9); __pyx_t_9 = 0;
+1326: typeinfo = f.typeinfo # cached info (e.g., type_args, default_callable)
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_typeinfo); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_typeinfo, __pyx_t_9); __pyx_t_9 = 0;
+1327: type_args = f.type_args
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (!(likely(PyTuple_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_9))) __PYX_ERR(0, 1327, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_type_args, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+1328: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L32_try_end; __pyx_L25_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L27_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5); goto __pyx_L1_error; __pyx_L26_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5); __pyx_L32_try_end:; }
+1329: metadata = f.metadata
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_metadata); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1329, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_metadata, __pyx_t_9); __pyx_t_9 = 0;
+1330: except AttributeError:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 1330, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4);
+1331: metadata = PyObject_GetAttr(f, "metadata")
__pyx_t_15 = PyObject_GetAttr(__pyx_v_f, __pyx_n_u_metadata); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1331, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_XDECREF_SET(__pyx_v_metadata, __pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L26_exception_handled; } goto __pyx_L27_except_error;
1332:
1333: # _default_callable = typeinfo.get('default_callable', False)
1334: # Check if object is empty
+1335: if is_empty(value) and not PyObject_IsInstance(value, list):
__pyx_t_24 = __pyx_f_9datamodel_10converters_is_empty(__pyx_v_value); if (unlikely(__pyx_t_24 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1335, __pyx_L1_error) if (__pyx_t_24) { } else { __pyx_t_2 = __pyx_t_24; goto __pyx_L36_bool_binop_done; } __pyx_t_24 = PyObject_IsInstance(__pyx_v_value, ((PyObject *)(&PyList_Type))); if (unlikely(__pyx_t_24 == ((int)-1))) __PYX_ERR(0, 1335, __pyx_L1_error) __pyx_t_25 = (!__pyx_t_24); __pyx_t_2 = __pyx_t_25; __pyx_L36_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1336: if _type == str and value is not "":
__pyx_t_4 = PyObject_RichCompare(__pyx_v__type, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1336, __pyx_L1_error) __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 1336, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_25) { } else { __pyx_t_2 = __pyx_t_25; goto __pyx_L39_bool_binop_done; } __pyx_t_25 = (__pyx_v_value != __pyx_kp_u__2); __pyx_t_2 = __pyx_t_25; __pyx_L39_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1337: value = f.default_factory if PyObject_IsInstance(_default, (_MISSING_TYPE)) else _default
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = PyObject_IsInstance(__pyx_v__default, __pyx_t_8); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1337, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_default_factory); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __pyx_t_8; __pyx_t_8 = 0; } else { __Pyx_INCREF(__pyx_v__default); __pyx_t_4 = __pyx_v__default; } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0;
1338: # PyObject_SetAttr(obj, name, value)
+1339: obj.__dict__[name] = value
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_value) < 0))) __PYX_ERR(0, 1339, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1340: if _default is not None:
__pyx_t_2 = (__pyx_v__default != Py_None); if (__pyx_t_2) { /* … */ }
+1341: value = _handle_default_value(obj, name, value, _default, f._default_callable)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_default_callable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __pyx_f_9datamodel_10converters__handle_default_value(__pyx_v_obj, __pyx_v_name, __pyx_v_value, __pyx_v__default, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_8); __pyx_t_8 = 0;
+1342: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L49_try_end; __pyx_L42_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L44_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L48_try_continue:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L3_continue; __pyx_L49_try_end:; }
+1343: _encoder = metadata.get('encoder')
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_metadata, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1343, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_n_u_encoder}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1343, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v__encoder, __pyx_t_8); __pyx_t_8 = 0;
+1344: newval = value
__Pyx_INCREF(__pyx_v_value); __Pyx_XDECREF_SET(__pyx_v_newval, __pyx_v_value);
+1345: if f.parser is not None:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_parser); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1345, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_8 != Py_None); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L50; }
1346: # If a custom parser is attached to Field, use it
+1347: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; goto __pyx_L58_try_end; __pyx_L51_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L53_except_error:; __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_22, __pyx_t_21); goto __pyx_L42_error; __pyx_L57_try_continue:; __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_22, __pyx_t_21); goto __pyx_L48_try_continue; __pyx_L58_try_end:; }
+1348: newval = f.parser(value)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_parser); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1348, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_value}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1348, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
+1349: if newval != value:
__pyx_t_8 = PyObject_RichCompare(__pyx_v_newval, __pyx_v_value, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1349, __pyx_L51_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1349, __pyx_L51_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
+1350: obj.__dict__[name] = newval
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1350, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1350, __pyx_L51_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1351: except Exception as ex:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1351, __pyx_L53_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_v_ex = __pyx_t_4; /*try:*/ { /* … */ /*finally:*/ { __pyx_L65_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_26 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_29); __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_28, __pyx_t_29); } __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_20, __pyx_t_19, __pyx_t_18); __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_26; goto __pyx_L53_except_error; } __pyx_L62_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L60_except_continue; } } __pyx_L60_except_continue:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L57_try_continue; } goto __pyx_L53_except_error;
+1352: errors.update(_build_error(name, f"Error parsing *{name}* = *{value}*", ex))
__pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1352, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing); __pyx_t_13 += 15; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1352, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__12); __pyx_t_13 += 5; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__12); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1352, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__13); __pyx_t_13 += 1; __Pyx_GIVEREF(__pyx_kp_u__13); PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_kp_u__13); __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_15, 5, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1352, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_12), __pyx_v_ex); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1352, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1352, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1353: continue
goto __pyx_L62_continue; }
+1354: elif field_category == 'primitive':
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_field_category, __pyx_n_u_primitive, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1354, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1355: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; goto __pyx_L78_try_end; __pyx_L71_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L73_except_error:; __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23); goto __pyx_L42_error; __pyx_L77_try_continue:; __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23); goto __pyx_L48_try_continue; __pyx_L78_try_end:; }
+1356: newval = parse_basic(_type, value, _encoder)
__pyx_t_30.__pyx_n = 1; __pyx_t_30.encoder = __pyx_v__encoder; __pyx_t_9 = __pyx_f_9datamodel_10converters_parse_basic(__pyx_v__type, __pyx_v_value, 0, &__pyx_t_30); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1356, __pyx_L71_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+1357: if newval != value:
__pyx_t_9 = PyObject_RichCompare(__pyx_v_newval, __pyx_v_value, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1357, __pyx_L71_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1357, __pyx_L71_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ }
+1358: obj.__dict__[name] = newval
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1358, __pyx_L71_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_t_9, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1358, __pyx_L71_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+1359: except ValueError as ex:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1359, __pyx_L73_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_v_ex = __pyx_t_4; /*try:*/ { /* … */ /*finally:*/ { __pyx_L85_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27) < 0)) __Pyx_ErrFetch(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_31 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ErrRestore(__pyx_t_29, __pyx_t_28, __pyx_t_27); __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_31; goto __pyx_L73_except_error; } __pyx_L82_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L80_except_continue; } } __pyx_L80_except_continue:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L77_try_continue; } goto __pyx_L73_except_error;
+1360: errors.update(_build_error(name, f"Error parsing {name}: ", ex))
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1360, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_2); __pyx_t_13 += 14; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Error_parsing_2); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1360, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_15); __pyx_t_15 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_kp_u__7); __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_12, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1360, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_15), __pyx_v_ex); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1360, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1360, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+1361: continue
goto __pyx_L82_continue; }
+1362: elif field_category == 'type':
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_field_category, __pyx_n_u_type_2, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1362, __pyx_L42_error) if (__pyx_t_2) { goto __pyx_L50; }
1363: # TODO: support multiple types
1364: pass
+1365: elif field_category == 'dataclass':
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_field_category, __pyx_n_u_dataclass, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1365, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1366: if no_nesting is False:
__pyx_t_2 = (__pyx_v_no_nesting == 0); if (__pyx_t_2) { /* … */ }
+1367: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L92; }
+1368: newval = _handle_dataclass_type(
__pyx_t_32.__pyx_n = 2; __pyx_t_32.as_objects = __pyx_t_8; __pyx_t_32.parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__handle_dataclass_type(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1368, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
+1369: f, name, value, _type, as_objects, obj
__pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1369, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8);
1370: )
1371: else:
+1372: newval = _handle_dataclass_type(
/*else*/ { /* … */ __pyx_t_32.__pyx_n = 2; __pyx_t_32.as_objects = __pyx_t_4; __pyx_t_32.parent = Py_None; __pyx_t_8 = __pyx_f_9datamodel_10converters__handle_dataclass_type(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1372, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L92:;
+1373: f, name, value, _type, as_objects, None
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1373, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4);
1374: )
+1375: if newval!= value:
__pyx_t_8 = PyObject_RichCompare(__pyx_v_newval, __pyx_v_value, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1375, __pyx_L42_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1375, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
1376: # PyObject_SetAttr(obj, name, newval)
+1377: obj.__dict__[name] = newval
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1377, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1377, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1378: elif f.origin in (list, 'list') and f._inner_is_dc:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1378, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1378, __pyx_L42_error) __pyx_t_24 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 1378, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_24) { } else { __pyx_t_25 = __pyx_t_24; goto __pyx_L96_bool_binop_done; } __pyx_t_24 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_list, Py_EQ)); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 1378, __pyx_L42_error) __pyx_t_25 = __pyx_t_24; __pyx_L96_bool_binop_done:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_24 = __pyx_t_25; if (__pyx_t_24) { } else { __pyx_t_2 = __pyx_t_24; goto __pyx_L94_bool_binop_done; } __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1378, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_24 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 1378, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_24; __pyx_L94_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1379: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L98; }
+1380: newval = _handle_list_of_dataclasses(f, name, value, _type, obj)
__pyx_t_33.__pyx_n = 1; __pyx_t_33.parent = __pyx_v_obj; __pyx_t_8 = __pyx_f_9datamodel_10converters__handle_list_of_dataclasses(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_33); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1380, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
1381: else:
+1382: newval = _handle_list_of_dataclasses(f, name, value, _type, None)
/*else*/ { __pyx_t_33.__pyx_n = 1; __pyx_t_33.parent = Py_None; __pyx_t_8 = __pyx_f_9datamodel_10converters__handle_list_of_dataclasses(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_33); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1382, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L98:;
+1383: obj.__dict__[name] = newval
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1383, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1383, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1384: elif field_category == 'typing':
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_field_category, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1384, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1385: if f.is_dc:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_is_dc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1385, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1385, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L99; }
1386: # means that is_dataclass(T)
+1387: newval = _handle_dataclass_type(None, name, value, _type, as_objects, None)
__pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1387, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_32.__pyx_n = 2; __pyx_t_32.as_objects = __pyx_t_8; __pyx_t_32.parent = Py_None; __pyx_t_4 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1387, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
+1388: obj.__dict__[name] = newval
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1388, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1388, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1389: elif f.origin is list:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1389, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = (__pyx_t_4 == ((PyObject *)(&PyList_Type))); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L99; }
1390: # Other typical case is when is a List of primitives.
+1391: if f._inner_priv:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_priv); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1391, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1391, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L100; }
+1392: newval = _parse_list_type(
__pyx_t_34.__pyx_n = 1; __pyx_t_34._parent = __pyx_v_obj; __pyx_t_8 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_f, __pyx_v__type, __pyx_v_value, __pyx_v__encoder, __pyx_t_4, &__pyx_t_34); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1392, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
1393: f,
1394: _type,
1395: value,
1396: _encoder,
+1397: f.args,
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1397, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4);
1398: obj
1399: )
1400: else:
+1401: try:
/*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; goto __pyx_L108_try_end; __pyx_L101_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L103_except_error:; __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_22, __pyx_t_21); goto __pyx_L42_error; __pyx_L108_try_end:; } } __pyx_L100:;
+1402: newval = _parse_typing(
__pyx_t_35.__pyx_n = 3; __pyx_t_35.encoder = __pyx_v__encoder; __pyx_t_35.as_objects = __pyx_t_8; __pyx_t_35.parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_35); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1402, __pyx_L101_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
1403: f,
1404: _type,
1405: value,
1406: _encoder,
+1407: as_objects,
__pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1407, __pyx_L101_error) __Pyx_GOTREF(__pyx_t_8);
1408: obj
1409: )
+1410: except Exception as e:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 1410, __pyx_L103_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_8); /*try:*/ { /* … */ /*finally:*/ { __pyx_L114_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_36 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_29); __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_28, __pyx_t_29); } __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_20, __pyx_t_19, __pyx_t_18); __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_36; goto __pyx_L103_except_error; } } } goto __pyx_L103_except_error;
+1411: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1411, __pyx_L114_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_15, 0, 0, 0); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __PYX_ERR(0, 1411, __pyx_L114_error) }
+1412: f"Error parsing List: {name}: {e}"
__pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1412, __pyx_L114_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_List); __pyx_t_13 += 20; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_List); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing_List); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1412, __pyx_L114_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__7); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1412, __pyx_L114_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_15, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1412, __pyx_L114_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
1413: )
+1414: obj.__dict__[name] = newval
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1414, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_t_9, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1414, __pyx_L42_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1415: # If the field is a Union and data is a list, use _parse_union_type.
+1416: elif f.origin is Union:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1416, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Union); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1416, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_9 == __pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L99; }
1417: # e.g. Optional[...] or Union[A, B]
+1418: if len(f.args) == 2 and type(None) in f.args:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1418, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_13 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1418, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_24 = (__pyx_t_13 == 2); if (__pyx_t_24) { } else { __pyx_t_2 = __pyx_t_24; goto __pyx_L121_bool_binop_done; } __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1418, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_24 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_t_8, Py_EQ)); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 1418, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_24; __pyx_L121_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L120; }
1419: # Handle Optional[...] that is Union[..., None] cases first:
+1420: if f._inner_priv:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_priv); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1420, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1420, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
1421: # If Optional but non-None is a primitive
+1422: newval = _parse_builtin_type(f, f._inner_type, value, _encoder)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1422, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_f, __pyx_t_8, __pyx_v_value, __pyx_v__encoder); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1422, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+1423: if f._inner_is_dc:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1423, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1423, __pyx_L42_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ }
1424: # non-None is a Optional Dataclass:
+1425: newval = _handle_dataclass_type(
__pyx_t_32.__pyx_n = 2; __pyx_t_32.as_objects = __pyx_t_8; __pyx_t_32.parent = Py_None; __pyx_t_4 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, __pyx_v_name, __pyx_v_value, __pyx_t_9, &__pyx_t_32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1425, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
+1426: None, name, value, f._inner_type, as_objects, None
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1426, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1426, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8);
1427: )
+1428: obj.__dict__[name] = newval
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1428, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1428, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1429: else:
+1430: newval = _parse_typing(
/*else*/ { /* … */ __pyx_t_35.__pyx_n = 3; __pyx_t_35.encoder = __pyx_v__encoder; __pyx_t_35.as_objects = __pyx_t_4; __pyx_t_35.parent = __pyx_v_obj; __pyx_t_8 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_35); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1430, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
1431: f,
1432: _type,
1433: value,
1434: _encoder,
+1435: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1435, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4);
1436: obj
1437: )
+1438: obj.__dict__[name] = newval
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1438, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1438, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_L120:;
1439: else:
+1440: try:
/*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; goto __pyx_L132_try_end; __pyx_L125_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L127_except_error:; __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23); goto __pyx_L42_error; __pyx_L132_try_end:; } } __pyx_L99:;
+1441: newval = _parse_typing(
__pyx_t_35.__pyx_n = 3; __pyx_t_35.encoder = __pyx_v__encoder; __pyx_t_35.as_objects = __pyx_t_8; __pyx_t_35.parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_35); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1441, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
1442: f,
1443: _type,
1444: value,
1445: _encoder,
+1446: as_objects,
__pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1446, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_8);
1447: obj
1448: )
+1449: obj.__dict__[name] = newval
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1449, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1449, __pyx_L125_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1450: except Exception as e:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 1450, __pyx_L127_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_8); /*try:*/ { /* … */ /*finally:*/ { __pyx_L138_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27) < 0)) __Pyx_ErrFetch(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_38 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ErrRestore(__pyx_t_29, __pyx_t_28, __pyx_t_27); __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_38; goto __pyx_L127_except_error; } } } goto __pyx_L127_except_error;
+1451: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_37); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1451, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0; __Pyx_Raise(__pyx_t_15, 0, 0, 0); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __PYX_ERR(0, 1451, __pyx_L138_error) }
+1452: f"Error parsing {f.origin}: {name}: {e}"
__pyx_t_15 = PyTuple_New(6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1452, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_2); __pyx_t_13 += 14; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_2); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing_2); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1452, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_37 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1452, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_37); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_37); __Pyx_GIVEREF(__pyx_t_37); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_37); __pyx_t_37 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__7); __pyx_t_37 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1452, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_37); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_37); __Pyx_GIVEREF(__pyx_t_37); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_37); __pyx_t_37 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_kp_u__7); __pyx_t_37 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1452, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_37); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_37); __Pyx_GIVEREF(__pyx_t_37); PyTuple_SET_ITEM(__pyx_t_15, 5, __pyx_t_37); __pyx_t_37 = 0; __pyx_t_37 = __Pyx_PyUnicode_Join(__pyx_t_15, 6, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1452, __pyx_L138_error) __Pyx_GOTREF(__pyx_t_37); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
1453: )
+1454: elif isinstance(value, list) and type_args:
__pyx_t_24 = PyList_Check(__pyx_v_value); if (__pyx_t_24) { } else { __pyx_t_2 = __pyx_t_24; goto __pyx_L144_bool_binop_done; } __pyx_t_24 = (__pyx_v_type_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_type_args) != 0); __pyx_t_2 = __pyx_t_24; __pyx_L144_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1455: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L146; }
+1456: newval = _handle_list_of_dataclasses(f, name, value, _type, obj)
__pyx_t_33.__pyx_n = 1; __pyx_t_33.parent = __pyx_v_obj; __pyx_t_9 = __pyx_f_9datamodel_10converters__handle_list_of_dataclasses(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_33); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1456, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
1457: else:
+1458: newval = _handle_list_of_dataclasses(f, name, value, _type, None)
/*else*/ { __pyx_t_33.__pyx_n = 1; __pyx_t_33.parent = Py_None; __pyx_t_9 = __pyx_f_9datamodel_10converters__handle_list_of_dataclasses(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_33); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1458, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0; } __pyx_L146:;
+1459: obj.__dict__[name] = newval
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1459, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_t_9, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1459, __pyx_L42_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1460: else:
+1461: newval = _parse_typing(
/*else*/ { /* … */ __pyx_t_35.__pyx_n = 3; __pyx_t_35.encoder = __pyx_v__encoder; __pyx_t_35.as_objects = __pyx_t_9; __pyx_t_35.parent = __pyx_v_obj; __pyx_t_8 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_35); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1461, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
1462: f,
1463: _type,
1464: value,
1465: _encoder,
+1466: as_objects,
__pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1466, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9);
1467: obj
1468: )
+1469: obj.__dict__[name] = newval
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1469, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1469, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_L50:;
1470: # then, call the validation process:
+1471: if (error := _validation_(name, newval, f, _type, meta, field_category, as_objects)):
if (!(likely(PyUnicode_CheckExact(__pyx_v_field_category))||((__pyx_v_field_category) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_field_category))) __PYX_ERR(0, 1471, __pyx_L42_error) __pyx_t_39.__pyx_n = 1; __pyx_t_39.as_objects = __pyx_v_as_objects; __pyx_t_8 = __pyx_f_9datamodel_10converters__validation_(__pyx_v_name, __pyx_v_newval, __pyx_v_f, __pyx_v__type, __pyx_v_meta, ((PyObject*)__pyx_v_field_category), &__pyx_t_39); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1471, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_error, __pyx_t_8); __Pyx_INCREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1471, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
+1472: errors[name] = error
if (unlikely((PyDict_SetItem(__pyx_v_errors, __pyx_v_name, __pyx_v_error) < 0))) __PYX_ERR(0, 1472, __pyx_L42_error)
+1473: except ValueError as ex:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 1473, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_ex, __pyx_t_9); /*try:*/ { /* … */ /*finally:*/ { __pyx_L153_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_40 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18); } __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21); __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_40; goto __pyx_L44_except_error; } __pyx_L150_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L148_except_continue; } } __pyx_L148_except_continue:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L48_try_continue; }
+1474: if meta.strict is True:
__pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_meta, __pyx_n_s_strict); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1474, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = (__pyx_t_15 == Py_True); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+1475: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_9, __pyx_t_4); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_4 = 0; __PYX_ERR(0, 1475, __pyx_L153_error)
1476: else:
+1477: errors.update(_build_error(name, f"Wrong Value for {f.name}: {f.type}", ex))
/*else*/ { __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Wrong_Value_for); __pyx_t_13 += 16; __Pyx_GIVEREF(__pyx_kp_u_Wrong_Value_for); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Wrong_Value_for); __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_name); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_37); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_t_37, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__7); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_37 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_37); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_37) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_37); __Pyx_GIVEREF(__pyx_t_37); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_37); __pyx_t_37 = 0; __pyx_t_37 = __Pyx_PyUnicode_Join(__pyx_t_15, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_37); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_37), __pyx_v_ex); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0; __pyx_t_37 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1477, __pyx_L153_error) __Pyx_GOTREF(__pyx_t_37); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
+1478: continue
goto __pyx_L150_continue; } }
+1479: except AttributeError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_8) < 0) __PYX_ERR(0, 1479, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8);
+1480: raise
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_9, __pyx_t_8); __pyx_t_4 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __PYX_ERR(0, 1480, __pyx_L44_except_error) }
+1481: except (TypeError, RuntimeError) as ex:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_RuntimeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 1481, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_ex, __pyx_t_9); /*try:*/ { /* … */ /*finally:*/ { __pyx_L167_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_41 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23); } __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20); __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_41; goto __pyx_L44_except_error; } __pyx_L164_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L162_except_continue; } } __pyx_L162_except_continue:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L48_try_continue; } goto __pyx_L44_except_error;
+1482: errors.update(_build_error(name, f"Wrong Type for {f.name}: {f.type}", ex))
__pyx_t_37 = PyTuple_New(4); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_37); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Wrong_Type_for); __pyx_t_13 += 15; __Pyx_GIVEREF(__pyx_kp_u_Wrong_Type_for); PyTuple_SET_ITEM(__pyx_t_37, 0, __pyx_kp_u_Wrong_Type_for); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_t_15, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_37, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_37, 2, __pyx_kp_u__7); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_37, 3, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_37, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0; __pyx_t_37 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_15), __pyx_v_ex); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_37); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_37); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1482, __pyx_L167_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+1483: continue
goto __pyx_L164_continue; }
1484: # Return Errors (if any)
+1485: return errors
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_errors); __pyx_r = __pyx_v_errors; goto __pyx_L0;
1486:
+1487: cdef object _validation_(
static PyObject *__pyx_f_9datamodel_10converters__validation_(PyObject *__pyx_v_name, PyObject *__pyx_v_value, PyObject *__pyx_v_f, PyObject *__pyx_v__type, PyObject *__pyx_v_meta, PyObject *__pyx_v_field_category, struct __pyx_opt_args_9datamodel_10converters__validation_ *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datamodel.converters._validation_", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_val_type); __Pyx_XDECREF(__pyx_v_error); __Pyx_XDECREF(__pyx_v_err); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__validation_ { int __pyx_n; int as_objects; };
1488: str name,
1489: object value,
1490: object f,
1491: object _type,
1492: object meta,
1493: str field_category,
+1494: bint as_objects = False
int __pyx_v_as_objects = ((int)0); PyObject *__pyx_v_val_type = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_err = 0; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_as_objects = __pyx_optional_args->as_objects; } }
1495: ):
1496: """
1497: _validation_.
1498: TODO: cover validations as length, not_null, required, max, min, etc
1499: """
+1500: cdef object val_type = type(value)
__Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_value)));
__pyx_v_val_type = ((PyObject *)Py_TYPE(__pyx_v_value));
+1501: cdef str error = None
__Pyx_INCREF(Py_None);
__pyx_v_error = ((PyObject*)Py_None);
1502: cdef dict err = {
+1503: "field": name,
__pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_field, __pyx_v_name) < 0) __PYX_ERR(0, 1503, __pyx_L1_error)
+1504: "value": value,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_value, __pyx_v_value) < 0) __PYX_ERR(0, 1503, __pyx_L1_error)
+1505: "error": None
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_error_3, Py_None) < 0) __PYX_ERR(0, 1503, __pyx_L1_error) __pyx_v_err = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1506: }
+1507: if val_type == type or value == _type or is_empty(value):
__pyx_t_1 = PyObject_RichCompare(__pyx_v_val_type, ((PyObject *)(&PyType_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1507, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_v__type, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1507, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1507, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = __pyx_f_9datamodel_10converters_is_empty(__pyx_v_value); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1507, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1508: try:
{ /*try:*/ { /* … */ } __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L11_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L0; }
+1509: _field_checks_(f, name, value, meta)
__pyx_t_1 = __pyx_f_9datamodel_10converters__field_checks_(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v_meta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1509, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1510: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L11_try_return;
+1511: except (ValueError, TypeError):
__pyx_t_7 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError); if (__pyx_t_7) { __Pyx_AddTraceback("datamodel.converters._validation_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 1511, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+1512: raise
__Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_8, __pyx_t_9); __pyx_t_1 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 1512, __pyx_L9_except_error) } goto __pyx_L9_except_error;
1513: # If the field has a cached validator, use it.
+1514: if f.validator is not None:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_validator); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = (__pyx_t_9 != Py_None); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ }
+1515: try:
{ /*try:*/ { /* … */ } __pyx_L16_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L18_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L1_error; __pyx_L20_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L0; }
+1516: error = f.validator(f, name, value, _type)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_validator); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1516, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_1, __pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_10, 4+__pyx_t_10); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1516, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if (!(likely(PyUnicode_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_9))) __PYX_ERR(0, 1516, __pyx_L16_error) __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+1517: if error:
__pyx_t_2 = (__pyx_v_error != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_error) != 0);
if (__pyx_t_2) {
/* … */
}
+1518: err["error"] = error
if (unlikely((PyDict_SetItem(__pyx_v_err, __pyx_n_u_error_3, __pyx_v_error) < 0))) __PYX_ERR(0, 1518, __pyx_L16_error)
+1519: return err
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_err); __pyx_r = __pyx_v_err; goto __pyx_L20_try_return;
+1520: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L20_try_return;
+1521: except ValueError:
__pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_7) { __Pyx_AddTraceback("datamodel.converters._validation_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_1) < 0) __PYX_ERR(0, 1521, __pyx_L18_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_1);
+1522: raise
__Pyx_GIVEREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_8, __pyx_t_1); __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_1 = 0; __PYX_ERR(0, 1522, __pyx_L18_except_error) } goto __pyx_L18_except_error;
1523: else:
1524: # capturing other errors from validator:
+1525: return _validation(f, name, value, _type, val_type, field_category, as_objects)
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_validation); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[8] = {__pyx_t_11, __pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, __pyx_v_val_type, __pyx_v_field_category, __pyx_t_9}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_10, 7+__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1526:
+1527: cdef object _field_checks_(object f, str name, object value, object meta):
static PyObject *__pyx_f_9datamodel_10converters__field_checks_(PyObject *__pyx_v_f, PyObject *__pyx_v_name, PyObject *__pyx_v_value, PyObject *__pyx_v_meta) { PyObject *__pyx_v_metadata = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("datamodel.converters._field_checks_", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1528: # Validate Primary Key
+1529: cdef object metadata = f.metadata
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_metadata); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_metadata = __pyx_t_1; __pyx_t_1 = 0;
+1530: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); __pyx_L8_try_end:; }
+1531: if metadata.get('primary', False) is True:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_metadata, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1531, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__pyx_t_5 == Py_True); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { /* … */ } /* … */ __pyx_tuple__14 = PyTuple_Pack(2, __pyx_n_u_primary, Py_False); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14);
+1532: if 'db_default' in metadata:
__pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_db_default, __pyx_v_metadata, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1532, __pyx_L3_error) if (likely(__pyx_t_6)) { goto __pyx_L10; }
1533: pass
1534: else:
+1535: raise ValueError(
/*else*/ { /* … */ __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1535, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 1535, __pyx_L3_error) } __pyx_L10:;
+1536: f":: Missing Primary Key *{name}*"
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1536, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Missing_Primary_Key); __pyx_t_7 += 24; __Pyx_GIVEREF(__pyx_kp_u_Missing_Primary_Key); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Missing_Primary_Key); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1536, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u__13); __pyx_t_7 += 1; __Pyx_GIVEREF(__pyx_kp_u__13); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u__13); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1536, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1537: )
+1538: except KeyError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_9) { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error;
1539: pass
1540: # Validate Required
+1541: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L16_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L1_error; __pyx_L15_try_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L0; __pyx_L14_except_return:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_3, __pyx_t_2); goto __pyx_L0; __pyx_L16_try_end:; }
+1542: if metadata.get('required', False) is True and meta.strict is True:
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_metadata, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1542, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1542, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = (__pyx_t_1 == Py_True); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_10) { } else { __pyx_t_6 = __pyx_t_10; goto __pyx_L18_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_meta, __pyx_n_s_strict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1542, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = (__pyx_t_1 == Py_True); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __pyx_t_10; __pyx_L18_bool_binop_done:; if (__pyx_t_6) { /* … */ } /* … */ __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_u_required, Py_False); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1542, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15);
+1543: if 'db_default' in metadata:
__pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_db_default, __pyx_v_metadata, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1543, __pyx_L11_error) if (__pyx_t_6) { /* … */ }
+1544: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L15_try_return;
+1545: if value is not None:
__pyx_t_6 = (__pyx_v_value != Py_None); if (__pyx_t_6) { /* … */ }
+1546: return # If default value is set, no need to raise an error
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L15_try_return;
+1547: raise ValueError(
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1547, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1547, __pyx_L11_error)
+1548: f":: Missing Required Field *{name}*"
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1548, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Missing_Required_Field); __pyx_t_7 += 27; __Pyx_GIVEREF(__pyx_kp_u_Missing_Required_Field); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Missing_Required_Field); __pyx_t_5 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1548, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__13); __pyx_t_7 += 1; __Pyx_GIVEREF(__pyx_kp_u__13); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__13); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1548, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1549: )
+1550: except ValueError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._field_checks_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_11) < 0) __PYX_ERR(0, 1550, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_11);
+1551: raise
__Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_11); __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_11 = 0; __PYX_ERR(0, 1551, __pyx_L13_except_error) }
+1552: except KeyError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._field_checks_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 1552, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1);
+1553: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L14_except_return; } goto __pyx_L13_except_error;
1554: # Nullable:
+1555: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L31_try_end; __pyx_L26_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L28_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L29_except_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; __pyx_L31_try_end:; }
+1556: if metadata.get('nullable', True) is False and meta.strict is True:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_metadata, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1556, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1556, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = (__pyx_t_5 == Py_False); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_10) { } else { __pyx_t_6 = __pyx_t_10; goto __pyx_L33_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_meta, __pyx_n_s_strict); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1556, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = (__pyx_t_5 == Py_True); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __pyx_t_10; __pyx_L33_bool_binop_done:; if (unlikely(__pyx_t_6)) { /* … */ } /* … */ __pyx_tuple__16 = PyTuple_Pack(2, __pyx_n_u_nullable, Py_True); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 1556, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16);
+1557: raise ValueError(
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1557, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 1557, __pyx_L26_error)
+1558: f":: *{name}* Cannot be null."
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1558, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u__17); __pyx_t_7 += 4; __Pyx_GIVEREF(__pyx_kp_u__17); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u__17); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1558, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_Cannot_be_null); __pyx_t_7 += 17; __Pyx_GIVEREF(__pyx_kp_u_Cannot_be_null); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_Cannot_be_null); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1558, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1559: )
+1560: except ValueError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._field_checks_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_1, &__pyx_t_11) < 0) __PYX_ERR(0, 1560, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_11);
+1561: raise
__Pyx_GIVEREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_1, __pyx_t_11); __pyx_t_5 = 0; __pyx_t_1 = 0; __pyx_t_11 = 0; __PYX_ERR(0, 1561, __pyx_L28_except_error) }
+1562: except KeyError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters._field_checks_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(0, 1562, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5);
+1563: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L29_except_return; } goto __pyx_L28_except_error;
+1564: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1565:
1566:
+1567: cpdef parse_type(object field, object T, object data, object encoder = None):
static PyObject *__pyx_pw_9datamodel_10converters_37parse_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_9datamodel_10converters_parse_type(PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_data, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_9datamodel_10converters_parse_type *__pyx_optional_args) { PyObject *__pyx_v_encoder = ((PyObject *)Py_None); PyObject *__pyx_v_origin = 0; PyObject *__pyx_v_args = 0; PyObject *__pyx_v_type_name = 0; PyObject *__pyx_v_type_args = 0; CYTHON_UNUSED PyObject *__pyx_v_typeinfo = 0; PyObject *__pyx_v_arg_type = NULL; PyObject *__pyx_v_t = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_v_converted_item = NULL; PyObject *__pyx_v_non_none_arg = NULL; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_v_fn = NULL; CYTHON_UNUSED PyObject *__pyx_v_ex = NULL; PyObject *__pyx_v_exc = NULL; PyObject *__pyx_8genexpr6__pyx_v_k = NULL; PyObject *__pyx_8genexpr6__pyx_v_v = NULL; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_encoder = __pyx_optional_args->encoder; } } __Pyx_INCREF(__pyx_v_T); __Pyx_INCREF(__pyx_v_data); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_27); __Pyx_AddTraceback("datamodel.converters.parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_origin); __Pyx_XDECREF(__pyx_v_args); __Pyx_XDECREF(__pyx_v_type_name); __Pyx_XDECREF(__pyx_v_type_args); __Pyx_XDECREF(__pyx_v_typeinfo); __Pyx_XDECREF(__pyx_v_arg_type); __Pyx_XDECREF(__pyx_v_t); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_converted_item); __Pyx_XDECREF(__pyx_v_non_none_arg); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XDECREF(__pyx_v_fn); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XDECREF(__pyx_v_exc); __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_v); __Pyx_XDECREF(__pyx_v_T); __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_37parse_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_9datamodel_10converters_36parse_type, "parse_type(field, T, data, encoder=None)"); static PyMethodDef __pyx_mdef_9datamodel_10converters_37parse_type = {"parse_type", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_37parse_type, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9datamodel_10converters_36parse_type}; static PyObject *__pyx_pw_9datamodel_10converters_37parse_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_field = 0; PyObject *__pyx_v_T = 0; PyObject *__pyx_v_data = 0; PyObject *__pyx_v_encoder = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("parse_type (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_field,&__pyx_n_s_T,&__pyx_n_s_data,&__pyx_n_s_encoder,0}; PyObject* values[4] = {0,0,0,0}; values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_field)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1567, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_T)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1567, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, 1); __PYX_ERR(0, 1567, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1567, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, 2); __PYX_ERR(0, 1567, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoder); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1567, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "parse_type") < 0)) __PYX_ERR(0, 1567, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_field = values[0]; __pyx_v_T = values[1]; __pyx_v_data = values[2]; __pyx_v_encoder = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, __pyx_nargs); __PYX_ERR(0, 1567, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("datamodel.converters.parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_9datamodel_10converters_36parse_type(__pyx_self, __pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_9datamodel_10converters_36parse_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_field, PyObject *__pyx_v_T, PyObject *__pyx_v_data, PyObject *__pyx_v_encoder) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.encoder = __pyx_v_encoder; __pyx_t_1 = __pyx_f_9datamodel_10converters_parse_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("datamodel.converters.parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__48 = PyTuple_Pack(4, __pyx_n_s_field, __pyx_n_s_T, __pyx_n_s_data, __pyx_n_s_encoder); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__48); __Pyx_GIVEREF(__pyx_tuple__48); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_37parse_type, 0, __pyx_n_s_parse_type, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__45); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_type, __pyx_t_2) < 0) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ struct __pyx_opt_args_9datamodel_10converters_parse_type { int __pyx_n; PyObject *encoder; };
+1568: cdef object origin = get_origin(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_T}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+1569: cdef tuple args = None
__Pyx_INCREF(Py_None);
__pyx_v_args = ((PyObject*)Py_None);
+1570: cdef str type_name = getattr(T, '_name', None)
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_T, __pyx_n_u_name_3, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1570, __pyx_L1_error) __pyx_v_type_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1571: cdef object type_args = getattr(T, '__args__', None)
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_T, __pyx_n_u_args, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_type_args = __pyx_t_1; __pyx_t_1 = 0;
+1572: cdef dict typeinfo = getattr(T, '_typeinfo_', None)
__pyx_t_1 = __Pyx_GetAttr3(__pyx_v_T, __pyx_n_u_typeinfo_2, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_1))) __PYX_ERR(0, 1572, __pyx_L1_error) __pyx_v_typeinfo = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1573:
+1574: if isinstance(T, NewType):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_NewType); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_IsInstance(__pyx_v_T, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1574, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
1575: # change type if is a NewType object.
+1576: T = T.__supertype__
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_T, __pyx_n_s_supertype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_T, __pyx_t_1); __pyx_t_1 = 0;
1577:
1578: # Check if the data is already of the correct type
+1579: if isinstance(data, T):
__pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_v_T); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1579, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+1580: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1581:
+1582: if field._type_category == 'typing':
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_type_category); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1582, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1582, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ goto __pyx_L5; }
+1583: args = type_args or ()
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_type_args); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1583, __pyx_L1_error) if (!__pyx_t_5) { } else { if (!(likely(PyTuple_CheckExact(__pyx_v_type_args))||((__pyx_v_type_args) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_v_type_args))) __PYX_ERR(0, 1583, __pyx_L1_error) __Pyx_INCREF(__pyx_v_type_args); __pyx_t_1 = __pyx_v_type_args; goto __pyx_L6_bool_binop_done; } __Pyx_INCREF(__pyx_empty_tuple); __pyx_t_1 = __pyx_empty_tuple; __pyx_L6_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+1584: if type_name == 'Dict' and isinstance(data, dict):
__pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_type_name, __pyx_n_u_Dict, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1584, __pyx_L1_error) if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L9_bool_binop_done; } __pyx_t_6 = PyDict_Check(__pyx_v_data); __pyx_t_5 = __pyx_t_6; __pyx_L9_bool_binop_done:; if (__pyx_t_5) { /* … */ goto __pyx_L8; }
+1585: if args:
__pyx_t_5 = (__pyx_v_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_args) != 0);
if (__pyx_t_5) {
/* … */
}
+1586: return {k: parse_type(field, type_args[1], v) for k, v in data.items()}
__Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1586, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; if (unlikely(__pyx_v_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1586, __pyx_L14_error) } __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_data, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1586, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_8, &__pyx_t_7, &__pyx_t_3, &__pyx_t_10, NULL, __pyx_t_9); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 1586, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_k, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_v, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_type_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1586, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __pyx_f_9datamodel_10converters_parse_type(__pyx_v_field, __pyx_t_10, __pyx_8genexpr6__pyx_v_v, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1586, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr6__pyx_v_k, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 1586, __pyx_L14_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_k); __pyx_8genexpr6__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_v); __pyx_8genexpr6__pyx_v_v = 0; goto __pyx_L17_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_k); __pyx_8genexpr6__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_v); __pyx_8genexpr6__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L17_exit_scope:; } /* exit inner scope */ __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1587:
+1588: elif type_name == 'List':
__pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_type_name, __pyx_n_u_List, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1588, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+1589: if not isinstance(data, (list, tuple)):
__pyx_t_6 = PyList_Check(__pyx_v_data); if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L19_bool_binop_done; } __pyx_t_6 = PyTuple_Check(__pyx_v_data); __pyx_t_5 = __pyx_t_6; __pyx_L19_bool_binop_done:; __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ }
+1590: data = [data]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_data)) __PYX_ERR(0, 1590, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+1591: arg_type = args[0]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1591, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+1592: if arg_type.__module__ == 'typing': # nested typing
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_module); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1592, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+1593: try:
{ /*try:*/ { /* … */ } __pyx_L22_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L24_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L1_error; __pyx_L26_try_return:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L0; __pyx_L25_except_return:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L0; }
+1594: t = arg_type.__args__[0]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1594, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_t = __pyx_t_2; __pyx_t_2 = 0;
+1595: if is_dc(t):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1595, __pyx_L22_error) if (__pyx_t_6) { /* … */ }
+1596: result = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1596, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_result = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+1597: for x in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_2 = __pyx_v_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0; __pyx_t_15 = NULL; } else { __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1597, __pyx_L22_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1597, __pyx_L22_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1597, __pyx_L22_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1597, __pyx_L22_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1597, __pyx_L22_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1597, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_15(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1597, __pyx_L22_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1598: if isinstance(x, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_x);
if (__pyx_t_6) {
/* … */
goto __pyx_L31;
}
+1599: result.append(t(**x))
if (unlikely(__pyx_v_x == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1599, __pyx_L22_error) } if (likely(PyDict_CheckExact(__pyx_v_x))) { __pyx_t_1 = PyDict_Copy(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1599, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1599, __pyx_L22_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1600: elif isinstance(x, (list, tuple)):
__pyx_t_5 = PyList_Check(__pyx_v_x); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L32_bool_binop_done; } __pyx_t_5 = PyTuple_Check(__pyx_v_x); __pyx_t_6 = __pyx_t_5; __pyx_L32_bool_binop_done:; if (__pyx_t_6) { /* … */ goto __pyx_L31; }
+1601: result.append(t(*x))
__pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1601, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1601, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1601, __pyx_L22_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1602: else:
+1603: result.append(t())
/*else*/ { __Pyx_INCREF(__pyx_v_t); __pyx_t_3 = __pyx_v_t; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1603, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1603, __pyx_L22_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L31:;
+1604: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L26_try_return;
1605: else:
+1606: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L26_try_return; }
+1607: except AttributeError:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 1607, __pyx_L24_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3);
+1608: return data # data -as is-
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L25_except_return; } goto __pyx_L24_except_error;
+1609: elif is_dc(arg_type):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_arg_type); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1609, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+1610: if isinstance(data, list):
__pyx_t_6 = PyList_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
}
+1611: result = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1612: for d in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_3 = __pyx_v_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_15 = NULL; } else { __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1612, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1612, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1612, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1612, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1612, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_15(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1612, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1613: # is already a dataclass:
+1614: if is_dc(d):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_d); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1614, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L40; }
+1615: result.append(d)
__pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_d); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1615, __pyx_L1_error)
+1616: elif isinstance(d, list):
__pyx_t_6 = PyList_Check(__pyx_v_d);
if (__pyx_t_6) {
/* … */
goto __pyx_L40;
}
+1617: result.append(arg_type(*d))
__pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_arg_type, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1618: elif isinstance(d, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_d);
if (__pyx_t_6) {
/* … */
goto __pyx_L40;
}
+1619: result.append(arg_type(**d))
if (unlikely(__pyx_v_d == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1619, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_d))) { __pyx_t_2 = PyDict_Copy(__pyx_v_d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { __pyx_t_2 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_arg_type, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1620: else:
+1621: result.append(arg_type(d))
/*else*/ { __Pyx_INCREF(__pyx_v_arg_type); __pyx_t_2 = __pyx_v_arg_type; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_d}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1621, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L40:;
+1622: return result
__Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_result)) { __Pyx_RaiseUnboundLocalError("result"); __PYX_ERR(0, 1622, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1623: else:
+1624: result = []
/*else*/ { __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1625: if is_iterable(data):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_data}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ }
+1626: for item in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_3 = __pyx_v_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_15 = NULL; } else { __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1626, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1626, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1626, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1626, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1626, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_15(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1626, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1627: # escalar value:
+1628: converted_item = parse_type(field, arg_type, item, encoder)
__pyx_t_17.__pyx_n = 1; __pyx_t_17.encoder = __pyx_v_encoder; __pyx_t_1 = __pyx_f_9datamodel_10converters_parse_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_item, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_converted_item, __pyx_t_1); __pyx_t_1 = 0;
+1629: result.append(converted_item)
__pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_converted_item); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1629, __pyx_L1_error)
+1630: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+1631: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0; }
+1632: elif type_name is None or type_name in ('Optional', 'Union'):
__pyx_t_5 = (__pyx_v_type_name == ((PyObject*)Py_None)); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L46_bool_binop_done; } __Pyx_INCREF(__pyx_v_type_name); __pyx_t_18 = __pyx_v_type_name; __pyx_t_19 = (__Pyx_PyUnicode_Equals(__pyx_t_18, __pyx_n_u_Optional, Py_EQ)); if (unlikely((__pyx_t_19 < 0))) __PYX_ERR(0, 1632, __pyx_L1_error) if (!__pyx_t_19) { } else { __pyx_t_5 = __pyx_t_19; goto __pyx_L48_bool_binop_done; } __pyx_t_19 = (__Pyx_PyUnicode_Equals(__pyx_t_18, __pyx_n_u_Union, Py_EQ)); if (unlikely((__pyx_t_19 < 0))) __PYX_ERR(0, 1632, __pyx_L1_error) __pyx_t_5 = __pyx_t_19; __pyx_L48_bool_binop_done:; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_19 = __pyx_t_5; __pyx_t_6 = __pyx_t_19; __pyx_L46_bool_binop_done:; if (__pyx_t_6) { /* … */ } __pyx_L8:;
+1633: args = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_T}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_3))) __PYX_ERR(0, 1633, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
1634: # Handling Optional types
+1635: if origin == Union and type(None) in args:
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Union); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1635, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_RichCompare(__pyx_v_origin, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1635, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_19 < 0))) __PYX_ERR(0, 1635, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_19) { } else { __pyx_t_6 = __pyx_t_19; goto __pyx_L51_bool_binop_done; } __pyx_t_19 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_args, Py_EQ)); if (unlikely((__pyx_t_19 < 0))) __PYX_ERR(0, 1635, __pyx_L1_error) __pyx_t_6 = __pyx_t_19; __pyx_L51_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+1636: if data is None:
__pyx_t_6 = (__pyx_v_data == Py_None); if (__pyx_t_6) { /* … */ }
+1637: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1638: # Determine the non-None type.
+1639: non_none_arg = args[0] if args[1] is type(None) else args[1]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1639, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = (__pyx_t_3 == ((PyObject *)Py_TYPE(Py_None))); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1639, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1639, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_non_none_arg = __pyx_t_1; __pyx_t_1 = 0;
+1640: if non_none_arg == list:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_non_none_arg, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1640, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1640, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+1641: field.args = args
if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_v_args) < 0) __PYX_ERR(0, 1641, __pyx_L1_error)
+1642: field.origin = get_origin(non_none_arg)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_non_none_arg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_origin, __pyx_t_1) < 0) __PYX_ERR(0, 1642, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1643: if isinstance(data, (list, str, dict)):
__pyx_t_19 = PyList_Check(__pyx_v_data); if (!__pyx_t_19) { } else { __pyx_t_6 = __pyx_t_19; goto __pyx_L56_bool_binop_done; } __pyx_t_19 = PyUnicode_Check(__pyx_v_data); if (!__pyx_t_19) { } else { __pyx_t_6 = __pyx_t_19; goto __pyx_L56_bool_binop_done; } __pyx_t_19 = PyDict_Check(__pyx_v_data); __pyx_t_6 = __pyx_t_19; __pyx_L56_bool_binop_done:; if (likely(__pyx_t_6)) { /* … */ }
+1644: return _parse_builtin_type(field, non_none_arg, data, encoder)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_non_none_arg, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1645: else:
+1646: raise ValueError(f"Unsupported type for List in Optional: {type(data)}")
/*else*/ { __pyx_t_1 = __Pyx_PyObject_FormatSimple(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Unsupported_type_for_List_in_Opt, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1646, __pyx_L1_error) }
1647: # If the non-None type is exactly dict, return the dict as is.
+1648: if non_none_arg is dict:
__pyx_t_6 = (__pyx_v_non_none_arg == ((PyObject *)(&PyDict_Type))); if (__pyx_t_6) { /* … */ }
+1649: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1650: # Otherwise, recursively parse using the non-None type.
+1651: field.args = args
if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_v_args) < 0) __PYX_ERR(0, 1651, __pyx_L1_error)
+1652: field.origin = get_origin(non_none_arg)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_non_none_arg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_origin, __pyx_t_1) < 0) __PYX_ERR(0, 1652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1653: return parse_type(field, non_none_arg, data, encoder)
__Pyx_XDECREF(__pyx_r); __pyx_t_17.__pyx_n = 1; __pyx_t_17.encoder = __pyx_v_encoder; __pyx_t_1 = __pyx_f_9datamodel_10converters_parse_type(__pyx_v_field, __pyx_v_non_none_arg, __pyx_v_data, 0, &__pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1654: try:
{ /*try:*/ { /* … */ } __pyx_L60_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L62_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); goto __pyx_L1_error; __pyx_L64_try_return:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); goto __pyx_L0; __pyx_L61_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); }
+1655: t = args[0]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1655, __pyx_L60_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1655, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_t = __pyx_t_1; __pyx_t_1 = 0;
+1656: if is_dc(t):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1656, __pyx_L60_error) if (__pyx_t_6) { /* … */ goto __pyx_L66; }
+1657: if isinstance(data, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
goto __pyx_L67;
}
+1658: data = t(**data)
if (unlikely(__pyx_v_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1658, __pyx_L60_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_1 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1658, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1658, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1658, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
+1659: elif isinstance(data, (list, tuple)):
__pyx_t_19 = PyList_Check(__pyx_v_data); if (!__pyx_t_19) { } else { __pyx_t_6 = __pyx_t_19; goto __pyx_L68_bool_binop_done; } __pyx_t_19 = PyTuple_Check(__pyx_v_data); __pyx_t_6 = __pyx_t_19; __pyx_L68_bool_binop_done:; if (__pyx_t_6) { /* … */ goto __pyx_L67; }
+1660: data = t(*data)
__pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1660, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1660, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
1661: else:
1662: ## is already a dataclass, returning
+1663: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return; } __pyx_L67:;
+1664: elif callable(t):
__pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1664, __pyx_L60_error) if (__pyx_t_6) { /* … */ } __pyx_L66:;
+1665: if t.__module__ == 'typing': # nested typing
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_module); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1665, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1665, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
1666: # there is also a nested typing:
+1667: if t._name == 'List' and isinstance(data, list):
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_name_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1667, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_19 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_List, Py_EQ)); if (unlikely((__pyx_t_19 < 0))) __PYX_ERR(0, 1667, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_19) { } else { __pyx_t_6 = __pyx_t_19; goto __pyx_L72_bool_binop_done; } __pyx_t_19 = PyList_Check(__pyx_v_data); __pyx_t_6 = __pyx_t_19; __pyx_L72_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+1668: arg = t.__args__[0]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1668, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1668, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_arg = __pyx_t_3; __pyx_t_3 = 0;
+1669: if is_dc(arg):
__pyx_t_6 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_arg); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1669, __pyx_L60_error) if (__pyx_t_6) { /* … */ }
+1670: result = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1670, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1671: for x in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_3 = __pyx_v_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_15 = NULL; } else { __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1671, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1671, __pyx_L60_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1671, __pyx_L60_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1671, __pyx_L60_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1671, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1671, __pyx_L60_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1671, __pyx_L60_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1671, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_15(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1671, __pyx_L60_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1672: if isinstance(x, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_x);
if (__pyx_t_6) {
/* … */
goto __pyx_L77;
}
+1673: result.append(arg(**x))
if (unlikely(__pyx_v_x == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 1673, __pyx_L60_error) } if (likely(PyDict_CheckExact(__pyx_v_x))) { __pyx_t_1 = PyDict_Copy(__pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1673, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1673, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_arg, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1673, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1673, __pyx_L60_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1674: else:
+1675: result.append(arg(*x))
/*else*/ { __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1675, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_arg, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1675, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1675, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L77:;
+1676: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L64_try_return;
+1677: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return;
1678: else:
+1679: try:
/*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; goto __pyx_L84_try_end; __pyx_L79_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L81_except_error:; __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); goto __pyx_L60_error; __pyx_L83_try_return:; __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); goto __pyx_L64_try_return; __pyx_L80_exception_handled:; __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); __pyx_L84_try_end:; } }
+1680: if t == str:
__pyx_t_3 = PyObject_RichCompare(__pyx_v_t, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1680, __pyx_L79_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1680, __pyx_L79_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ }
+1681: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L83_try_return;
+1682: fn = encoders[t]
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_encoders); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1682, __pyx_L79_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1682, __pyx_L79_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_fn = __pyx_t_1; __pyx_t_1 = 0;
+1683: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0; goto __pyx_L91_try_end; __pyx_L86_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L88_except_error:; __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25); goto __pyx_L79_error; __pyx_L87_exception_handled:; __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25); __pyx_L91_try_end:; }
+1684: if data is not None:
__pyx_t_6 = (__pyx_v_data != Py_None); if (__pyx_t_6) { /* … */ }
+1685: data = fn(data)
__Pyx_INCREF(__pyx_v_fn); __pyx_t_3 = __pyx_v_fn; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1685, __pyx_L86_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+1686: except TypeError as ex:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 1686, __pyx_L88_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_v_ex = __pyx_t_3; /*try:*/ { } /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L99; } __pyx_L99:; } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L87_exception_handled; }
1687: pass
+1688: except (ValueError, RuntimeError) as exc:
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_RuntimeError); if (__pyx_t_9) { __Pyx_AddTraceback("datamodel.converters.parse_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 1688, __pyx_L88_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_v_exc = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L105_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_32, &__pyx_t_33, &__pyx_t_34); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31) < 0)) __Pyx_ErrFetch(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_30); __Pyx_XGOTREF(__pyx_t_31); __Pyx_XGOTREF(__pyx_t_32); __Pyx_XGOTREF(__pyx_t_33); __Pyx_XGOTREF(__pyx_t_34); __pyx_t_9 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_28 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_32); __Pyx_XGIVEREF(__pyx_t_33); __Pyx_XGIVEREF(__pyx_t_34); __Pyx_ExceptionReset(__pyx_t_32, __pyx_t_33, __pyx_t_34); } __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_30); __Pyx_XGIVEREF(__pyx_t_31); __Pyx_ErrRestore(__pyx_t_29, __pyx_t_30, __pyx_t_31); __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_28; goto __pyx_L88_except_error; } } } goto __pyx_L88_except_error;
+1689: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_27); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1689, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 1689, __pyx_L105_error) }
+1690: f"Model: Error parsing {T}, {exc}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1690, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = 0; __pyx_t_26 = 127; __Pyx_INCREF(__pyx_kp_u_Model_Error_parsing); __pyx_t_8 += 21; __Pyx_GIVEREF(__pyx_kp_u_Model_Error_parsing); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Model_Error_parsing); __pyx_t_27 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 1690, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_26 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_27) > __pyx_t_26) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_27) : __pyx_t_26; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_27); __Pyx_GIVEREF(__pyx_t_27); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_27); __pyx_t_27 = 0; __Pyx_INCREF(__pyx_kp_u__10); __pyx_t_8 += 2; __Pyx_GIVEREF(__pyx_kp_u__10); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u__10); __pyx_t_27 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 1690, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_27); __pyx_t_26 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_27) > __pyx_t_26) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_27) : __pyx_t_26; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_27); __Pyx_GIVEREF(__pyx_t_27); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_27); __pyx_t_27 = 0; __pyx_t_27 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_8, __pyx_t_26); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 1690, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1691: )
+1692: except KeyError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_11) { __Pyx_ErrRestore(0,0,0); goto __pyx_L80_exception_handled; } goto __pyx_L81_except_error;
1693: pass
+1694: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return;
+1695: except KeyError:
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_11) { __Pyx_ErrRestore(0,0,0); goto __pyx_L61_exception_handled; } goto __pyx_L62_except_error;
1696: pass
+1697: elif origin is dict and isinstance(data, dict):
__pyx_t_19 = (__pyx_v_origin == ((PyObject *)(&PyDict_Type)));
if (__pyx_t_19) {
} else {
__pyx_t_6 = __pyx_t_19;
goto __pyx_L111_bool_binop_done;
}
__pyx_t_19 = PyDict_Check(__pyx_v_data);
__pyx_t_6 = __pyx_t_19;
__pyx_L111_bool_binop_done:;
if (__pyx_t_6) {
/* … */
}
+1698: return _parse_dict_type(field, T, data, encoder, args)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1699: elif origin is list:
__pyx_t_6 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_6) { /* … */ }
+1700: return _parse_list_type(field, T, data, encoder, args)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_args, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1701: elif origin is not None:
__pyx_t_6 = (__pyx_v_origin != Py_None); if (__pyx_t_6) { /* … */ }
1702: # Other typing constructs can be handled here
+1703: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1704: else:
+1705: return _parse_builtin_type(field, T, data, encoder)
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } __pyx_L5:;