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_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, Literal, Any
__pyx_t_2 = PyList_New(8); 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_INCREF(__pyx_n_s_Literal); __Pyx_GIVEREF(__pyx_n_s_Literal); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_Literal)) __PYX_ERR(0, 5, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Any); __Pyx_GIVEREF(__pyx_n_s_Any); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_Any)) __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_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Literal); 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_Literal, __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_Any); 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_Any, __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 pathlib import PurePath, Path
__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_PurePath); __Pyx_GIVEREF(__pyx_n_s_PurePath); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_PurePath)) __PYX_ERR(0, 11, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Path); __Pyx_GIVEREF(__pyx_n_s_Path); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_Path)) __PYX_ERR(0, 11, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pathlib, __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_PurePath); 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_PurePath, __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_Path); 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_Path, __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 decimal import Decimal, InvalidOperation
__pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Decimal); __Pyx_GIVEREF(__pyx_n_s_Decimal); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Decimal)) __PYX_ERR(0, 12, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_InvalidOperation); __Pyx_GIVEREF(__pyx_n_s_InvalidOperation); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_InvalidOperation)) __PYX_ERR(0, 12, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_decimal, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 12, __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_Decimal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Decimal, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_InvalidOperation); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidOperation, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0013: from libc.stdio cimport sprintf, snprintf
0014: from libc.stdlib cimport malloc, free
0015: from cpython.mem cimport PyMem_Malloc, PyMem_Free
0016: cimport cython
0017: from cpython cimport datetime
0018: from cpython.object cimport (
0019: PyObject_IsInstance,
0020: PyObject_IsSubclass,
0021: PyObject_HasAttr,
0022: PyObject_GetAttr,
0023: PyObject_SetAttr,
0024: PyObject_Call,
0025: PyObject_TypeCheck,
0026: PyCallable_Check
0027: )
0028: from cpython.ref cimport PyObject
+0029: from uuid import UUID
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_UUID); __Pyx_GIVEREF(__pyx_n_s_UUID); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_UUID)) __PYX_ERR(0, 29, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_uuid, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __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_UUID); 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_UUID, __pyx_t_3) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0030: import asyncpg.pgproto.pgproto as pgproto
__pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_asyncpg_pgproto_pgproto, __pyx_tuple__19); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pgproto, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19);
+0031: from .functions import is_iterable, is_primitive
__pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_is_iterable); __Pyx_GIVEREF(__pyx_n_s_is_iterable); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_is_iterable)) __PYX_ERR(0, 31, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_is_primitive); __Pyx_GIVEREF(__pyx_n_s_is_primitive); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_is_primitive)) __PYX_ERR(0, 31, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_functions, __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_is_iterable); 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_is_iterable, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_is_primitive); 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_is_primitive, __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 .validation import _validation
__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_validation); __Pyx_GIVEREF(__pyx_n_s_validation); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_validation)) __PYX_ERR(0, 32, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_validation_2, __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_validation); 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_validation, __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: from .validation cimport _validate_constraints
+0034: from .fields import Field
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_Field); __Pyx_GIVEREF(__pyx_n_s_Field); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Field)) __PYX_ERR(0, 34, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_fields, __pyx_t_2, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __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_Field); 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_Field, __pyx_t_2) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0035: # New converter:
+0036: import datamodel.rs_parsers as rc
__pyx_t_3 = __Pyx_ImportDottedModule(__pyx_n_s_datamodel_rs_parsers, __pyx_tuple__20); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_rc, __pyx_t_3) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__20 = PyTuple_Pack(2, __pyx_n_s_datamodel, __pyx_n_s_rs_parsers); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20);
0037:
+0038: cdef struct ColumnDef:
struct __pyx_t_9datamodel_10converters_ColumnDef { char const *name; PyObject *field; };
0039: const char* name
0040: PyObject* field
0041:
+0042: 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; }
0043: """Returns True if obj is a dataclass or an instance of a
0044: dataclass."""
+0045: 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, 45, __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, 45, __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, 45, __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;
+0046: return PyObject_HasAttr(cls, '__dataclass_fields__')
__pyx_r = PyObject_HasAttr(__pyx_v_cls, __pyx_n_u_dataclass_fields);
goto __pyx_L0;
0047:
+0048: cdef bint is_empty(object value):
static int __pyx_f_9datamodel_10converters_is_empty(PyObject *__pyx_v_value) { 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; }
0049: """
0050: Determines if a value should be considered empty.
0051:
0052: Enhanced to handle different container types properly, including:
0053: - None
0054: - Empty strings
0055: - Empty lists, tuples, sets
0056: - _MISSING_TYPE (used in default value checks)
0057:
0058: Returns True if the value is considered empty, False otherwise.
0059: """
0060: # None is always empty
+0061: if value is None:
__pyx_t_1 = (__pyx_v_value == Py_None); if (__pyx_t_1) { /* … */ }
+0062: return True
__pyx_r = 1; goto __pyx_L0;
0063:
0064: # Field default missing markers
+0065: 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, 65, __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, 65, __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, 65, __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, 65, __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, 65, __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) { /* … */ }
+0066: return True
__pyx_r = 1; goto __pyx_L0;
0067:
0068: # Empty strings are considered empty
+0069: if 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, 69, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L8_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, 69, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L8_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0070: return True
__pyx_r = 1; goto __pyx_L0;
0071:
+0072: if 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, 72, __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, 72, __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, 72, __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, 72, __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) { /* … */ }
+0073: return False
__pyx_r = 0; goto __pyx_L0;
0074:
+0075: if PyObject_IsInstance(value, (tuple, list, set)) and len(value) == 0:
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF((PyObject *)(&PyTuple_Type)); __Pyx_GIVEREF((PyObject *)(&PyTuple_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyTuple_Type)))) __PYX_ERR(0, 75, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyList_Type)); __Pyx_GIVEREF((PyObject *)(&PyList_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyList_Type)))) __PYX_ERR(0, 75, __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, 75, __pyx_L1_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 75, __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_L14_bool_binop_done; } __pyx_t_5 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 75, __pyx_L1_error) __pyx_t_3 = (__pyx_t_5 == 0); __pyx_t_1 = __pyx_t_3; __pyx_L14_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0076: return True
__pyx_r = 1; goto __pyx_L0;
0077:
0078: # Special case for containers: empty containers are NOT considered empty
0079: # because they are valid initialized values
+0080: if PyObject_IsInstance(value, (list, tuple, set)):
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __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, 80, __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, 80, __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, 80, __pyx_L1_error); __pyx_t_1 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0081: return False # Return False even for empty containers
__pyx_r = 0; goto __pyx_L0;
0082:
0083: # Numeric values of 0 are not considered empty
+0084: if PyObject_IsInstance(value, (int, float)) and value == 0:
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 84, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 84, __pyx_L1_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 84, __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_L18_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, 84, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L18_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0085: return False
__pyx_r = 0; goto __pyx_L0;
0086:
0087: # Objects with explicit "empty" attribute
+0088: if 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_L21_bool_binop_done; } __pyx_t_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_u_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __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, 88, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L21_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0089: return False
__pyx_r = 0; goto __pyx_L0;
0090:
0091: # Fallback to Python's truthiness
+0092: if not value:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 92, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { /* … */ }
+0093: return True
__pyx_r = 1; goto __pyx_L0;
0094:
0095: # Default: not empty
+0096: return False
__pyx_r = 0; goto __pyx_L0;
0097:
+0098: 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, 98, __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, 98, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("has_attribute", 1, 2, 2, 1); __PYX_ERR(0, 98, __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, 98, __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, 98, __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, 98, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __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, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21); /* … */ __pyx_t_3 = __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_3)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_has_attribute, __pyx_t_3) < 0) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 98, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 98, __pyx_L1_error)
0099: """Returns True if obj has the attribute attr."""
+0100: return PyObject_HasAttr(obj, attr)
__pyx_r = PyObject_HasAttr(__pyx_v_obj, __pyx_v_attr);
goto __pyx_L0;
0101:
+0102: 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_v_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_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_XDECREF(__pyx_v_val); __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, 102, __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, 102, __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, 102, __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, 102, __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, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); /* … */ __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_3to_string, 0, __pyx_n_s_to_string_2, NULL, __pyx_n_s_datamodel_converters, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_string_2, __pyx_t_3) < 0) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_2, 102, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 102, __pyx_L1_error)
0103: """
0104: Returns a string version of an object.
0105: """
+0106: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0107: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0108: if isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0109: 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, 109, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyObject*)__pyx_v_obj); goto __pyx_L0;
+0110: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0111: 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; }
+0112: 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, 112, __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, 112, __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, 112, __pyx_L6_error) __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L10_try_return;
+0113: 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, 113, __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;
+0114: 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, 114, __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, 114, __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, 114, __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, 114, __pyx_L17_error) }
+0115: if isinstance(obj, (int, float, Decimal)):
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_20 = PyInt_Check(__pyx_v_obj); if (!__pyx_t_20) { } else { __pyx_t_1 = __pyx_t_20; goto __pyx_L24_bool_binop_done; } __pyx_t_20 = PyFloat_Check(__pyx_v_obj); if (!__pyx_t_20) { } else { __pyx_t_1 = __pyx_t_20; goto __pyx_L24_bool_binop_done; } __pyx_t_20 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_7); __pyx_t_1 = __pyx_t_20; __pyx_L24_bool_binop_done:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
0116: # its a number
+0117: return str(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_Unicode(__pyx_v_obj); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L0;
+0118: if callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 118, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
0119: # its a function callable returning a value
+0120: try:
{ /*try:*/ { /* … */ } __pyx_L28_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_L30_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_L32_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_L29_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); }
+0121: val = obj()
__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, 121, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_v_val = __pyx_t_7; __pyx_t_7 = 0;
0122: # Recursively call to_string on that result:
+0123: return to_string(val)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __pyx_f_9datamodel_10converters_to_string(__pyx_v_val, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 123, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L32_try_return;
+0124: except Exception:
__pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_12) { __Pyx_ErrRestore(0,0,0); goto __pyx_L29_exception_handled; } goto __pyx_L30_except_error;
0125: pass
0126: # For any other arbitrary type, explicitly fail:
+0127: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 127, __pyx_L1_error)
+0128: f"Cannot convert object of type {type(obj).__name__} to string."
__pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_21 = 0; __pyx_t_22 = 127; __Pyx_INCREF(__pyx_kp_u_Cannot_convert_object_of_type); __pyx_t_21 += 30; __Pyx_GIVEREF(__pyx_kp_u_Cannot_convert_object_of_type); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Cannot_convert_object_of_type); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_6, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_22 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_22) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_22; __pyx_t_21 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_to_string); __pyx_t_21 += 11; __Pyx_GIVEREF(__pyx_kp_u_to_string); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u_to_string); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, __pyx_t_21, __pyx_t_22); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0129: )
0130:
+0131: 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, 131, __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, 131, __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, 131, __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, 131, __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_3 = __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_3)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_uuid, __pyx_t_3) < 0) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 131, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 131, __pyx_L1_error)
0132: """Returns a UUID version of a str column.
0133: """
+0134: if isinstance(obj, pgproto.UUID):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __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, 134, __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, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
0135: # If it's asyncpg's UUID, convert by casting to string first
+0136: 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, 136, __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, 136, __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, 136, __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;
+0137: if isinstance(obj, UUID):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __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, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
0138: # already an uuid
+0139: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0140: elif callable(obj):
__pyx_t_3 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 140, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
0141: # its a function callable returning a value
+0142: 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); }
+0143: return UUID(obj())
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __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, 143, __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, 143, __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;
+0144: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0145: pass
+0146: 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; }
+0147: 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, 147, __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, 147, __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, 147, __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;
+0148: 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, 148, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4);
+0149: 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;
0150:
0151:
+0152: 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, 152, __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, 152, __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, 152, __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, 152, __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, 152, __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_3 = __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_3)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_slugify_camelcase, __pyx_t_3) < 0) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 152, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 152, __pyx_L1_error)
0153: """slugify_camelcase.
0154:
0155: Converting CamelCase into a spaced version, but don’t double-space
0156: if the string already contains spaces or uppercase letters follow
0157: existing spaces.
0158: """
+0159: 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) {
/* … */
}
+0160: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0161:
+0162: 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, 162, __pyx_L1_error) __pyx_t_4 = __Pyx_PyUnicode_FromOrdinal(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 162, __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, 162, __pyx_L1_error); __pyx_t_4 = 0; __pyx_v_slugified = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0163: 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, 163, __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, 163, __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;
+0164: 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, 164, __pyx_L1_error) __pyx_v_c = __pyx_t_3;
0165: # Condition: if c is uppercase AND the previous character isn't a space,
0166: # insert a space before it.
+0167: 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, 167, __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, 167, __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, 167, __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, 167, __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) { /* … */ }
+0168: 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, 168, __pyx_L1_error)
+0169: slugified.append(c)
__pyx_t_5 = __Pyx_PyUnicode_FromOrdinal(__pyx_v_c); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __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, 169, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
+0170: 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, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L0;
0171:
0172:
+0173: 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, 173, __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, 173, __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, 173, __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, 173, __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_3 = __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_3)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_date, __pyx_t_3) < 0) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 173, __pyx_L1_error)
0174: """to_date.
0175:
0176: Returns obj converted to date.
0177: """
+0178: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0179: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_Date *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0180: elif obj == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __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, 180, __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, 180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+0181: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_Date *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0182: if isinstance(obj, datetime.date):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_date);
if (__pyx_t_1) {
/* … */
}
+0183: 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, 183, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyDateTime_Date *)__pyx_v_obj); goto __pyx_L0;
+0184: 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) { /* … */ }
+0185: 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, 185, __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, 185, __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, 185, __pyx_L1_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
+0186: 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) {
/* … */
}
+0187: 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, 187, __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, 187, __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;
0188: # Handle Unix epoch via Rust's `to_timestamp`
+0189: 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) { /* … */ }
+0190: 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); }
+0191: 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, 191, __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, 191, __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, 191, __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, 191, __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, 191, __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, 191, __pyx_L13_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L17_try_return;
+0192: 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;
0193: pass
0194: # using rust todate function
+0195: 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); }
+0196: 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, 196, __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, 196, __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, 196, __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, 196, __pyx_L19_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L23_try_return;
+0197: 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;
0198: pass
0199: # Fallback to Cython-native ciso8601 parsing
+0200: 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; }
+0201: 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, 201, __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, 201, __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, 201, __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, 201, __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, 201, __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, 201, __pyx_L25_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L29_try_return;
+0202: 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, 202, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
0203: pass
+0204: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 204, __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, 204, __pyx_L27_except_error) } goto __pyx_L27_except_error;
+0205: f"Can't convert invalid data *{obj}* to date"
__pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 205, __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, 205, __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, 205, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
0206: )
0207:
0208:
+0209: 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, 209, __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, 209, __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, 209, __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, 209, __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_3 = __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_3)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_datetime, __pyx_t_3) < 0) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 209, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 209, __pyx_L1_error)
0210: """to_datetime.
0211:
0212: Returns obj converted to datetime.
0213: """
+0214: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0215: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_DateTime *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0216: elif obj == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __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, 216, __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, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+0217: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_DateTime *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0218: if isinstance(obj, datetime.datetime):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_datetime);
if (__pyx_t_1) {
/* … */
}
+0219: 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, 219, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyDateTime_DateTime *)__pyx_v_obj); goto __pyx_L0;
+0220: 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) {
/* … */
}
+0221: 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, 221, __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, 221, __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;
0222: # Handle Unix epoch via Rust's `to_timestamp`
+0223: 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) { /* … */ }
+0224: 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); }
+0225: 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, 225, __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, 225, __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, 225, __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, 225, __pyx_L11_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L15_try_return;
+0226: 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;
0227: pass
+0228: 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); }
+0229: return ciso8601.parse_datetime(obj)
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ciso8601); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 229, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_parse_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __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, 229, __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, 229, __pyx_L17_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L21_try_return;
+0230: 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;
0231: pass
+0232: 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; }
+0233: return rc.to_datetime(obj)
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_rc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_to_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 233, __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, 233, __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, 233, __pyx_L23_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L27_try_return;
+0234: 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, 234, __pyx_L25_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
+0235: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 235, __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, 235, __pyx_L25_except_error) } goto __pyx_L25_except_error;
+0236: f"Can't convert invalid data *{obj}* to datetime"
__pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 236, __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, 236, __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, 236, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0237: )
0238:
0239:
+0240: 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, 240, __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, 240, __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, 240, __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, 240, __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_3 = __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_3)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_integer, __pyx_t_3) < 0) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 240, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 240, __pyx_L1_error)
0241: """to_integer.
0242:
0243: Returns object converted to integer.
0244: """
+0245: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0246: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0247: if isinstance(obj, int):
__pyx_t_1 = PyInt_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0248: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0249: if isinstance(obj, unicode):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0250: 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, 250, __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, 250, __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;
+0251: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0252: 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; }
+0253: return int(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L11_try_return;
+0254: 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, 254, __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;
+0255: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 255, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0256: 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, 256, __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, 256, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0257: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 255, __pyx_L18_error) }
+0258: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 258, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L6; }
0259: # its a function callable returning a value
+0260: 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); }
+0261: 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, 261, __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;
+0262: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L25_exception_handled;
}
0263: pass
0264: else:
+0265: 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:;
+0266: return int(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L34_try_return;
+0267: 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, 267, __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;
+0268: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 268, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0269: 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, 269, __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, 269, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0270: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 268, __pyx_L41_error) }
0271:
+0272: 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, 272, __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, 272, __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, 272, __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, 272, __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_3 = __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_3)) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_float, __pyx_t_3) < 0) __PYX_ERR(0, 272, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 272, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 272, __pyx_L1_error)
0273: """to_float.
0274:
0275: Returns object converted to float.
0276: """
+0277: if isinstance(obj, (float, Decimal)):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __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) { /* … */ }
+0278: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0279: elif isinstance(obj, _MISSING_TYPE):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __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, 279, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0280: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0281: elif callable(obj):
__pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 281, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L3; }
0282: # its a function callable returning a value
+0283: 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); }
+0284: 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, 284, __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;
+0285: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L7_exception_handled;
}
0286: pass
0287: else:
+0288: 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:;
+0289: return float(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Float(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L16_try_return;
+0290: 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, 290, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8);
+0291: 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;
0292:
+0293: 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, 293, __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, 293, __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, 293, __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, 293, __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_3 = __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_3)) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_decimal, __pyx_t_3) < 0) __PYX_ERR(0, 293, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 293, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 293, __pyx_L1_error)
0294: """to_decimal.
0295:
0296: Returns a Decimal version of object.
0297: """
+0298: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0299: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0300: if isinstance(obj, Decimal):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __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, 300, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0301: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0302: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 302, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0303: # its a function callable returning a value
+0304: 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); }
+0305: 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, 305, __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;
+0306: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0307: pass
0308: else:
+0309: 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:;
+0310: return Decimal(obj)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __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, 310, __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;
+0311: 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, 311, __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, 311, __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; } } }
+0312: raise ValueError(
__pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 312, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0313: 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, 313, __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, 313, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0314: ) from ex
__Pyx_Raise(__pyx_t_9, 0, 0, __pyx_v_ex); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 312, __pyx_L22_error) }
+0315: 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, 315, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+0316: 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;
0317:
+0318: TIMEDELTA_RE = re.compile(r"(-)?(\d{1,3}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?")
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEDELTA_RE, __pyx_t_3) < 0) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32);
0319:
+0320: 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; }
+0321: if not s:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_s); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 321, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0322: return 0
__pyx_r = 0; goto __pyx_L0;
0323: # Pad zeros to ensure the fraction length in microseconds
+0324: 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, 324, __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, 324, __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, 324, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4);
+0325: 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, 325, __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, 325, __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, 325, __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, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__5); __Pyx_GIVEREF(__pyx_slice__5);
0326:
+0327: 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, 327, __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, 327, __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, 327, __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, 327, __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_3 = __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_3)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_timedelta, __pyx_t_3) < 0) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 327, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 327, __pyx_L1_error)
0328:
+0329: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0330: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0331: if isinstance(obj, datetime.timedelta):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_timedelta);
if (__pyx_t_1) {
/* … */
}
+0332: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0333:
+0334: 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) {
/* … */
}
+0335: 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, 335, __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, 335, __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;
0336:
+0337: m = TIMEDELTA_RE.match(obj)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_TIMEDELTA_RE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 337, __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, 337, __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, 337, __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;
+0338: if not m:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_m); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 338, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0339: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0340:
+0341: 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; }
+0342: 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, 342, __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, 342, __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, 342, __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;
+0343: 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, 343, __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, 343, __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, 343, __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, 343, __pyx_L9_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0344: 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, 344, __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, 344, __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;
+0345: 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, 345, __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, 345, __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, 345, __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;
0346: tdelta = (
+0347: 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, 347, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0348: hours=int(hours),
__pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 348, __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, 348, __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, 348, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0349: minutes=int(minutes),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_minutes); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 349, __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, 348, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0350: seconds=int(seconds),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_seconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 350, __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, 348, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0351: microseconds=int(microseconds),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_microseconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 351, __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, 348, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
0352: )
+0353: * negate
__pyx_t_5 = PyNumber_Multiply(__pyx_t_12, __pyx_v_negate); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 353, __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;
0354: )
+0355: return tdelta
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_tdelta); __pyx_r = __pyx_v_tdelta; goto __pyx_L13_try_return;
+0356: 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, 356, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_11);
+0357: raise ValueError(
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 357, __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, 357, __pyx_L11_except_error) } goto __pyx_L11_except_error;
+0358: 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, 358, __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, 358, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0359: )
0360:
+0361: TIME_RE = re.compile(r"(\d{1,2}):(\d{1,2}):(\d{1,2})(?:.(\d{1,6}))?")
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIME_RE, __pyx_t_3) < 0) __PYX_ERR(0, 361, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34);
0362:
+0363: 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, 363, __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, 363, __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, 363, __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, 363, __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_3 = __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_3)) __PYX_ERR(0, 363, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_time, __pyx_t_3) < 0) __PYX_ERR(0, 363, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 363, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 363, __pyx_L1_error)
0364: """to_time.
0365:
0366: Returns obj converted to datetime.time.
0367: """
+0368: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0369: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0370: if isinstance(obj, datetime.time):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_time);
if (__pyx_t_1) {
/* … */
}
+0371: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0372: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 372, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0373: # its a function callable returning a value
+0374: 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); }
+0375: 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, 375, __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;
+0376: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0377: pass
0378: else:
+0379: 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); }
+0380: 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, 380, __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, 380, __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, 380, __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, 380, __pyx_L11_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5)) __PYX_ERR(0, 380, __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, 380, __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, 380, __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, 380, __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;
+0381: 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;
0382: pass
+0383: m = TIME_RE.match(obj)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_TIME_RE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 383, __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, 383, __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, 383, __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;
+0384: if not m:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_m); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 384, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_1); if (__pyx_t_10) { /* … */ }
+0385: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0386: 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:;
+0387: 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, 387, __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, 387, __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, 387, __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;
+0388: 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, 388, __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, 388, __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, 388, __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, 388, __pyx_L18_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0389: 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, 389, __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, 389, __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;
+0390: 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, 390, __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;
+0391: hour=int(hours),
__pyx_t_11 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 391, __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, 391, __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, 391, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0392: minute=int(minutes),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_minutes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 392, __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, 391, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0393: second=int(seconds),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_seconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __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, 391, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0394: microsecond=int(microseconds),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __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, 391, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0395: )
+0396: 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, 396, __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;
+0397: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 397, __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, 397, __pyx_L29_error) }
+0398: f"Invalid Time/Timestamp Object {obj}: {e}"
__pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 398, __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, 398, __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, 398, __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, 398, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0399: )
0400:
0401:
+0402: 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, 402, __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, 402, __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, 402, __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, 402, __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, 402, __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, 402, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); /* … */ __pyx_t_3 = __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_3)) __PYX_ERR(0, 402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_strtobool, __pyx_t_3) < 0) __PYX_ERR(0, 402, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 402, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 402, __pyx_L1_error)
0403: """Convert a string representation of truth to true (1) or false (0).
0404:
0405: True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
0406: are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
0407: 'val' is anything else.
0408: """
+0409: val = val.lower()
__pyx_t_1 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_lower, __pyx_v_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __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, 409, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_val, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+0410: 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, 410, __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, 410, __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, 410, __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, 410, __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, 410, __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, 410, __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, 410, __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) { /* … */ }
+0411: return True
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
+0412: 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, 412, __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, 412, __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, 412, __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, 412, __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, 412, __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, 412, __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, 412, __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, 412, __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)) { /* … */ }
+0413: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
0414: else:
+0415: raise ValueError(
/*else*/ { /* … */ __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 415, __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, 415, __pyx_L1_error) }
+0416: f"Invalid truth value for **'{val}'**"
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __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, 416, __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, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0417: )
0418:
+0419: 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, 419, __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, 419, __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, 419, __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, 419, __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_3 = __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_3)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_boolean, __pyx_t_3) < 0) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 419, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 419, __pyx_L1_error)
0420: """to_boolean.
0421:
0422: Convert and returns any object value to boolean version.
0423: """
+0424: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0425: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0426: 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, 426, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0427: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0428: 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) {
/* … */
}
+0429: 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, 429, __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, 429, __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;
+0430: if isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0431: 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, 431, __pyx_L1_error) __pyx_t_2 = __pyx_f_9datamodel_10converters_strtobool(((PyObject*)__pyx_v_obj), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0432: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 432, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L8; }
0433: # its a function callable returning a value
+0434: 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); }
+0435: 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, 435, __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;
+0436: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L10_exception_handled;
}
0437: pass
0438: else:
+0439: 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, 439, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } __pyx_L8:;
0440:
+0441: 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, 441, __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, 441, __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, 441, __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, 441, __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_3 = __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_3)) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_object, __pyx_t_3) < 0) __PYX_ERR(0, 441, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 441, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 441, __pyx_L1_error)
+0442: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0443: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0444: 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) { /* … */ }
+0445: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0446: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 446, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0447: # its a function callable returning a value
+0448: 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); }
+0449: 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, 449, __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;
+0450: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L9_exception_handled;
}
0451: pass
+0452: elif isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (likely(__pyx_t_1)) {
/* … */
}
+0453: 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; }
+0454: 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, 454, __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, 454, __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, 454, __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;
+0455: 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, 455, __pyx_L16_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7);
+0456: 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;
0457: else:
+0458: raise ValueError(
/*else*/ { /* … */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 458, __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, 458, __pyx_L1_error) } __pyx_L4:;
+0459: f"Can't convert invalid data {obj} to Object"
__pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 459, __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, 459, __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, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0460: )
0461:
+0462: 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, 462, __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, 462, __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, 462, __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, 462, __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_3 = __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_3)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_bytes, __pyx_t_3) < 0) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 462, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 462, __pyx_L1_error)
0463: """
0464: Convert the given object to bytes.
0465:
0466: - If the object is already bytes, return it directly.
0467: - If the object is a string, encode it (using UTF-8).
0468: - If the object is callable, call it and convert its result.
0469: - Otherwise, attempt to convert the object to bytes.
0470: If conversion fails, raise a ValueError.
0471: """
+0472: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (unlikely(__pyx_t_1)) { /* … */ }
+0473: 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, 473, __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, 473, __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, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9);
0474:
0475: # 1. If already bytes, return as is.
+0476: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0477: 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, 477, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyObject*)__pyx_v_obj); goto __pyx_L0;
0478:
0479: # 2. If it's a string, encode it to bytes.
+0480: elif isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0481: 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, 481, __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, 481, __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, 481, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0;
0482:
0483: # 3. If it's callable, attempt to call it and convert its result.
+0484: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 484, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0485: 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; }
+0486: 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, 486, __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;
0487: # Recursively convert the result.
+0488: 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, 488, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L9_try_return;
+0489: 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, 489, __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;
+0490: 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, 490, __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, 490, __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, 490, __pyx_L16_error) }
0491:
0492: # 4. Try converting the object into bytes using Python's built-in conversion.
+0493: 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; }
+0494: 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, 494, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L26_try_return;
+0495: 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, 495, __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;
+0496: 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, 496, __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, 496, __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, 496, __pyx_L33_error) }
0497:
+0498: 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; }
0499: """
0500: Check if `value` is callable by calling Python's callable(...)
0501: but reacquire the GIL inside.
0502: """
+0503: 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; } } }
+0504: return callable(value)
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_value); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 504, __pyx_L4_error) __pyx_r = __pyx_t_1; goto __pyx_L3_return; }
0505:
0506:
0507: # Encoder List:
0508: encoders = {
+0509: str: to_string,
__pyx_t_3 = __Pyx_PyDict_NewPresized(13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_to_string_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyUnicode_Type)), __pyx_t_2) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0510: UUID: to_uuid,
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_uuid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0511: pgproto.UUID: to_uuid,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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, 511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0512: bool: to_boolean,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_boolean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject*)&PyBool_Type), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0513: int: to_integer,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_integer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyInt_Type)), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0514: float: to_float,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_float); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyFloat_Type)), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0515: datetime.date: to_date,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_date); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_ptype_7cpython_8datetime_date), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0516: datetime.datetime: to_datetime,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_ptype_7cpython_8datetime_datetime), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0517: datetime.timedelta: to_timedelta,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_timedelta); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_ptype_7cpython_8datetime_timedelta), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0518: datetime.time: to_time,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_ptype_7cpython_8datetime_time), __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0519: Decimal: to_decimal,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_to_decimal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_t_4, __pyx_t_2) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0520: bytes: to_bytes,
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_to_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 520, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyBytes_Type)), __pyx_t_2) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0521: Path: lambda obj: Path(obj) if isinstance(obj, str) else obj
/* Python wrapper */ static PyObject *__pyx_pw_9datamodel_10converters_38lambda(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 PyMethodDef __pyx_mdef_9datamodel_10converters_38lambda = {"lambda", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9datamodel_10converters_38lambda, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_9datamodel_10converters_38lambda(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("lambda (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, 521, __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, "lambda") < 0)) __PYX_ERR(0, 521, __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("lambda", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 521, __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.lambda", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_lambda_funcdef_9datamodel_10converters_lambda(__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_lambda_funcdef_9datamodel_10converters_lambda(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyUnicode_Check(__pyx_v_obj); if (__pyx_t_2) { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 521, __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_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_v_obj}; __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, 521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_obj); __pyx_t_1 = __pyx_v_obj; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("datamodel.converters.lambda", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9datamodel_10converters_38lambda, 0, __pyx_n_s_lambda, NULL, __pyx_n_s_datamodel_converters, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_4) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_encoders, __pyx_t_3) < 0) __PYX_ERR(0, 508, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0522: }
0523:
0524:
0525: # Maps a type to a conversion callable
+0526: cdef dict TYPE_PARSERS = {}
__pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_v_9datamodel_10converters_TYPE_PARSERS); __Pyx_DECREF_SET(__pyx_v_9datamodel_10converters_TYPE_PARSERS, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
0527:
0528:
+0529: 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, 529, __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, 529, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("register_parser", 1, 2, 2, 1); __PYX_ERR(0, 529, __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, 529, __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, 529, __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, 529, __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, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__41); __Pyx_GIVEREF(__pyx_tuple__41); /* … */ __pyx_t_3 = __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_3)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_register_parser, __pyx_t_3) < 0) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 529, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 529, __pyx_L1_error)
0530: """register_parser.
0531:
0532: Register a new Parser function for a given type.
0533:
0534: Parameters:
0535: _type (type): The type for which the parser function is registered.
0536: parser_func (function): The parser function to convert the given type.
0537: """
+0538: 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, 538, __pyx_L1_error) } if (unlikely((PyDict_SetItem(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v__type, __pyx_v_parser_func) < 0))) __PYX_ERR(0, 538, __pyx_L1_error)
0539:
0540:
0541: ## Parsing Functions
+0542: cdef object _parse_set_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_set_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_set_type *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_18); __Pyx_AddTraceback("datamodel.converters._parse_set_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_processed_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_set_type { int __pyx_n; PyObject *_parent; };
0543: object field,
0544: object T,
0545: object data,
0546: object encoder,
0547: object args,
+0548: 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_processed_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);
0549: ):
0550: """
0551: Parse a set of items to a typing type.
0552: """
+0553: cdef object arg_type = args[0] if args else Any
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 553, __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, 553, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+0554: cdef set result = set()
__pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 554, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0555: cdef tuple key = (arg_type, field.name)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_arg_type); __Pyx_GIVEREF(__pyx_v_arg_type); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_arg_type)) __PYX_ERR(0, 555, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1)) __PYX_ERR(0, 555, __pyx_L1_error); __pyx_t_1 = 0; __pyx_v_key = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+0556: 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, 556, __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, 556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 556, __pyx_L1_error) if (!__pyx_t_2) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __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, 556, __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, 556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_L3_bool_binop_done:; __pyx_v_converter = __pyx_t_3; __pyx_t_3 = 0;
+0557: cdef object inner_type = field._inner_type if hasattr(field, '_inner_type') else arg_type
__pyx_t_2 = __Pyx_HasAttr(__pyx_v_field, __pyx_n_u_inner_type); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 557, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_v_arg_type); __pyx_t_3 = __pyx_v_arg_type; } __pyx_v_inner_type = __pyx_t_3; __pyx_t_3 = 0;
0558:
+0559: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+0560: return set() # short-circuit
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
0561:
0562: # If data is not already a collection, put it in a list for processing
+0563: if not isinstance(data, (list, tuple, set)):
__pyx_t_4 = PyList_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L7_bool_binop_done; } __pyx_t_4 = PyTuple_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L7_bool_binop_done; } __pyx_t_4 = PySet_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_4; __pyx_L7_bool_binop_done:; __pyx_t_4 = (!__pyx_t_2); if (__pyx_t_4) { /* … */ }
+0564: data = [data]
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_data)) __PYX_ERR(0, 564, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
0565:
0566: # If it's a dataclass
+0567: 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, 567, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+0568: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __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, 568, __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, 568, __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, 568, __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, 568, __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, 568, __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, 568, __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, 568, __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, 568, __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;
+0569: 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, 569, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L13; }
+0570: result.add(d)
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_d); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 570, __pyx_L1_error)
+0571: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 571, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L13; }
+0572: result.add(
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0573: converter(field.name, d, inner_type, _parent)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 573, __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, 573, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; }
0574: )
+0575: elif isinstance(d, dict):
__pyx_t_4 = PyDict_Check(__pyx_v_d);
if (__pyx_t_4) {
/* … */
goto __pyx_L13;
}
+0576: result.add(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, 576, __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, 576, __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, 576, __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, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0577: elif isinstance(d, (list, tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_d); if (!__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L14_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_d); __pyx_t_4 = __pyx_t_2; __pyx_L14_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L13; }
+0578: result.add(inner_type(*d))
__pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 578, __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, 578, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 578, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0579: else:
+0580: result.add(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, 580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 580, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L13:;
+0581: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+0582: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 582, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L10; }
+0583: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 583, __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, 583, __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, 583, __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, 583, __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, 583, __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, 583, __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, 583, __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, 583, __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, 583, __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;
+0584: result.add(
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 584, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0585: converter(field.name, item, inner_type, _parent)
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 585, __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, 585, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
0586: )
+0587: elif is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 587, __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_3 = __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_3)) __PYX_ERR(0, 587, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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, 587, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { /* … */ goto __pyx_L10; }
0588: # Process each item with appropriate converters
+0589: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 589, __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, 589, __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, 589, __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, 589, __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, 589, __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, 589, __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, 589, __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, 589, __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, 589, __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;
+0590: 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_L29_try_end; __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_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_L29_try_end:; }
0591: # If a specific encoder exists for this type, use it
+0592: if encoder:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 592, __pyx_L22_error) if (__pyx_t_4) { /* … */ goto __pyx_L30; }
+0593: processed_item = encoder(item)
__Pyx_INCREF(__pyx_v_encoder); __pyx_t_8 = __pyx_v_encoder; __pyx_t_9 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(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_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_item}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_XDECREF_SET(__pyx_v_processed_item, __pyx_t_1); __pyx_t_1 = 0;
0594: else:
0595: # Otherwise try to use builtin converters
+0596: processed_item = _parse_builtin_type(field, inner_type, item, None)
/*else*/ { __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_processed_item, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L30:;
+0597: result.add(processed_item)
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_processed_item); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 597, __pyx_L22_error)
+0598: except Exception as e:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters._parse_set_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 598, __pyx_L24_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_v_e = __pyx_t_8; /*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_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 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_15 = __pyx_lineno; __pyx_t_19 = __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_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_15; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20; goto __pyx_L24_except_error; } } } goto __pyx_L24_except_error;
+0599: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_18); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 599, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+0600: f"Error parsing set item of {inner_type}: {e}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 600, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_set_item_of); __pyx_t_16 += 26; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_set_item_of); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Error_parsing_set_item_of); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_inner_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 600, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u__7); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 600, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 600, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0601: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 599, __pyx_L36_error) }
0602: else:
+0603: for item in data:
/*else*/ { 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __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, 603, __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, 603, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 603, __pyx_L1_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #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, 603, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 603, __pyx_L1_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } } else { __pyx_t_9 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_9)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 603, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_9); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_9); __pyx_t_9 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L10:;
+0604: result.add(
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0605: _parse_typing(field, T=inner_type, data=item, encoder=encoder, as_objects=False)
__pyx_t_27.__pyx_n = 2; __pyx_t_27.encoder = __pyx_v_encoder; __pyx_t_27.as_objects = Py_False; __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, &__pyx_t_27); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 605, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9);
0606: )
+0607: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0608:
+0609: 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_key_type = 0; PyObject *__pyx_v_val_type = 0; PyObject *__pyx_v_new_dict = 0; PyObject *__pyx_v_val_origin = 0; PyObject *__pyx_v_val_args = 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_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("datamodel.converters._parse_dict_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_key_type); __Pyx_XDECREF(__pyx_v_val_type); __Pyx_XDECREF(__pyx_v_new_dict); __Pyx_XDECREF(__pyx_v_val_origin); __Pyx_XDECREF(__pyx_v_val_args); __Pyx_XDECREF(__pyx_v_k); __Pyx_XDECREF(__pyx_v_v); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0610: object field,
0611: object T,
0612: object data,
0613: object encoder,
0614: object args
0615: ):
+0616: cdef object key_type = args[0] # First arg is key type
__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, 616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_key_type = __pyx_t_1; __pyx_t_1 = 0;
+0617: cdef object val_type = args[1] # Second arg is value type
__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, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_val_type = __pyx_t_1; __pyx_t_1 = 0;
+0618: cdef dict new_dict = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_new_dict = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
0619: cdef object val_origin, val_args
0620:
0621: # Check if we have type args (Dict[K, V])
+0622: if not args or len(args) < 2:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 622, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_3); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 622, __pyx_L1_error) __pyx_t_4 = (__pyx_t_5 < 2); __pyx_t_2 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0623: return data # If no type arguments, return as is
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0624:
0625: # Get origin and args of value type to check if it's a nested Dict
+0626: val_origin = get_origin(val_type)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 626, __pyx_L1_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_val_type}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_v_val_origin = __pyx_t_1; __pyx_t_1 = 0;
+0627: val_args = get_args(val_type)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_get_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 627, __pyx_L1_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_val_type}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_v_val_args = __pyx_t_1; __pyx_t_1 = 0;
0628:
0629: # Process each key-value pair
+0630: for k, v in data.items():
__pyx_t_5 = 0; if (unlikely(__pyx_v_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 630, __pyx_L1_error) } __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_data, 0, __pyx_n_s_items, (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 630, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_9, &__pyx_t_5, &__pyx_t_6, &__pyx_t_7, NULL, __pyx_t_10); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 630, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_7); __pyx_t_7 = 0;
0631: # Convert the key if needed
+0632: if key_type == str and not isinstance(k, str):
__pyx_t_7 = PyObject_RichCompare(__pyx_v_key_type, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 632, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L9_bool_binop_done; } __pyx_t_4 = PyUnicode_Check(__pyx_v_k); __pyx_t_3 = (!__pyx_t_4); __pyx_t_2 = __pyx_t_3; __pyx_L9_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L8; }
+0633: k = str(k)
__pyx_t_7 = __Pyx_PyObject_Unicode(__pyx_v_k); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_7); __pyx_t_7 = 0;
+0634: elif key_type == int and isinstance(k, str):
__pyx_t_7 = PyObject_RichCompare(__pyx_v_key_type, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 634, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_k); __pyx_t_2 = __pyx_t_3; __pyx_L11_bool_binop_done:; if (__pyx_t_2) { /* … */ } __pyx_L8:;
+0635: 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_L20_try_end; __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L15_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_L14_exception_handled:; __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); __pyx_L20_try_end:; }
+0636: k = int(k)
__pyx_t_7 = __Pyx_PyNumber_Int(__pyx_v_k); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 636, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_7); __pyx_t_7 = 0;
+0637: except (ValueError, TypeError):
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError);
if (__pyx_t_11) {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L14_exception_handled;
}
goto __pyx_L15_except_error;
0638: pass
0639:
0640: # If value type is a nested Dict
+0641: if val_origin is dict and val_args:
__pyx_t_3 = (__pyx_v_val_origin == ((PyObject *)(&PyDict_Type))); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L22_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_val_args); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 641, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L22_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L21; }
+0642: if isinstance(v, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_v);
if (__pyx_t_2) {
/* … */
goto __pyx_L24;
}
0643: # Recursively process nested dict
+0644: new_dict[k] = _parse_dict_type(field, val_type, v, encoder, val_args)
__pyx_t_7 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_val_type, __pyx_v_v, __pyx_v_encoder, __pyx_v_val_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_7) < 0))) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0645: else:
0646: # Not a dict but should be - create empty dict
+0647: new_dict[k] = {}
/*else*/ { __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_7) < 0))) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_L24:;
0648: # If value type is a primitive type
+0649: elif is_primitive(val_type):
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_15 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_v_val_type}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L21; }
+0650: if val_type == int and isinstance(v, str):
__pyx_t_7 = PyObject_RichCompare(__pyx_v_val_type, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 650, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L26_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_v); __pyx_t_2 = __pyx_t_3; __pyx_L26_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L25; }
+0651: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L35_try_end; __pyx_L28_error:; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L30_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_L29_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); __pyx_L35_try_end:; }
+0652: new_dict[k] = int(v)
__pyx_t_7 = __Pyx_PyNumber_Int(__pyx_v_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 652, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_7) < 0))) __PYX_ERR(0, 652, __pyx_L28_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0653: except (ValueError, TypeError):
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._parse_dict_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_15) < 0) __PYX_ERR(0, 653, __pyx_L30_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_15);
+0654: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 654, __pyx_L30_except_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L29_exception_handled; } goto __pyx_L30_except_error;
+0655: elif val_type == float and isinstance(v, str):
__pyx_t_15 = PyObject_RichCompare(__pyx_v_val_type, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 655, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 655, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L38_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_v); __pyx_t_2 = __pyx_t_3; __pyx_L38_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L25; }
+0656: 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_L47_try_end; __pyx_L40_error:; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L42_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_L41_exception_handled:; __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); __pyx_L47_try_end:; }
+0657: new_dict[k] = float(v)
__pyx_t_15 = __Pyx_PyNumber_Float(__pyx_v_v); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 657, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_15); if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_15) < 0))) __PYX_ERR(0, 657, __pyx_L40_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+0658: except (ValueError, TypeError):
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._parse_dict_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 658, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+0659: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 659, __pyx_L42_except_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L41_exception_handled; } goto __pyx_L42_except_error;
+0660: elif val_type == bool and isinstance(v, str):
__pyx_t_7 = PyObject_RichCompare(__pyx_v_val_type, ((PyObject*)&PyBool_Type), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 660, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L50_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_v); __pyx_t_2 = __pyx_t_3; __pyx_L50_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L25; }
+0661: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L59_try_end; __pyx_L52_error:; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L54_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_L53_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); __pyx_L59_try_end:; }
+0662: new_dict[k] = to_boolean(v)
__pyx_t_7 = __pyx_f_9datamodel_10converters_to_boolean(__pyx_v_v, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 662, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_7) < 0))) __PYX_ERR(0, 662, __pyx_L52_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0663: except (ValueError, TypeError):
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._parse_dict_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_15) < 0) __PYX_ERR(0, 663, __pyx_L54_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_15);
+0664: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 664, __pyx_L54_except_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L53_exception_handled; } goto __pyx_L54_except_error;
+0665: elif val_type in encoders:
__Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_encoders); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 665, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_val_type, __pyx_t_15, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 665, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L25; }
+0666: 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_L69_try_end; __pyx_L62_error:; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L64_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_L63_exception_handled:; __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); __pyx_L69_try_end:; }
+0667: new_dict[k] = encoders[val_type](v)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_encoders); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 667, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_v_val_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 667, __pyx_L62_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_v}; __pyx_t_15 = __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_15)) __PYX_ERR(0, 667, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_t_15) < 0))) __PYX_ERR(0, 667, __pyx_L62_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+0668: except (ValueError, TypeError):
__pyx_t_11 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_ValueError, __pyx_builtin_TypeError); if (__pyx_t_11) { __Pyx_AddTraceback("datamodel.converters._parse_dict_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 668, __pyx_L64_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6);
+0669: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 669, __pyx_L64_except_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L63_exception_handled; } goto __pyx_L64_except_error;
0670: else:
+0671: new_dict[k] = v
/*else*/ { if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 671, __pyx_L1_error) } __pyx_L25:;
0672: # Other non-primitive types
0673: else:
+0674: new_dict[k] = _parse_typing(field, val_type, v, encoder, False)
/*else*/ { __pyx_t_16.__pyx_n = 2; __pyx_t_16.encoder = __pyx_v_encoder; __pyx_t_16.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_16); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 674, __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, 674, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L21:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0675:
+0676: return new_dict
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_dict); __pyx_r = __pyx_v_new_dict; goto __pyx_L0;
0677:
+0678: 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_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_28); __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_e); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_17_parse_tuple_type_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ struct __pyx_opt_args_9datamodel_10converters__parse_list_type { int __pyx_n; PyObject *_parent; };
0679: object field,
0680: object T,
0681: object data,
0682: object encoder,
0683: object args,
+0684: 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;
CYTHON_UNUSED int __pyx_v_is_optional;
PyObject *__pyx_v_d = NULL;
PyObject *__pyx_v_e = 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;
}
}
__Pyx_INCREF(__pyx_v_data);
0685: ):
0686: """
0687: Parse a list of items to a typing type.
0688: """
+0689: 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, 689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+0690: cdef list result = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0691: cdef tuple key = (arg_type, field.name)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 691, __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, 691, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1)) __PYX_ERR(0, 691, __pyx_L1_error); __pyx_t_1 = 0; __pyx_v_key = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+0692: 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, 692, __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, 692, __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, 692, __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, 692, __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, 692, __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;
+0693: 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, 693, __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, 693, __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;
+0694: cdef bint is_optional = False
__pyx_v_is_optional = 0;
0695:
+0696: if data is None:
__pyx_t_3 = (__pyx_v_data == Py_None); if (__pyx_t_3) { /* … */ }
+0697: return [] # short-circuit
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0698:
+0699: 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) { /* … */ }
+0700: data = [data]
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 700, __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, 700, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
0701:
0702: # If it's a dataclass
+0703: 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, 703, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+0704: 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, 704, __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, 704, __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, 704, __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, 704, __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, 704, __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, 704, __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, 704, __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, 704, __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, 704, __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;
+0705: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L21_try_end; __pyx_L14_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __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; /* … */ __pyx_L16_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_L21_try_end:; }
+0706: 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, 706, __pyx_L14_error) if (__pyx_t_4) { /* … */ goto __pyx_L22; }
+0707: result.append(d)
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_d); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 707, __pyx_L14_error)
+0708: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 708, __pyx_L14_error) if (__pyx_t_4) { /* … */ goto __pyx_L22; }
+0709: result.append(
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 709, __pyx_L14_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0710: converter(field.name, d, inner_type, _parent)
__pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 710, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_v_converter); __pyx_t_12 = __pyx_v_converter; __pyx_t_13 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_13, __pyx_t_11, __pyx_v_d, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_14, 4+__pyx_t_14); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; }
0711: )
+0712: elif isinstance(d, dict):
__pyx_t_4 = PyDict_Check(__pyx_v_d);
if (__pyx_t_4) {
/* … */
goto __pyx_L22;
}
+0713: 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, 713, __pyx_L14_error) } if (likely(PyDict_CheckExact(__pyx_v_d))) { __pyx_t_1 = PyDict_Copy(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L14_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, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_12 = __Pyx_PyObject_Call(__pyx_v_inner_type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_12); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 713, __pyx_L14_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0714: 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_L23_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_d); __pyx_t_4 = __pyx_t_3; __pyx_L23_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L22; }
+0715: result.append(inner_type(*d))
__pyx_t_12 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 715, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_inner_type, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 715, __pyx_L14_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0716: else:
+0717: result.append(inner_type(d))
/*else*/ { __Pyx_INCREF(__pyx_v_inner_type); __pyx_t_12 = __pyx_v_inner_type; __pyx_t_11 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_v_d}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 717, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 717, __pyx_L14_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L22:;
+0718: 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_1, &__pyx_t_12, &__pyx_t_11) < 0) __PYX_ERR(0, 718, __pyx_L16_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __pyx_v_e = __pyx_t_12; /*try:*/ { /* … */ /*finally:*/ { __pyx_L30_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_13); __pyx_t_13 = 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_15 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 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_15; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21; goto __pyx_L16_except_error; } } } goto __pyx_L16_except_error;
0719: # Propagate the error with more context
+0720: raise ValueError(
__pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_19); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 720, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+0721: f"Error creating {inner_type.__name__} from {d}: {e}"
__pyx_t_13 = PyTuple_New(6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 721, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Error_creating); __pyx_t_16 += 15; __Pyx_GIVEREF(__pyx_kp_u_Error_creating); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_kp_u_Error_creating); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_inner_type, __pyx_n_s_name); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 721, __pyx_L30_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, 721, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u_from); __pyx_t_16 += 6; __Pyx_GIVEREF(__pyx_kp_u_from); PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_kp_u_from); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_d, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 721, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_kp_u__7); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 721, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_13, 5, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_13, 6, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 721, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+0722: ) from e
__Pyx_Raise(__pyx_t_13, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __PYX_ERR(0, 720, __pyx_L30_error) }
+0723: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+0724: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 724, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L11; }
+0725: 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, 725, __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, 725, __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, 725, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 725, __pyx_L1_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); #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, 725, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 725, __pyx_L1_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); #endif } } else { __pyx_t_11 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_11)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 725, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_11); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_11); __pyx_t_11 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0726: result.append(
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 726, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0727: converter(field.name, item, inner_type, _parent)
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_v_converter); __pyx_t_1 = __pyx_v_converter; __pyx_t_13 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_13, __pyx_t_12, __pyx_v_item, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_14, 4+__pyx_t_14); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
0728: )
+0729: elif is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_inner_type}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_4) { /* … */ goto __pyx_L11; }
+0730: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L45_try_end; __pyx_L40_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __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; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_L42_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_L41_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); __pyx_L45_try_end:; }
+0731: 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, 731, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 731, __pyx_L40_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, 731, __pyx_L40_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 731, __pyx_L40_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 731, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); #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, 731, __pyx_L40_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 731, __pyx_L40_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 731, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); #endif } } else { __pyx_t_11 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_11)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 731, __pyx_L40_error) } break; } __Pyx_GOTREF(__pyx_t_11); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_11); __pyx_t_11 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0732: if encoder:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 732, __pyx_L40_error) if (__pyx_t_4) { /* … */ }
+0733: result.append(encoder(item))
__Pyx_INCREF(__pyx_v_encoder); __pyx_t_1 = __pyx_v_encoder; __pyx_t_12 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_v_item}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 733, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 733, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0734: if inner_type == int and isinstance(item, str):
__pyx_t_11 = PyObject_RichCompare(__pyx_v_inner_type, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 734, __pyx_L40_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 734, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L50_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_item); __pyx_t_4 = __pyx_t_3; __pyx_L50_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L49; }
+0735: result.append(int(item))
__pyx_t_11 = __Pyx_PyNumber_Int(__pyx_v_item); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 735, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 735, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0736: elif inner_type == float and isinstance(item, str):
__pyx_t_11 = PyObject_RichCompare(__pyx_v_inner_type, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 736, __pyx_L40_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 736, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L52_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_item); __pyx_t_4 = __pyx_t_3; __pyx_L52_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L49; }
+0737: result.append(float(item))
__pyx_t_11 = __Pyx_PyNumber_Float(__pyx_v_item); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 737, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 737, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0738: else:
+0739: if inner_type in encoders:
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_encoders); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 739, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_inner_type, __pyx_t_11, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 739, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_4) { /* … */ goto __pyx_L54; }
+0740: result.append(encoders[inner_type](item))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_encoders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_inner_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 740, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_item}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 740, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 740, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0741: else:
+0742: result.append(
/*else*/ { /* … */ __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 742, __pyx_L40_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_L54:; } __pyx_L49:;
+0743: _parse_builtin_type(field, inner_type, item, None)
__pyx_t_11 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, Py_None); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 743, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_11);
0744: )
+0745: except Exception as e:
__pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_20) { __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_11, &__pyx_t_12) < 0) __PYX_ERR(0, 745, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_t_11); __pyx_v_e = __pyx_t_11; /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L62; } __pyx_L61_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27) < 0)) __Pyx_ErrFetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_26); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_32); __Pyx_XGOTREF(__pyx_t_31); __Pyx_XGOTREF(__pyx_t_30); __pyx_t_15 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_33 = __pyx_filename; { __Pyx_XDECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_32); __Pyx_XGIVEREF(__pyx_t_31); __Pyx_XGIVEREF(__pyx_t_30); __Pyx_ExceptionReset(__pyx_t_32, __pyx_t_31, __pyx_t_30); } __Pyx_XGIVEREF(__pyx_t_25); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ErrRestore(__pyx_t_25, __pyx_t_26, __pyx_t_27); __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_33; goto __pyx_L42_except_error; } __pyx_L62:; } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L41_exception_handled; } goto __pyx_L42_except_error;
+0746: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0; __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0; goto __pyx_L70_try_end; __pyx_L63_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; /* … */ __pyx_L65_except_error:; __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_26, __pyx_t_25); goto __pyx_L61_error; __pyx_L70_try_end:; } }
+0747: result = rc.to_list(inner_type, data)
__Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_rc); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 747, __pyx_L63_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_to_list); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 747, __pyx_L63_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_19))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_19); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_19, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_v_inner_type, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_19, __pyx_callargs+1-__pyx_t_14, 2+__pyx_t_14); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L63_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_1))) __PYX_ERR(0, 747, __pyx_L63_error) __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
0748: # return data
+0749: except Exception as e:
__pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_20) { __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_19, &__pyx_t_13) < 0) __PYX_ERR(0, 749, __pyx_L65_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_t_19); __Pyx_DECREF_SET(__pyx_v_e, __pyx_t_19); /*try:*/ { /* … */ /*finally:*/ { __pyx_L76_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_30); __Pyx_XGOTREF(__pyx_t_31); __Pyx_XGOTREF(__pyx_t_32); __pyx_t_20 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_29 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_30); __Pyx_XGIVEREF(__pyx_t_31); __Pyx_XGIVEREF(__pyx_t_32); __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32); } __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ErrRestore(__pyx_t_24, __pyx_t_23, __pyx_t_22); __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_lineno = __pyx_t_20; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_29; goto __pyx_L65_except_error; } } } goto __pyx_L65_except_error;
+0750: raise ValueError(
__pyx_t_18 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_28); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 750, __pyx_L76_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
+0751: f"Error parsing list of {inner_type}: {e}"
__pyx_t_18 = PyTuple_New(4); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 751, __pyx_L76_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_5 = 0; __pyx_t_17 = 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_18, 0, __pyx_kp_u_Error_parsing_list_of); __pyx_t_28 = __Pyx_PyObject_FormatSimple(__pyx_v_inner_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 751, __pyx_L76_error) __Pyx_GOTREF(__pyx_t_28); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_28); __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_28); __pyx_t_28 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_5 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_kp_u__7); __pyx_t_28 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 751, __pyx_L76_error) __Pyx_GOTREF(__pyx_t_28); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_28); __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_t_28); __pyx_t_28 = 0; __pyx_t_28 = __Pyx_PyUnicode_Join(__pyx_t_18, 4, __pyx_t_5, __pyx_t_17); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 751, __pyx_L76_error) __Pyx_GOTREF(__pyx_t_28); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+0752: ) from e
__Pyx_Raise(__pyx_t_18, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __PYX_ERR(0, 750, __pyx_L76_error) }
+0753: elif inner_type is Any:
__Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_Any); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_4 = (__pyx_v_inner_type == __pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_4) { /* … */ }
0754: # If no type is specified, return the list as-is
+0755: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0756: else:
+0757: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 757, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { 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, 757, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 757, __pyx_L1_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); #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, 757, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 757, __pyx_L1_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); #endif } } else { __pyx_t_11 = __pyx_t_6(__pyx_t_12); if (unlikely(!__pyx_t_11)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 757, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_11); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_11); __pyx_t_11 = 0; /* … */ } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_L11:;
+0758: result.append(
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_11); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0759: _parse_typing(field, T=inner_type, data=item, encoder=encoder, as_objects=False)
__pyx_t_34.__pyx_n = 2; __pyx_t_34.encoder = __pyx_v_encoder; __pyx_t_34.as_objects = Py_False; __pyx_t_11 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, &__pyx_t_34); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11);
0760: )
+0761: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0762:
+0763: cdef object _parse_tuple_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_tuple_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_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_tuple_type *__pyx_cur_scope; PyObject *__pyx_v_result = 0; PyObject *__pyx_v_converted_elements = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_item_type = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_gb_9datamodel_10converters_17_parse_tuple_type_2generator = 0; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_tuple_type *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_tuple_type(__pyx_ptype_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_tuple_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_tuple_type *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 763, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __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); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_AddTraceback("datamodel.converters._parse_tuple_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_converted_elements); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_item_type); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_17_parse_tuple_type_2generator); __Pyx_XDECREF(__pyx_v_data); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct____pyx_f_9datamodel_10converters__parse_tuple_type { PyObject_HEAD PyObject *__pyx_v_element_type; PyObject *__pyx_v_encoder; PyObject *__pyx_v_field; };
0764: object field,
0765: object T,
0766: object data,
0767: object encoder,
0768: object args
0769: ):
0770: """
0771: Parse a tuple of items to their respective types.
0772: Handles both heterogeneous tuples (Tuple[T1, T2, ...]) and
0773: homogeneous tuples (Tuple[T, ...])
0774: """
+0775: cdef tuple result = ()
__Pyx_INCREF(__pyx_empty_tuple);
__pyx_v_result = __pyx_empty_tuple;
0776:
0777: # Handle empty data
+0778: if data is None:
__pyx_t_1 = (__pyx_v_data == Py_None); if (__pyx_t_1) { /* … */ }
+0779: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
0780:
0781: # Ensure data is in tuple form
+0782: if not isinstance(data, (list, tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_data); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_data); __pyx_t_1 = __pyx_t_2; __pyx_L5_bool_binop_done:; __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0783: data = (data,)
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data)) __PYX_ERR(0, 783, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
0784:
0785: # Check for homogeneous tuple with ellipsis: Tuple[T, ...]
+0786: if len(args) == 2 and args[1] is Ellipsis:
__pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 786, __pyx_L1_error) __pyx_t_1 = (__pyx_t_4 == 2); if (__pyx_t_1) { } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L8_bool_binop_done; } __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = (__pyx_t_3 == __pyx_builtin_Ellipsis); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_1; __pyx_L8_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L7; }
0787: # All elements should be of type args[0]
+0788: element_type = args[0]
__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, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_element_type = __pyx_t_3; __pyx_t_3 = 0;
+0789: result = tuple(
__pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
+0790: _parse_builtin_type(field, element_type, item, encoder)
static PyObject *__pyx_pf_9datamodel_10converters_17_parse_tuple_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, 790, __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_tuple_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_17_parse_tuple_type_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_parse_tuple_type_locals_genexpr, __pyx_n_s_datamodel_converters); if (unlikely(!gen)) __PYX_ERR(0, 790, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("datamodel.converters._parse_tuple_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_tuple_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, 790, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 790, __pyx_L1_error) } __pyx_t_5 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_5); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_element_type)) { __Pyx_RaiseClosureNameError("element_type"); __PYX_ERR(0, 790, __pyx_L1_error) } __pyx_t_6 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_element_type; __Pyx_INCREF(__pyx_t_6); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_encoder)) { __Pyx_RaiseClosureNameError("encoder"); __PYX_ERR(0, 790, __pyx_L1_error) } __pyx_t_7 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_7); __pyx_t_10 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_t_5, __pyx_t_6, __pyx_cur_scope->__pyx_v_item, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __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; __pyx_t_4 = __pyx_t_10; __pyx_t_10 = 0; } else { /* … */ /* 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_XDECREF(__pyx_t_10); __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_17_parse_tuple_type_genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ 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_tuple_type *__pyx_outer_scope; PyObject *__pyx_genexpr_arg_0; PyObject *__pyx_v_item; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
+0791: if is_primitive(element_type) else
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_element_type)) { __Pyx_RaiseClosureNameError("element_type"); __PYX_ERR(0, 791, __pyx_L1_error) } __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_cur_scope->__pyx_outer_scope->__pyx_v_element_type}; __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, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) {
+0792: _parse_type(field, element_type, item, encoder, False)
if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 792, __pyx_L1_error) } __pyx_t_10 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_10); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_element_type)) { __Pyx_RaiseClosureNameError("element_type"); __PYX_ERR(0, 792, __pyx_L1_error) } __pyx_t_7 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_element_type; __Pyx_INCREF(__pyx_t_7); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_encoder)) { __Pyx_RaiseClosureNameError("encoder"); __PYX_ERR(0, 792, __pyx_L1_error) } __pyx_t_6 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_6); __pyx_t_11.__pyx_n = 2; __pyx_t_11.encoder = __pyx_t_6; __pyx_t_11.as_objects = Py_False; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_type(__pyx_t_10, __pyx_t_7, __pyx_cur_scope->__pyx_v_item, &__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 792, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } __pyx_r = __pyx_t_4; __pyx_t_4 = 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, 790, __pyx_L1_error)
+0793: for item in data
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 793, __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, 793, __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, 793, __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, 793, __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, 793, __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, 793, __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, 793, __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, 793, __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, 793, __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, 793, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
0794: )
0795: # Handle heterogeneous tuple: Tuple[T1, T2, ...]
+0796: elif len(args) > 0:
__pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 796, __pyx_L1_error) __pyx_t_2 = (__pyx_t_4 > 0); if (__pyx_t_2) { /* … */ goto __pyx_L7; }
0797: # Validate tuple length
+0798: if len(data) != len(args):
__pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 798, __pyx_L1_error) __pyx_t_6 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 798, __pyx_L1_error) __pyx_t_2 = (__pyx_t_4 != __pyx_t_6); if (unlikely(__pyx_t_2)) { /* … */ }
+0799: raise ValueError(
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 799, __pyx_L1_error)
+0800: f"Tuple length mismatch for {field.name}: expected {len(args)}, got {len(data)}"
__pyx_t_5 = PyTuple_New(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_Tuple_length_mismatch_for); __pyx_t_6 += 26; __Pyx_GIVEREF(__pyx_kp_u_Tuple_length_mismatch_for); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Tuple_length_mismatch_for); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u_expected); __pyx_t_6 += 11; __Pyx_GIVEREF(__pyx_kp_u_expected); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_expected); __pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 800, __pyx_L1_error) __pyx_t_8 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_4, 0, ' ', 'd'); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u_got); __pyx_t_6 += 6; __Pyx_GIVEREF(__pyx_kp_u_got); PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_kp_u_got); __pyx_t_4 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 800, __pyx_L1_error) __pyx_t_8 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_4, 0, ' ', 'd'); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_5, 6, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
0801: )
0802:
0803: # Convert each element according to its type
+0804: converted_elements = []
__pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_converted_elements = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0805: for i, (item_type, item) in enumerate(zip(args, data)):
__Pyx_INCREF(__pyx_int_0); __pyx_t_5 = __pyx_int_0; __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_args); __Pyx_GIVEREF(__pyx_v_args); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_args)) __PYX_ERR(0, 805, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_data)) __PYX_ERR(0, 805, __pyx_L1_error); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_8 = __pyx_t_3; __Pyx_INCREF(__pyx_t_8); __pyx_t_6 = 0; __pyx_t_9 = NULL; } else { __pyx_t_6 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 805, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_8))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_8); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 805, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 805, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 805, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 805, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_8); 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, 805, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; 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, 805, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_10 = PyList_GET_ITEM(sequence, 0); __pyx_t_11 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); #else __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L13_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed; __Pyx_GOTREF(__pyx_t_11); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) __PYX_ERR(0, 805, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L14_unpacking_done; __pyx_L13_unpacking_failed:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 805, __pyx_L1_error) __pyx_L14_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_item_type, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5); __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0806: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L22_try_end; __pyx_L15_error:; __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; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L17_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L1_error; __pyx_L22_try_end:; }
+0807: if is_primitive(item_type):
__Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 807, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = NULL; __pyx_t_17 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_17 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_item_type}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_17, 1+__pyx_t_17); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 807, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 807, __pyx_L15_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L23; }
+0808: converted_elements.append(_parse_builtin_type(field, item_type, item, encoder))
__pyx_t_3 = __pyx_cur_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_3); __pyx_t_11 = __pyx_cur_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_11); __pyx_t_10 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_t_3, __pyx_v_item_type, __pyx_v_item, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 808, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_converted_elements, __pyx_t_10); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 808, __pyx_L15_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
0809: else:
+0810: converted_elements.append(_parse_type(field, item_type, item, encoder, False))
/*else*/ { __pyx_t_10 = __pyx_cur_scope->__pyx_v_field; __Pyx_INCREF(__pyx_t_10); __pyx_t_11 = __pyx_cur_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_11); __pyx_t_19.__pyx_n = 2; __pyx_t_19.encoder = __pyx_t_11; __pyx_t_19.as_objects = Py_False; __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_type(__pyx_t_10, __pyx_v_item_type, __pyx_v_item, &__pyx_t_19); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 810, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_converted_elements, __pyx_t_3); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 810, __pyx_L15_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L23:;
+0811: except Exception as e:
__pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_20) { __Pyx_AddTraceback("datamodel.converters._parse_tuple_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_11, &__pyx_t_10) < 0) __PYX_ERR(0, 811, __pyx_L17_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_10); __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_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_28, &__pyx_t_29, &__pyx_t_30); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27) < 0)) __Pyx_ErrFetch(&__pyx_t_25, &__pyx_t_26, &__pyx_t_27); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_26); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_30); __pyx_t_20 = __pyx_lineno; __pyx_t_23 = __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_28); __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_30); __Pyx_ExceptionReset(__pyx_t_28, __pyx_t_29, __pyx_t_30); } __Pyx_XGIVEREF(__pyx_t_25); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ErrRestore(__pyx_t_25, __pyx_t_26, __pyx_t_27); __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_lineno = __pyx_t_20; __pyx_clineno = __pyx_t_23; __pyx_filename = __pyx_t_24; goto __pyx_L17_except_error; } } } goto __pyx_L17_except_error;
+0812: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_22); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 812, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 812, __pyx_L29_error) }
+0813: f"Error parsing tuple element {i} of {field.name}: {e}"
__pyx_t_12 = PyTuple_New(6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 813, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_4 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_tuple_element); __pyx_t_4 += 28; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_tuple_element); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Error_parsing_tuple_element); __pyx_t_21 = __Pyx_PyObject_FormatSimple(__pyx_v_i, __pyx_empty_unicode); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 813, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_7; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u_of); __pyx_t_4 += 4; __Pyx_GIVEREF(__pyx_kp_u_of); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_kp_u_of); __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 813, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_22 = __Pyx_PyObject_FormatSimple(__pyx_t_21, __pyx_empty_unicode); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 813, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) : __pyx_t_7; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_22); __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_22); __pyx_t_22 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_4 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_kp_u__7); __pyx_t_22 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 813, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) : __pyx_t_7; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_22); __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_22); __pyx_t_22 = 0; __pyx_t_22 = __Pyx_PyUnicode_Join(__pyx_t_12, 6, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 813, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
0814: )
0815:
+0816: result = tuple(converted_elements)
__pyx_t_5 = PyList_AsTuple(__pyx_v_converted_elements); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
0817: else:
0818: # No type args, just return the tuple
+0819: result = tuple(data)
/*else*/ { __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; } __pyx_L7:;
0820:
+0821: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0822:
+0823: 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; }
+0824: if isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0825: 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, 825, __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, 825, __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, 825, __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, 825, __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;
+0826: 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) { /* … */ }
+0827: return T(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 827, __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, 827, __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;
0828: else:
+0829: 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, 829, __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; }
0830:
+0831: 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; }
+0832: if encoder is not None:
__pyx_t_1 = (__pyx_v_encoder != Py_None); if (__pyx_t_1) { /* … */ }
+0833: 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; }
+0834: 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, 834, __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;
+0835: 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, 835, __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;
+0836: raise ValueError(f"Error parsing type {T}, {e}")
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 836, __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, 836, __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, 836, __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, 836, __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, 836, __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, 836, __pyx_L15_error) }
+0837: 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, 837, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 837, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0838: 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, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0839: if T == int:
__pyx_t_7 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 839, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0840: return to_integer(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __pyx_f_9datamodel_10converters_to_integer(__pyx_v_data, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0841: if T == float:
__pyx_t_7 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 841, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 841, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0842: return to_float(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __pyx_f_9datamodel_10converters_to_float(__pyx_v_data, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0843: 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, 843, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 843, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0844: 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, 844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0845: 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, 845, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 845, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0846: 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, 846, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0847: if T == UUID:
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_UUID); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 847, __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, 847, __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, 847, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { /* … */ }
+0848: 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, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0849: 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, 849, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0850: 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, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0851: elif T == Path:
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyObject_RichCompare(__pyx_v_T, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 851, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 851, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0852: if isinstance(data, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0853: return Path(data)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __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, __pyx_v_data}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0854: elif isinstance(data, Path):
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 854, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyObject_IsInstance(__pyx_v_data, __pyx_t_7); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 854, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0855: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0856: else:
+0857: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L28_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_L30_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_L32_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; } }
+0858: return Path(str(data))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 858, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_Unicode(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 858, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_5}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 858, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L32_try_return;
+0859: except:
/*except:*/ { __Pyx_AddTraceback("datamodel.converters._parse_builtin_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 859, __pyx_L30_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+0860: raise ValueError(f"Cannot convert {data} to Path")
__pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 860, __pyx_L30_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Cannot_convert); __pyx_t_11 += 15; __Pyx_GIVEREF(__pyx_kp_u_Cannot_convert); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Cannot_convert); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_data, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 860, __pyx_L30_except_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_to_Path); __pyx_t_11 += 8; __Pyx_GIVEREF(__pyx_kp_u_to_Path); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_to_Path); __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 860, __pyx_L30_except_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, 860, __pyx_L30_except_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, 860, __pyx_L30_except_error) }
+0861: elif T == dict:
__pyx_t_5 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 861, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_1) { /* … */ }
+0862: if not isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
__pyx_t_22 = (!__pyx_t_1);
if (unlikely(__pyx_t_22)) {
/* … */
}
+0863: raise ValueError(
__pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 863, __pyx_L1_error)
+0864: f"Expected dict, got {type(data).__name__}"
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expected_dict_got, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0865: )
+0866: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0867: elif T == list:
__pyx_t_6 = PyObject_RichCompare(__pyx_v_T, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 867, __pyx_L1_error) __pyx_t_22 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_22 < 0))) __PYX_ERR(0, 867, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_22) { /* … */ }
+0868: 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_L38_bool_binop_done; } __pyx_t_1 = PyTuple_Check(__pyx_v_data); __pyx_t_22 = __pyx_t_1; __pyx_L38_bool_binop_done:; __pyx_t_1 = (!__pyx_t_22); if (__pyx_t_1) { /* … */ }
+0869: data = [data]
__pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_data)) __PYX_ERR(0, 869, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_6); __pyx_t_6 = 0;
+0870: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0871: else:
0872: # Try encoders dict:
+0873: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L40_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_L42_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_L44_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_L43_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; } }
+0874: if field._encoder_fn is None:
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_encoder_fn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 874, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = (__pyx_t_6 == Py_None); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { /* … */ }
+0875: field._encoder_fn = encoders[T]
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_encoders); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 875, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_v_T); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 875, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_encoder_fn, __pyx_t_5) < 0) __PYX_ERR(0, 875, __pyx_L40_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0876: return field._encoder_fn(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_encoder_fn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L40_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_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, 876, __pyx_L40_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_L44_try_return;
+0877: 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_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 877, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
0878: # attempt direct construction:
+0879: if isinstance(T, type):
__pyx_t_1 = PyType_Check(__pyx_v_T);
if (__pyx_t_1) {
/* … */
}
+0880: 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_L57_try_end; __pyx_L50_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_L52_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_L42_except_error; __pyx_L54_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_L43_except_return; __pyx_L51_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_L57_try_end:; }
+0881: if isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0882: 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, 882, __pyx_L50_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_10 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 882, __pyx_L50_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, 882, __pyx_L50_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, 882, __pyx_L50_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_L54_try_return;
+0883: 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_L59_bool_binop_done; } __pyx_t_22 = PyTuple_Check(__pyx_v_data); __pyx_t_1 = __pyx_t_22; __pyx_L59_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0884: return T(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 884, __pyx_L50_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, 884, __pyx_L50_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_L54_try_return;
+0885: elif isinstance(data, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0886: 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, 886, __pyx_L50_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_L54_try_return;
+0887: 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_L51_exception_handled;
}
goto __pyx_L52_except_error;
0888: pass
+0889: 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_L43_except_return; }
+0890: 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_7, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 890, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_v_e = __pyx_t_6; /*try:*/ { /* … */ /*finally:*/ { __pyx_L66_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_L42_except_error; } } }
+0891: raise TypeError(f"Error type {T}: {e}") from e
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 891, __pyx_L66_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, 891, __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, 891, __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, 891, __pyx_L66_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, 891, __pyx_L66_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, 891, __pyx_L66_error) }
+0892: 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, 892, __pyx_L42_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_L77_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_L42_except_error; } } } goto __pyx_L42_except_error;
+0893: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 893, __pyx_L77_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+0894: f"Error parsing type {T}: {e}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 894, __pyx_L77_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, 894, __pyx_L77_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, 894, __pyx_L77_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, 894, __pyx_L77_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0895: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 893, __pyx_L77_error) }
0896:
+0897: 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, 897, __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, 897, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_basic", 0, 2, 3, 1); __PYX_ERR(0, 897, __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, 897, __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, 897, __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, 897, __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, 897, __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_2generator1(__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, 897, __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, 897, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 897, __pyx_L1_error) /* … */ __pyx_t_3 = __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_3)) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_tuple__45); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_basic, __pyx_t_3) < 0) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_tuple__45 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 897, __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; };
0898: """parse_basic.
0899:
0900: Parse a value to primitive types as str or int.
0901: --- (int, float, str, bool, bytes)
0902: """
+0903: 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, 903, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 903, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0904: if isinstance(data, str):
__pyx_t_2 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0905: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0906: elif data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0907: return str(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_Unicode(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0908: 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, 908, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 908, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0909: if isinstance(data, int):
__pyx_t_2 = PyInt_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0910: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0911: elif data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0912: return int(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0913: 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, 913, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 913, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0914: if data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0915: 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, 915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0916: if T == UUID or T == pgproto.UUID:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 916, __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, 916, __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, 916, __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, 916, __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, 916, __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, 916, __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, 916, __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) { /* … */ }
+0917: 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, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+0918: 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, 918, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 918, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0919: 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, 919, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0920: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0921: # function encoder:
+0922: if encoder:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 922, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+0923: 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, 923, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
0924: # using a function encoder:
+0925: 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; }
+0926: 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, 926, __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;
+0927: 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, 927, __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; } } }
+0928: raise TypeError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 928, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0929: 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, 929, __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, 929, __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, 929, __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, 929, __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, 929, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0930: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 928, __pyx_L27_error) }
+0931: 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, 931, __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; } } }
+0932: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 932, __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, 932, __pyx_L38_error) }
+0933: f"Error parsing type {T}, {e}"
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 933, __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, 933, __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, 933, __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, 933, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0934: )
+0935: 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, 935, __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;
+0936: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+0937: 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;
+0938: raise AttributeError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 938, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0939: 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, 939, __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, 939, __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, 939, __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, 939, __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, 939, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0940: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 938, __pyx_L49_error) }
0941: # Using the encoders for basic types:
+0942: 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); }
+0943: 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, 943, __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, 943, __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, 943, __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;
+0944: 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; }
0945: pass
+0946: 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, 946, __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; } } }
+0947: raise TypeError(f"Error type {T}: {e}") from e
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 947, __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, 947, __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, 947, __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, 947, __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, 947, __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, 947, __pyx_L67_error) }
+0948: 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, 948, __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;
+0949: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 949, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0950: f"Error parsing type {T}: {e}"
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 950, __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, 950, __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, 950, __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, 950, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0951: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 949, __pyx_L78_error) }
0952:
0953:
+0954: 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_2___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_v_error); __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_v); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator1); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator2); __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_2___pyx_f_9datamodel_10converters__parse_typing_type { PyObject_HEAD PyObject *__pyx_v_encoder; PyObject *__pyx_v_field; PyObject *__pyx_v_type_args; };
0955: object field,
0956: object T,
0957: object name,
0958: object data,
0959: object encoder,
0960: object origin,
0961: object args,
+0962: object as_objects=False
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False); PyObject *__pyx_v_error = NULL; PyObject *__pyx_8genexpr1__pyx_v_k = NULL; PyObject *__pyx_8genexpr1__pyx_v_v = NULL; PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_2generator1 = 0; PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator2 = 0; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2___pyx_f_9datamodel_10converters__parse_typing_type *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_2___pyx_f_9datamodel_10converters__parse_typing_type(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_2___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_2___pyx_f_9datamodel_10converters__parse_typing_type *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 954, __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);
0963: ):
0964: """
0965: Handle field_type='typing' scenario.
0966: """
+0967: 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, 967, __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, 967, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_type_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
0968:
+0969: 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, 969, __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, 969, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 969, __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, 969, __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, 969, __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, 969, __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, 969, __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, 969, __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) { /* … */ }
+0970: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (likely(__pyx_t_2)) {
/* … */
}
+0971: 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) {
/* … */
}
0972: # e.g. Dict[K, V]
+0973: 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, 973, __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, 973, __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, 973, __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, 973, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_k, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr1__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, 973, __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, 973, __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_8genexpr1__pyx_v_v, &__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 973, __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_8genexpr1__pyx_v_k, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 973, __pyx_L14_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_k); __pyx_8genexpr1__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_v); __pyx_8genexpr1__pyx_v_v = 0; goto __pyx_L17_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_k); __pyx_8genexpr1__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_v); __pyx_8genexpr1__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;
+0974: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0975: else:
+0976: 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); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 976, __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, 976, __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, 976, __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, 976, __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, 976, __pyx_L1_error) }
0977:
+0978: if field.origin is tuple or name == 'Tuple' or field.origin == tuple:
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = (__pyx_t_6 == ((PyObject *)(&PyTuple_Type))); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L19_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_name, __pyx_n_u_Tuple, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 978, __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, 978, __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, 978, __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, 978, __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) { /* … */ }
+0979: 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_L23_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_3; __pyx_L23_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0980: if len(type_args) == 2 and type_args[1] is Ellipsis:
__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, 980, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 980, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_8 == 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, 980, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_type_args, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = (__pyx_t_1 == __pyx_builtin_Ellipsis); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L26_bool_binop_done:; if (__pyx_t_2) { /* … */ }
0981: # Homogeneous tuple: e.g. Tuple[float, ...]
+0982: return tuple(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 982, __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;
+0983: _parse_type(field, type_args[0], datum, None, 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_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, 983, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2___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_2generator1, 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, 983, __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_2generator1(__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, 983, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 983, __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, 983, __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, 983, __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, 983, __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, 983, __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, 983, __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; } static PyObject *__pyx_gb_9datamodel_10converters_18_parse_typing_type_5generator2(__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_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_3_genexpr { PyObject_HEAD struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2___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 *); };
+0984: for datum in data
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 984, __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, 984, __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, 984, __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, 984, __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, 984, __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, 984, __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, 984, __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, 984, __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, 984, __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, 984, __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);
0985: )
+0986: elif 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, 986, __pyx_L1_error) __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, 986, __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, 986, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = (__pyx_t_8 == __pyx_t_7); if (__pyx_t_2) { /* … */ }
0987: # Heterogeneous tuple: Convert each element to its corresponding type
+0988: return tuple(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 988, __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;
+0989: _parse_type(field, typ, datum, encoder, 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_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, 989, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2___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_5generator2, 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, 989, __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_5generator2(__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, 989, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 989, __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, 989, __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, 989, __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, 989, __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; } /* … */ __pyx_t_6 = __pyx_pf_9datamodel_10converters_18_parse_typing_type_3genexpr(((PyObject*)__pyx_cur_scope), __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_4_genexpr { PyObject_HEAD struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_2___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 *); };
+0990: for typ, datum in zip(type_args, data)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __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, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 990, __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, 990, __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, 990, __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, 990, __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_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __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_6, 0, __pyx_cur_scope->__pyx_v_type_args)) __PYX_ERR(0, 990, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_data)) __PYX_ERR(0, 990, __pyx_L1_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0991: )
+0992: elif len(type_args) > 0:
__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, 992, __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, 992, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = (__pyx_t_7 > 0); if (unlikely(__pyx_t_2)) { /* … */ }
0993: # Length mismatch but we have type arguments - try to convert what we can
+0994: error = f"Tuple length mismatch for {field.name}: expected {len(type_args)}, got {len(data)}"
__pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Tuple_length_mismatch_for); __pyx_t_7 += 26; __Pyx_GIVEREF(__pyx_kp_u_Tuple_length_mismatch_for); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Tuple_length_mismatch_for); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_t_6, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u_expected); __pyx_t_7 += 11; __Pyx_GIVEREF(__pyx_kp_u_expected); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_expected); __pyx_t_12 = __pyx_cur_scope->__pyx_v_type_args; __Pyx_INCREF(__pyx_t_12); if (unlikely(__pyx_t_12 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 994, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyTuple_GET_SIZE(__pyx_t_12); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_8, 0, ' ', 'd'); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u_got); __pyx_t_7 += 6; __Pyx_GIVEREF(__pyx_kp_u_got); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_got); __pyx_t_8 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 994, __pyx_L1_error) __pyx_t_12 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_8, 0, ' ', 'd'); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_7, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_error = ((PyObject*)__pyx_t_12); __pyx_t_12 = 0;
+0995: raise ValueError(error)
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 995, __pyx_L1_error)
0996: # If we can't process it, just return as-is
+0997: return tuple(data) if not isinstance(data, tuple) else data
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_Check(__pyx_v_data); __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __pyx_t_1; __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_v_data); __pyx_t_12 = __pyx_v_data; } __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0;
0998:
+0999: if name in {'List', 'Sequence'} or field.origin in {list, Sequence}:
__Pyx_INCREF(__pyx_v_name); __pyx_t_12 = __pyx_v_name; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_List, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 999, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_2 = __pyx_t_5; goto __pyx_L31_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_n_u_Sequence, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 999, __pyx_L1_error) __pyx_t_2 = __pyx_t_5; __pyx_L31_bool_binop_done:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_5 = __pyx_t_2; if (!__pyx_t_5) { } else { __pyx_t_3 = __pyx_t_5; goto __pyx_L29_bool_binop_done; } __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_1 = PyObject_RichCompare(__pyx_t_12, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 999, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_2) { } else { __pyx_t_5 = __pyx_t_2; goto __pyx_L33_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_t_12, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __pyx_t_2; __pyx_L33_bool_binop_done:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_2 = __pyx_t_5; __pyx_t_3 = __pyx_t_2; __pyx_L29_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1000: if not isinstance(data, (list, tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_data); if (!__pyx_t_2) { } else { __pyx_t_3 = __pyx_t_2; goto __pyx_L36_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_data); __pyx_t_3 = __pyx_t_2; __pyx_L36_bool_binop_done:; __pyx_t_2 = (!__pyx_t_3); if (__pyx_t_2) { /* … */ }
+1001: data = [data]
__pyx_t_12 = PyList_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_12, 0, __pyx_v_data)) __PYX_ERR(0, 1001, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_12); __pyx_t_12 = 0;
+1002: return _parse_list_typing(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_15.__pyx_n = 1; __pyx_t_15.as_objects = __pyx_v_as_objects; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_list_typing(__pyx_t_12, ((PyObject*)__pyx_t_6), __pyx_v_data, __pyx_t_1, __pyx_v_origin, __pyx_v_args, &__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+1003: field,
__pyx_t_12 = __pyx_cur_scope->__pyx_v_field;
__Pyx_INCREF(__pyx_t_12);
+1004: type_args,
__pyx_t_6 = __pyx_cur_scope->__pyx_v_type_args;
__Pyx_INCREF(__pyx_t_6);
1005: data,
+1006: encoder,
__pyx_t_1 = __pyx_cur_scope->__pyx_v_encoder;
__Pyx_INCREF(__pyx_t_1);
1007: origin,
1008: args,
1009: as_objects=as_objects
1010: )
1011:
1012: # handle None, Optional, Union:
+1013: if name is None or name in ('Optional', 'Union'):
__pyx_t_3 = (__pyx_v_name == Py_None); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; 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, 1013, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_3 = __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, 1013, __pyx_L1_error) __pyx_t_3 = __pyx_t_5; __pyx_L41_bool_binop_done:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __pyx_t_3; __pyx_t_2 = __pyx_t_5; __pyx_L39_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1014: 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_1 = __pyx_cur_scope->__pyx_v_encoder; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = __pyx_f_9datamodel_10converters__parse_optional_union(__pyx_t_4, __pyx_v_T, __pyx_v_data, __pyx_t_1, __pyx_v_origin, __pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
1015:
+1016: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1017:
+1018: 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; PyObject *__pyx_v_processed_sublist = 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_inner_type = NULL; PyObject *__pyx_v_sublist = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_v_processed_item = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_a = 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_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __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_processed_sublist); __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_inner_type); __Pyx_XDECREF(__pyx_v_sublist); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_processed_item); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_a); __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; };
1019: object field,
1020: tuple type_args,
1021: object data,
1022: object encoder,
1023: object origin,
1024: object args,
1025: object as_objects=False,
1026: dict typeinfo=None
1027: ):
1028: """
1029: Handle List[T] logic, trying to reduce overhead from repeated lookups.
1030: """
+1031: cdef list result = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1031, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1032: cdef list processed_sublist = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_processed_sublist = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1033: cdef list out = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_out = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1034: 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, 1034, __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, 1034, __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;
+1035: 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, 1035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_module = __pyx_t_1; __pyx_t_1 = 0;
+1036: 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, 1036, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_is_nested_typing = __pyx_t_2;
1037:
1038: # If no type args, we can't proceed with further logic
+1039: 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) {
/* … */
}
+1040: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1041:
+1042: if is_nested_typing:
if (__pyx_v_is_nested_typing) { /* … */ }
1043: # nested typing: e.g. List[List[Foo]] or List[Optional[Foo]] etc.
+1044: try:
{ /*try:*/ { /* … */ } __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __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_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; }
+1045: 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, 1045, __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, 1045, __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;
+1046: 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, 1046, __pyx_L5_error) if (__pyx_t_4) { /* … */ }
+1047: 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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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, 1047, __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;
+1048: 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, 1048, __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, 1048, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1049: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
+1050: elif field._inner_origin is list:
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1050, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = (__pyx_t_3 == ((PyObject *)(&PyList_Type))); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { /* … */ }
+1051: inner_type = subT
__Pyx_INCREF(__pyx_v_subT);
__pyx_v_inner_type = __pyx_v_subT;
+1052: for sublist 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, 1052, __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, 1052, __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, 1052, __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, 1052, __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, 1052, __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, 1052, __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, 1052, __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, 1052, __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, 1052, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_sublist, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1053: if not isinstance(sublist, (list, tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_sublist); if (!__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L18_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_sublist); __pyx_t_4 = __pyx_t_2; __pyx_L18_bool_binop_done:; __pyx_t_2 = (!__pyx_t_4); if (__pyx_t_2) { /* … */ }
1054: # Convert single items to lists if needed
+1055: sublist = [sublist]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_sublist); __Pyx_GIVEREF(__pyx_v_sublist); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_sublist)) __PYX_ERR(0, 1055, __pyx_L5_error); __Pyx_DECREF_SET(__pyx_v_sublist, __pyx_t_1); __pyx_t_1 = 0;
+1056: processed_sublist = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_processed_sublist, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+1057: for item in sublist:
if (likely(PyList_CheckExact(__pyx_v_sublist)) || PyTuple_CheckExact(__pyx_v_sublist)) { __pyx_t_1 = __pyx_v_sublist; __Pyx_INCREF(__pyx_t_1); __pyx_t_11 = 0; __pyx_t_12 = NULL; } else { __pyx_t_11 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_sublist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1057, __pyx_L5_error) } for (;;) { if (likely(!__pyx_t_12)) { 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, 1057, __pyx_L5_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_13 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_11); __Pyx_INCREF(__pyx_t_13); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 1057, __pyx_L5_error) #else __pyx_t_13 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1057, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); #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, 1057, __pyx_L5_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_11); __Pyx_INCREF(__pyx_t_13); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 1057, __pyx_L5_error) #else __pyx_t_13 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1057, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); #endif } } else { __pyx_t_13 = __pyx_t_12(__pyx_t_1); if (unlikely(!__pyx_t_13)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1057, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_13); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_13); __pyx_t_13 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1058: # Convert each item to the expected inner type
+1059: if is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1059, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = NULL; __pyx_t_16 = 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_16 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_v_inner_type}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_16, 1+__pyx_t_16); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1059, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1059, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L22; }
+1060: if inner_type == int and isinstance(item, str):
__pyx_t_13 = PyObject_RichCompare(__pyx_v_inner_type, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1060, __pyx_L5_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1060, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L24_bool_binop_done; } __pyx_t_4 = PyUnicode_Check(__pyx_v_item); __pyx_t_2 = __pyx_t_4; __pyx_L24_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L23; }
+1061: processed_sublist.append(int(item))
__pyx_t_13 = __Pyx_PyNumber_Int(__pyx_v_item); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1061, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_processed_sublist, __pyx_t_13); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1061, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+1062: elif inner_type == float and isinstance(item, str):
__pyx_t_13 = PyObject_RichCompare(__pyx_v_inner_type, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1062, __pyx_L5_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1062, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L26_bool_binop_done; } __pyx_t_4 = PyUnicode_Check(__pyx_v_item); __pyx_t_2 = __pyx_t_4; __pyx_L26_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L23; }
+1063: processed_sublist.append(float(item))
__pyx_t_13 = __Pyx_PyNumber_Float(__pyx_v_item); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1063, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_processed_sublist, __pyx_t_13); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1063, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1064: else:
+1065: processed_sublist.append(item)
/*else*/ { __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_processed_sublist, __pyx_v_item); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1065, __pyx_L5_error) } __pyx_L23:;
1066: else:
+1067: processed_sublist.append(_parse_type(field, inner_type, item, encoder, False))
/*else*/ { __pyx_t_17.__pyx_n = 2; __pyx_t_17.encoder = __pyx_v_encoder; __pyx_t_17.as_objects = Py_False; __pyx_t_13 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, &__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1067, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_processed_sublist, __pyx_t_13); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1067, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_L22:;
+1068: result.append(processed_sublist)
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_processed_sublist); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1068, __pyx_L5_error)
+1069: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
1070: # Handle List[Optional[T]] or List[Union[...]]
+1071: elif field._inner_origin is Union:
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1071, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Union); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1071, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__pyx_t_3 == __pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+1072: for item in data:
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_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1072, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1072, __pyx_L5_error) } for (;;) { if (likely(!__pyx_t_9)) { 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, 1072, __pyx_L5_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1072, __pyx_L5_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1072, __pyx_L5_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, 1072, __pyx_L5_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1072, __pyx_L5_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1072, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__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, 1072, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1073: processed_item = _parse_typing(field, arg_type, item, encoder, False)
__pyx_t_18.__pyx_n = 2; __pyx_t_18.encoder = __pyx_v_encoder; __pyx_t_18.as_objects = Py_False; __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_arg_type, __pyx_v_item, &__pyx_t_18); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1073, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_processed_item, __pyx_t_3); __pyx_t_3 = 0;
+1074: result.append(processed_item)
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_processed_item); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1074, __pyx_L5_error)
+1075: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
1076: else:
1077: # fallback
+1078: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L9_try_return; }
+1079: except AttributeError:
__pyx_t_19 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_19) { __Pyx_AddTraceback("datamodel.converters._parse_list_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_13) < 0) __PYX_ERR(0, 1079, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_13);
+1080: 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_13); __pyx_t_13 = 0; goto __pyx_L8_except_return; } goto __pyx_L7_except_error;
+1081: elif arg_type is not None and is_dc(arg_type):
__pyx_t_4 = (__pyx_v_arg_type != Py_None); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L35_bool_binop_done; } __pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_arg_type); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1081, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L35_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1082: # build list of dataclasses
+1083: for d in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_13 = __pyx_v_data; __Pyx_INCREF(__pyx_t_13); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1083, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1083, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_13))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1083, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1083, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1083, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1083, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1083, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1083, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_13); 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, 1083, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+1084: result.append(_instantiate_dataclass(arg_type, d))
__pyx_t_3 = __pyx_f_9datamodel_10converters__instantiate_dataclass(__pyx_v_arg_type, __pyx_v_d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1084, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1085: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+1086: elif is_primitive(arg_type):
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_16 = 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_16 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_arg_type}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_16, 1+__pyx_t_16); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1086, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_2) { /* … */ }
1087: # For simple primitive types, don't create nested lists
+1088: result = []
__pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_13)); __pyx_t_13 = 0;
+1089: for item in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_13 = __pyx_v_data; __Pyx_INCREF(__pyx_t_13); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1089, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_13))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1089, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1089, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1089, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1089, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_13); 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, 1089, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1090: # Convert the item to the expected type
+1091: if arg_type == int and isinstance(item, str):
__pyx_t_3 = PyObject_RichCompare(__pyx_v_arg_type, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1091, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1091, __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_L43_bool_binop_done; } __pyx_t_4 = PyUnicode_Check(__pyx_v_item); __pyx_t_2 = __pyx_t_4; __pyx_L43_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L42; }
+1092: result.append(int(item))
__pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1092, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1093: elif arg_type == float and isinstance(item, str):
__pyx_t_3 = PyObject_RichCompare(__pyx_v_arg_type, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1093, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1093, __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_L45_bool_binop_done; } __pyx_t_4 = PyUnicode_Check(__pyx_v_item); __pyx_t_2 = __pyx_t_4; __pyx_L45_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L42; }
+1094: result.append(float(item))
__pyx_t_3 = __Pyx_PyNumber_Float(__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1094, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1095: elif arg_type == str:
__pyx_t_3 = PyObject_RichCompare(__pyx_v_arg_type, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1095, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1095, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L42; }
+1096: result.append(str(item))
__pyx_t_3 = __Pyx_PyObject_Unicode(__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1097: elif arg_type == bool:
__pyx_t_3 = PyObject_RichCompare(__pyx_v_arg_type, ((PyObject*)&PyBool_Type), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1097, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1097, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L42; }
+1098: result.append(to_boolean(item))
__pyx_t_3 = __pyx_f_9datamodel_10converters_to_boolean(__pyx_v_item, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1099: else:
+1100: result.append(item)
/*else*/ { __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1100, __pyx_L1_error) } __pyx_L42:;
+1101: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1102: else:
+1103: for item in data:
/*else*/ { if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_13 = __pyx_v_data; __Pyx_INCREF(__pyx_t_13); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1103, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_13))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1103, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1103, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1103, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1103, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_13); 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, 1103, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; }
+1104: if type(item) is arg_type:
__pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_v_item)) == __pyx_v_arg_type); if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1105: result.append(item)
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1105, __pyx_L1_error)
1106: else:
1107: # Convert the item to the expected type
+1108: a = _parse_type(field, arg_type, item, encoder, False)
/*else*/ { __pyx_t_17.__pyx_n = 2; __pyx_t_17.encoder = __pyx_v_encoder; __pyx_t_17.as_objects = Py_False; __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_item, &__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3); __pyx_t_3 = 0;
+1109: result.append(a)
__pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_a); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1109, __pyx_L1_error) } __pyx_L50:;
+1110: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1111:
+1112: 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_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
1113: """
1114: Helper for instantiating a dataclass.
1115: """
+1116: 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, 1116, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+1117: return val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_val); __pyx_r = __pyx_v_val; goto __pyx_L0;
+1118: if isinstance(val, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_val);
if (__pyx_t_1) {
/* … */
}
+1119: 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, 1119, __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, 1119, __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, 1119, __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, 1119, __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;
+1120: 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) { /* … */ }
+1121: return cls(*val)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1121, __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, 1121, __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;
1122: else:
+1123: 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, 1123, __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; }
1124:
+1125: 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_v_non_none_origin = NULL; PyObject *__pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator3 = 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_7); __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_v_non_none_origin); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_21_parse_optional_union_2generator3); __Pyx_XDECREF(__pyx_v_args); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
1126: object field,
1127: object T,
1128: object data,
1129: object encoder,
1130: object origin,
1131: object args
1132: ):
1133: """
1134: Handle Optional or Union logic.
1135: """
1136: cdef object non_none_arg
+1137: 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, 1137, __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, 1137, __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;
+1138: cdef bint matched = False
__pyx_v_matched = 0;
1139:
1140: # Safety check to avoid null pointer dereference
+1141: if args is None or len(args) == 0:
__pyx_t_4 = (__pyx_v_args == Py_None); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1141, __pyx_L1_error) __pyx_t_4 = (__pyx_t_5 == 0); __pyx_t_2 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1142: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1143:
1144: # Early exit for None values in Optional types
+1145: if data is None and type(None) in args:
__pyx_t_4 = (__pyx_v_data == Py_None); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L7_bool_binop_done; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_args, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1145, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1146: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1147:
+1148: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1148, __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, 1148, __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, 1148, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1148, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1148, __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, 1148, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1148, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_6(__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, 1148, __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;
+1149: if t is not type(None) and PyObject_IsInstance(data, t):
__pyx_t_4 = (__pyx_v_t != ((PyObject *)Py_TYPE(Py_None))); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L12_bool_binop_done; } __pyx_t_4 = PyObject_IsInstance(__pyx_v_data, __pyx_v_t); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1149, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L12_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1150: # For container types, we still need to process their contents
+1151: if t in (list, dict, set, tuple) or get_origin(t) in (list, dict, set, tuple):
__Pyx_INCREF(__pyx_v_t); __pyx_t_3 = __pyx_v_t; __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L17_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L17_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PySet_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L17_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PyTuple_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_4 = __pyx_t_8; __pyx_L17_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __pyx_t_4; if (!__pyx_t_8) { } else { __pyx_t_2 = __pyx_t_8; goto __pyx_L15_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_t}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!__pyx_t_4) { } else { __pyx_t_8 = __pyx_t_4; goto __pyx_L21_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!__pyx_t_4) { } else { __pyx_t_8 = __pyx_t_4; goto __pyx_L21_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PySet_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!__pyx_t_4) { } else { __pyx_t_8 = __pyx_t_4; goto __pyx_L21_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)(&PyTuple_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1151, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __pyx_t_4; __pyx_L21_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __pyx_t_8; __pyx_t_2 = __pyx_t_4; __pyx_L15_bool_binop_done:; if (__pyx_t_2) { goto __pyx_L14; }
1152: # Continue to process contents
1153: pass
1154: else:
+1155: return data
/*else*/ { __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; } __pyx_L14:;
1156:
1157: # e.g. Optional[T] is Union[T, NoneType]
+1158: 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, 1158, __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, 1158, __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, 1158, __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_L27_bool_binop_done; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_args, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1158, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L27_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1159: # Pick the non-None type (assumes only two types in the Union)
+1160: 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, 1160, __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, 1160, __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, 1160, __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;
+1161: if non_none_arg is None:
__pyx_t_2 = (__pyx_v_non_none_arg == Py_None); if (__pyx_t_2) { /* … */ }
1162: # If only None type is in the Union, return None
+1163: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+1164: non_none_origin = get_origin(non_none_arg)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_10 = 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_10 = 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_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_non_none_origin = __pyx_t_3; __pyx_t_3 = 0;
+1165: if non_none_origin is list:
__pyx_t_2 = (__pyx_v_non_none_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ }
1166: # Distinguish between typing.List and list
+1167: if 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, 1167, __pyx_L1_error) if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L32_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, 1167, __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, 1167, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __pyx_L32_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1168: # It's typing.List - use _parse_list_typing
+1169: return _parse_list_typing(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_11.__pyx_n = 1; __pyx_t_11.as_objects = Py_None; __pyx_t_7 = __pyx_f_9datamodel_10converters__parse_list_typing(__pyx_v_field, ((PyObject*)__pyx_t_3), __pyx_v_data, __pyx_v_encoder, __pyx_v_non_none_origin, __pyx_t_1, &__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
1170: field,
+1171: get_args(non_none_arg),
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_10 = 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_10 = 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_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1171, __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, 1171, __pyx_L1_error)
1172: data,
1173: encoder,
1174: non_none_origin,
+1175: get_args(non_none_arg),
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_get_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_non_none_arg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; }
1176: None
1177: )
1178: else:
1179: # It's a plain list - use _parse_list_type
+1180: return _parse_list_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_12.__pyx_n = 1; __pyx_t_12._parent = Py_None; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_non_none_arg, __pyx_v_data, __pyx_v_encoder, __pyx_t_7, &__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1180, __pyx_L1_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_L0; }
1181: field,
1182: non_none_arg,
1183: data,
1184: encoder,
+1185: get_args(non_none_arg),
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_non_none_arg}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
1186: None
1187: )
1188: else:
+1189: return _parse_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __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_non_none_arg, __pyx_v_data, &__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1190: field,
1191: T=non_none_arg,
1192: data=data,
1193: encoder=encoder,
1194: as_objects=False
1195: )
1196: # Remove None from args.
+1197: 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_5_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_5_genexpr *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_5_genexpr(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_5_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1197, __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_2generator3, 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, 1197, __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_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, 1197, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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, 1197, __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_1 = __pyx_pf_9datamodel_10converters_21_parse_optional_union_genexpr(NULL, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_args, __pyx_t_7); __pyx_t_7 = 0; /* … */ struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_5_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 *); };
1198: # If there are no non-None types left, simply return data.
+1199: if not args:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1199, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_2); if (__pyx_t_4) { /* … */ }
+1200: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1201:
+1202: for t in args:
if (likely(PyList_CheckExact(__pyx_v_args)) || PyTuple_CheckExact(__pyx_v_args)) { __pyx_t_7 = __pyx_v_args; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1202, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1202, __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_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1202, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1202, __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_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1202, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_7); 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, 1202, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L38_for_end; __pyx_L36_break:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L38_for_end; __pyx_L38_for_end:;
+1203: if isinstance(data, t):
__pyx_t_4 = PyObject_IsInstance(__pyx_v_data, __pyx_v_t); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1203, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+1204: matched = True
__pyx_v_matched = 1;
+1205: break
goto __pyx_L36_break;
+1206: if not matched:
__pyx_t_4 = (!__pyx_v_matched); if (unlikely(__pyx_t_4)) { /* … */ }
+1207: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 1207, __pyx_L1_error)
+1208: f"Invalid type for *{field.name}* with {type(data)}, expected {T}"
__pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for); __pyx_t_5 += 18; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Invalid_type_for); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_14; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_with); __pyx_t_5 += 7; __Pyx_GIVEREF(__pyx_kp_u_with); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u_with); __pyx_t_3 = __Pyx_PyObject_FormatSimple(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_14; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_expected_2); __pyx_t_5 += 11; __Pyx_GIVEREF(__pyx_kp_u_expected_2); PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_kp_u_expected_2); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_T, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_14; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_7, 6, __pyx_t_5, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1209: )
+1210: try:
{ /*try:*/ { /* … */ } __pyx_L40_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L42_except_error:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L1_error; __pyx_L44_try_return:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L0; __pyx_L41_exception_handled:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); }
+1211: if is_dc(t):
__pyx_t_4 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_t); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1211, __pyx_L40_error) if (__pyx_t_4) { /* … */ }
+1212: if isinstance(data, dict):
__pyx_t_4 = PyDict_Check(__pyx_v_data);
if (__pyx_t_4) {
/* … */
}
+1213: 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, 1213, __pyx_L40_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_7 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1213, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_7); } else { __pyx_t_7 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1213, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_7); } __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1213, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L44_try_return;
+1214: elif isinstance(data, (list, tuple)):
__pyx_t_2 = PyList_Check(__pyx_v_data); if (!__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L48_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_data); __pyx_t_4 = __pyx_t_2; __pyx_L48_bool_binop_done:; if (__pyx_t_4) { /* … */ }
+1215: return t(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1215, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_Call(__pyx_v_t, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1215, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L44_try_return;
1216: else:
+1217: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L50_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L52_except_error:; __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); goto __pyx_L40_error; __pyx_L54_try_return:; __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); goto __pyx_L44_try_return; __pyx_L53_except_return:; __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); goto __pyx_L44_try_return; } }
+1218: return t(data)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_t); __pyx_t_3 = __pyx_v_t; __pyx_t_1 = NULL; __pyx_t_10 = 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_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_data}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1218, __pyx_L50_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L54_try_return;
+1219: except Exception:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_21) { __Pyx_AddTraceback("datamodel.converters._parse_optional_union", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 1219, __pyx_L52_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1);
+1220: 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_7); __pyx_t_7 = 0; goto __pyx_L53_except_return; } goto __pyx_L52_except_error;
+1221: elif callable(t):
__pyx_t_4 = __Pyx_PyCallable_Check(__pyx_v_t); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1221, __pyx_L40_error) if (__pyx_t_4) { /* … */ }
+1222: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L44_try_return;
+1223: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L44_try_return;
+1224: except KeyError:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError); if (__pyx_t_21) { __Pyx_ErrRestore(0,0,0); goto __pyx_L41_exception_handled; } goto __pyx_L42_except_error;
1225: pass
+1226: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1227:
+1228: cdef object _parse_union_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_union_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_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_exc = NULL; PyObject *__pyx_v_subtype_origin = NULL; PyObject *__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator4 = 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_14); __Pyx_XDECREF(__pyx_t_15); __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_exc); __Pyx_XDECREF(__pyx_v_subtype_origin); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator4); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1229: object field,
1230: object T,
1231: object name,
1232: object data,
1233: object encoder,
1234: object origin,
1235: object targs
1236: ):
1237: """
1238: Attempt each type in the Union until one parses successfully
1239: or raise an error if all fail.
1240: If T is Optional[...] (i.e. a Union with NoneType), unwrap it.
1241: """
+1242: cdef str field_name = field.name
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1242, __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, 1242, __pyx_L1_error) __pyx_v_field_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1243: cdef str error = None
__Pyx_INCREF(Py_None);
__pyx_v_error = ((PyObject*)Py_None);
+1244: cdef object non_none_arg = None
__Pyx_INCREF(Py_None);
__pyx_v_non_none_arg = Py_None;
+1245: cdef tuple inner_targs = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_targs = ((PyObject*)Py_None);
+1246: cdef bint is_typing = False
__pyx_v_is_typing = 0;
1247:
1248: # If the union includes NoneType, unwrap it and use only the non-None type.
+1249: 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, 1249, __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, 1249, __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, 1249, __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, 1249, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1250: 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, 1250, __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, 1250, __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, 1250, __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, 1250, __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, 1250, __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, 1250, __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, 1250, __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, 1250, __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, 1250, __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:;
+1251: if arg is not type(None):
__pyx_t_2 = (__pyx_v_arg != ((PyObject *)Py_TYPE(Py_None))); if (__pyx_t_2) { /* … */ }
+1252: non_none_arg = arg
__Pyx_INCREF(__pyx_v_arg); __Pyx_DECREF_SET(__pyx_v_non_none_arg, __pyx_v_arg);
+1253: break
goto __pyx_L7_break;
+1254: 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, 1254, __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, 1254, __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, 1254, __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;
1255:
+1256: 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; }
1257: # Invoke the parse_typing_type
+1258: 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, 1258, __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, 1258, __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, 1258, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1259: 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, 1259, __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, 1259, __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, 1259, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1260: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1261: 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, 1261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1262: field,
1263: non_none_arg,
1264: data,
1265: encoder,
1266: False
1267: )
1268: else:
+1269: pass
/*else*/ { } __pyx_L12:;
1270:
1271: # First check for dataclasses in the union
+1272: 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, 1272, __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, 1272, __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, 1272, __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, 1272, __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, 1272, __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, 1272, __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, 1272, __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, 1272, __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, 1272, __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;
+1273: if is_dc(arg_type):
__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, 1273, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+1274: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1275: try:
{ /*try:*/ { /* … */ } __pyx_L20_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L22_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_L26_try_continue:; __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_L16_continue; __pyx_L24_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; }
+1276: return arg_type(**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, 1276, __pyx_L20_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_1 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1276, __pyx_L20_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, 1276, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_7 = __Pyx_PyObject_Call(__pyx_v_arg_type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1276, __pyx_L20_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L24_try_return;
+1277: except Exception as exc:
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_13) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_14) < 0) __PYX_ERR(0, 1277, __pyx_L22_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_14); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L33_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_15); __pyx_t_15 = 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_13 = __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_13; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21; goto __pyx_L22_except_error; } __pyx_L30_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L28_except_continue; } } __pyx_L28_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L26_try_continue; } goto __pyx_L22_except_error;
+1278: error = f"Failed to create dataclass {arg_type.__name__} from dict: {exc}"
__pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1278, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Failed_to_create_dataclass); __pyx_t_16 += 27; __Pyx_GIVEREF(__pyx_kp_u_Failed_to_create_dataclass); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Failed_to_create_dataclass); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_name); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1278, __pyx_L33_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, 1278, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u_from_dict); __pyx_t_16 += 12; __Pyx_GIVEREF(__pyx_kp_u_from_dict); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u_from_dict); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1278, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_15, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1278, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_19)); __pyx_t_19 = 0;
+1279: continue
goto __pyx_L30_continue; }
+1280: elif 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, 1280, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+1281: 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_L0;
1282: else:
1283: # For string inputs, don't accept them as dataclasses
+1284: if isinstance(data, (str, int, float, bool)):
/*else*/ { __Pyx_INCREF(((PyObject*)&PyBool_Type)); __pyx_t_14 = ((PyObject*)&PyBool_Type); __pyx_t_4 = PyUnicode_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L40_bool_binop_done; } __pyx_t_4 = PyInt_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L40_bool_binop_done; } __pyx_t_4 = PyFloat_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L40_bool_binop_done; } __pyx_t_4 = PyObject_IsInstance(__pyx_v_data, __pyx_t_14); __pyx_t_2 = __pyx_t_4; __pyx_L40_bool_binop_done:; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (__pyx_t_2) { /* … */ }
+1285: error = f"Cannot convert {type(data).__name__} to {arg_type.__name__}"
__pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Cannot_convert); __pyx_t_16 += 15; __Pyx_GIVEREF(__pyx_kp_u_Cannot_convert); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_kp_u_Cannot_convert); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1285, __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, 1285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_to); __pyx_t_16 += 4; __Pyx_GIVEREF(__pyx_kp_u_to); PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_kp_u_to); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1285, __pyx_L1_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, 1285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_14, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+1286: continue
goto __pyx_L16_continue;
+1287: try:
{ /*try:*/ { /* … */ } __pyx_L44_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L46_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10); goto __pyx_L1_error; __pyx_L50_try_continue:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10); goto __pyx_L16_continue; __pyx_L48_try_return:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10); goto __pyx_L0; } }
+1288: return arg_type(data)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arg_type); __pyx_t_14 = __pyx_v_arg_type; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1288, __pyx_L44_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L48_try_return;
+1289: 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_1, &__pyx_t_14, &__pyx_t_7) < 0) __PYX_ERR(0, 1289, __pyx_L46_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_14); __pyx_v_exc = __pyx_t_14; /*try:*/ { /* … */ /*finally:*/ { __pyx_L57_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_15); __pyx_t_15 = 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_13 = __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_13; __pyx_filename = __pyx_t_28; goto __pyx_L46_except_error; } __pyx_L54_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L52_except_continue; } } __pyx_L52_except_continue:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L50_try_continue; } goto __pyx_L46_except_error;
+1290: error = f"Failed to create {arg_type.__name__} from {type(data).__name__}: {exc}"
__pyx_t_19 = PyTuple_New(6); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Failed_to_create); __pyx_t_16 += 17; __Pyx_GIVEREF(__pyx_kp_u_Failed_to_create); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_kp_u_Failed_to_create); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_15, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17; __pyx_t_16 += __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_from); __pyx_t_16 += 6; __Pyx_GIVEREF(__pyx_kp_u_from); PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_kp_u_from); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_18, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_15); __pyx_t_15 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_kp_u__7); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_19, 6, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1290, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_15)); __pyx_t_15 = 0;
+1291: continue
goto __pyx_L54_continue; }
+1292: if error:
__pyx_t_2 = (__pyx_v_error != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_error) != 0);
if (unlikely(__pyx_t_2)) {
/* … */
}
+1293: raise ValueError(
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 1293, __pyx_L1_error)
+1294: 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, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_17 = 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_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_14); __pyx_t_14 = 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_14 = __Pyx_PyObject_FormatSimple(__pyx_v_data, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_14); __pyx_t_14 = 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_14 = __Pyx_PyUnicode_Unicode(__pyx_v_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_3, 6, __pyx_t_5, __pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1295: )
1296:
+1297: 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, 1297, __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, 1297, __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, 1297, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_14); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1297, __pyx_L1_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #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, 1297, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_14); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1297, __pyx_L1_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #endif } } else { __pyx_t_14 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_14)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1297, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_14); } __Pyx_XDECREF_SET(__pyx_v_arg_type, __pyx_t_14); __pyx_t_14 = 0; /* … */ __pyx_L65_continue:; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1298: # Iterate over all subtypes of Union:
+1299: subtype_origin = get_origin(arg_type)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_arg_type}; __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_subtype_origin, __pyx_t_14); __pyx_t_14 = 0;
+1300: 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_L74_try_end; __pyx_L67_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L69_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_L73_try_continue:; __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_L65_continue; __pyx_L71_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_L68_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_L74_try_end:; }
+1301: 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_L76_bool_binop_done; } __pyx_t_4 = (__pyx_v_subtype_origin == ((PyObject *)(&PyTuple_Type))); __pyx_t_2 = __pyx_t_4; __pyx_L76_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1302: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1303: return _parse_list_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_14 = __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_14)) __PYX_ERR(0, 1303, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_r = __pyx_t_14; __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L71_try_return;
1304: else:
+1305: error = f"Invalid type for {field_name}: Expected a list, got {type(data).__name__}"
/*else*/ { __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1305, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_16 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_14, 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, 1305, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_list_got); __pyx_t_16 += 23; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_list_got); PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_kp_u_Expected_a_list_got); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1305, __pyx_L67_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, 1305, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_14, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1305, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+1306: continue
goto __pyx_L73_try_continue; }
+1307: if subtype_origin is list and field._inner_is_dc == True and isinstance(data, list):
__pyx_t_4 = (__pyx_v_subtype_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L80_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1307, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = PyObject_RichCompare(__pyx_t_1, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1307, __pyx_L67_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1307, __pyx_L67_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L80_bool_binop_done; } __pyx_t_4 = PyList_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_4; __pyx_L80_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1308: return _handle_list_of_dataclasses(field, field_name, data, T, None)
__Pyx_XDECREF(__pyx_r); __pyx_t_29.__pyx_n = 1; __pyx_t_29.parent = Py_None; __pyx_t_14 = __pyx_f_9datamodel_10converters__handle_list_of_dataclasses(__pyx_v_field, __pyx_v_field_name, __pyx_v_data, __pyx_v_T, &__pyx_t_29); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1308, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_r = __pyx_t_14; __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L71_try_return;
+1309: elif subtype_origin is dict:
__pyx_t_2 = (__pyx_v_subtype_origin == ((PyObject *)(&PyDict_Type))); if (__pyx_t_2) { /* … */ }
+1310: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1311: return _parse_dict_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_14 = __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_14)) __PYX_ERR(0, 1311, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_r = __pyx_t_14; __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L71_try_return;
1312: else:
+1313: error = f"Invalid type for {field_name} Expected a dict, got {type(data).__name__}"
/*else*/ { __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1313, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_16 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_14, 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, 1313, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_dict_got); __pyx_t_16 += 22; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_dict_got); PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_kp_u_Expected_a_dict_got); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1313, __pyx_L67_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, 1313, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_14, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1313, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
+1314: continue
goto __pyx_L73_try_continue; }
+1315: elif arg_type is list:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ goto __pyx_L79; }
+1316: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
goto __pyx_L84;
}
+1317: if arg_type is str:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyUnicode_Type))); if (__pyx_t_2) { /* … */ goto __pyx_L85; }
1318: # Ensure all elements in the list are strings
+1319: 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_6_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_6_genexpr *)__pyx_tp_new_9datamodel_10converters___pyx_scope_struct_6_genexpr(__pyx_ptype_9datamodel_10converters___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_9datamodel_10converters___pyx_scope_struct_6_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1319, __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_2generator4, 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, 1319, __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_2generator4(__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, 1319, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __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, 1319, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_14 = __Pyx_Generator_Next(__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1319, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1319, __pyx_L67_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (__pyx_t_2) { /* … */ }
+1320: 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_L71_try_return;
1321: else:
+1322: return _parse_list_type(field, arg_type, data, encoder, targs)
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_14 = __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_14)) __PYX_ERR(0, 1322, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_r = __pyx_t_14; __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L71_try_return; } __pyx_L85:;
1323: else:
+1324: error = f"Invalid type for {field_name}: Expected a list, got {type(data).__name__}"
/*else*/ { __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1324, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_16 += 17; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_2); PyTuple_SET_ITEM(__pyx_t_14, 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, 1324, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_list_got); __pyx_t_16 += 23; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_list_got); PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_kp_u_Expected_a_list_got); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1324, __pyx_L67_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, 1324, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_14, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1324, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+1325: continue
goto __pyx_L73_try_continue; } __pyx_L84:;
+1326: elif arg_type is dict:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyDict_Type))); if (__pyx_t_2) { /* … */ }
+1327: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1328: 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, 1328, __pyx_L67_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_L71_try_return;
1329: else:
+1330: 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, 1330, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_16 += 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_14 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1330, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_dict_got); __pyx_t_16 += 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_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1330, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_14, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1330, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __pyx_t_16 += __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_16, __pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1330, __pyx_L67_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;
+1331: continue
goto __pyx_L73_try_continue; }
+1332: elif subtype_origin is None:
__pyx_t_2 = (__pyx_v_subtype_origin == Py_None); if (__pyx_t_2) { /* … */ }
+1333: if is_dc(arg_type):
__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, 1333, __pyx_L67_error) if (__pyx_t_2) { /* … */ }
+1334: return _handle_dataclass_type(field, name, data, arg_type, False, 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, 1334, __pyx_L67_error) __pyx_t_30.__pyx_n = 2; __pyx_t_30.as_objects = Py_False; __pyx_t_30.parent = Py_None; __pyx_t_7 = __pyx_f_9datamodel_10converters__handle_dataclass_type(__pyx_v_field, ((PyObject*)__pyx_v_name), __pyx_v_data, __pyx_v_arg_type, &__pyx_t_30); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1334, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L71_try_return;
+1335: elif arg_type in encoders:
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_encoders); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1335, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_arg_type, __pyx_t_7, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1335, __pyx_L67_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_2) { /* … */ }
+1336: return _parse_builtin_type(field, arg_type, data, encoder)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1336, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L71_try_return;
+1337: elif 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, 1337, __pyx_L67_error) if (__pyx_t_2) { /* … */ }
+1338: 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_L71_try_return;
1339: else:
1340: # Not matching => record an error
+1341: 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, 1341, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_2); __pyx_t_16 += 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, 1341, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __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_16 += 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, 1341, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __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_16 += 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, 1341, __pyx_L67_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_17; __pyx_t_16 += __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_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1341, __pyx_L67_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;
+1342: continue
goto __pyx_L73_try_continue; }
1343: else:
1344: # fallback to builtin parse
+1345: 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, 1345, __pyx_L67_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_L71_try_return; } __pyx_L79:;
1346: field,
1347: arg_type,
1348: data,
1349: encoder,
1350: False
1351: )
+1352: except ValueError as exc:
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_13) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_14) < 0) __PYX_ERR(0, 1352, __pyx_L69_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_14); __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_L95; } __pyx_L94_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_15); __pyx_t_15 = 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_13 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_31 = __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_13; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_31; goto __pyx_L69_except_error; } __pyx_L95:; } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L68_exception_handled; }
+1353: error = f"{field.name}: {exc}"
__pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1353, __pyx_L94_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = 0; __pyx_t_17 = 127; __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1353, __pyx_L94_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_19, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1353, __pyx_L94_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_kp_u__7); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1353, __pyx_L94_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_15, 3, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1353, __pyx_L94_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_18)); __pyx_t_18 = 0; }
+1354: 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_14, &__pyx_t_7, &__pyx_t_1) < 0) __PYX_ERR(0, 1354, __pyx_L69_except_error) __Pyx_XGOTREF(__pyx_t_14); __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_L106; } __pyx_L105_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_15); __pyx_t_15 = 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_13 = __pyx_clineno; __pyx_t_32 = __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_13; __pyx_filename = __pyx_t_32; goto __pyx_L69_except_error; } __pyx_L106:; } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L68_exception_handled; } goto __pyx_L69_except_error;
+1355: error = f"Parse Error on {field.name}, {arg_type}: {exc}"
__pyx_t_18 = PyTuple_New(6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1355, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_Parse_Error_on); __pyx_t_16 += 15; __Pyx_GIVEREF(__pyx_kp_u_Parse_Error_on); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_kp_u_Parse_Error_on); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1355, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_t_15, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1355, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u__10); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__10); PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_kp_u__10); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_arg_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1355, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_18, 4, __pyx_kp_u__7); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1355, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_18, 5, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_18, 6, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1355, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_19)); __pyx_t_19 = 0; }
1356:
1357: # If we get here, all union attempts failed
+1358: raise ValueError(
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1358, __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, 1358, __pyx_L1_error)
+1359: 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, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_17 = 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_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1359, __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, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __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, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __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, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_17; __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_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1360: )
1361:
+1362: 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; };
1363: object field,
1364: object T,
1365: object data,
+1366: object encoder=None,
PyObject *__pyx_v_encoder = ((PyObject *)Py_None);
+1367: 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; } } }
1368: ):
1369: """
1370: Parse a value to a typing type.
1371: """
1372: # local cdef variables:
+1373: cdef object origin = get_origin(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1373, __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, 1373, __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;
+1374: cdef object targs = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1374, __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, 1374, __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;
+1375: 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, 1375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_name = __pyx_t_1; __pyx_t_1 = 0;
+1376: cdef object sub = None # for subtypes, local cache
__Pyx_INCREF(Py_None);
__pyx_v_sub = Py_None;
+1377: cdef object result = None
__Pyx_INCREF(Py_None);
__pyx_v_result = Py_None;
+1378: 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, 1378, __pyx_L1_error) __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_isdc = __pyx_t_1; __pyx_t_1 = 0;
1379:
+1380: if data is None:
__pyx_t_5 = (__pyx_v_data == Py_None); if (__pyx_t_5) { /* … */ }
+1381: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1382:
+1383: if isdc:
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_isdc); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1383, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+1384: 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, 1384, __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, 1384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1385: # Field type shortcuts
+1386: 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) {
/* … */
}
+1387: 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, 1387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1388: elif origin is list:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_5) { /* … */ }
+1389: 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, 1389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1390: elif origin is tuple:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyTuple_Type))); if (__pyx_t_5) { /* … */ }
+1391: return _parse_tuple_type(field, T, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_tuple_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1392: elif origin is set:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_5) { /* … */ }
1393: # Handle Sets - convert lists to sets
+1394: if isinstance(data, (list, tuple)):
__pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_5 = __pyx_t_7; goto __pyx_L8_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); __pyx_t_5 = __pyx_t_7; __pyx_L8_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+1395: return set(data) # Convert list/tuple to set
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1396: elif isinstance(data, set):
__pyx_t_5 = PySet_Check(__pyx_v_data);
if (__pyx_t_5) {
/* … */
}
+1397: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1398: else:
+1399: return {data} if data is not None else set() # Wrap single value in set
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_5 = (__pyx_v_data != Py_None); if (__pyx_t_5) { __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PySet_Add(__pyx_t_2, __pyx_v_data) < 0) __PYX_ERR(0, 1399, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } else { __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
+1400: elif origin is frozenset:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyFrozenSet_Type))); if (__pyx_t_5) { /* … */ }
1401: # Handle Frozensets - convert lists to frozensets
+1402: if isinstance(data, (list, tuple)):
__pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_5 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); __pyx_t_5 = __pyx_t_7; __pyx_L11_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+1403: return frozenset(data) # Convert list/tuple to frozenset
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyFrozenSet_New(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1404: elif isinstance(data, frozenset):
__pyx_t_5 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_5) { /* … */ }
+1405: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1406: else:
+1407: return frozenset([data]) if data is not None else frozenset() # Wrap single value in frozenset
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_5 = (__pyx_v_data != Py_None); if (__pyx_t_5) { __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data)) __PYX_ERR(0, 1407, __pyx_L1_error); __pyx_t_3 = __Pyx_PyFrozenSet_New(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = __Pyx_PyFrozenSet_New(((PyObject *)NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
+1408: elif origin is not None:
__pyx_t_5 = (__pyx_v_origin != Py_None); if (__pyx_t_5) { /* … */ }
+1409: if T in (int, float, str, bool) or T in encoders:
__Pyx_INCREF(__pyx_v_T); __pyx_t_1 = __pyx_v_T; __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1409, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L16_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1409, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L16_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1409, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L16_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject*)&PyBool_Type), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1409, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __pyx_t_8; __pyx_L16_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __pyx_t_7; if (!__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L14_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_encoders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_v_T, __pyx_t_1, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_8; __pyx_L14_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+1410: return _parse_builtin_type(field, T, data, encoder)
__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, 1410, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1411: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+1412: elif T is set:
__pyx_t_5 = (__pyx_v_T == ((PyObject *)(&PySet_Type))); if (__pyx_t_5) { /* … */ }
1413: # Handle bare 'set' type
+1414: if isinstance(data, (list, tuple)):
__pyx_t_8 = PyList_Check(__pyx_v_data); if (!__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L21_bool_binop_done; } __pyx_t_8 = PyTuple_Check(__pyx_v_data); __pyx_t_5 = __pyx_t_8; __pyx_L21_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+1415: return set(data) # Convert list/tuple to set
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1416: elif isinstance(data, set):
__pyx_t_5 = PySet_Check(__pyx_v_data);
if (__pyx_t_5) {
/* … */
}
+1417: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1418: else:
+1419: return {data} if data is not None else set()
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_5 = (__pyx_v_data != Py_None); if (__pyx_t_5) { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_data) < 0) __PYX_ERR(0, 1419, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1420: else:
1421: # fallback to builtin parse
+1422: 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, 1422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); __pyx_t_1 = 0;
+1423: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; }
1424:
+1425: 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_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __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_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_converted_item); __Pyx_XDECREF(__pyx_v_set_data); __Pyx_XDECREF(__pyx_v_processed_set); __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; };
1426: object field,
1427: object T,
1428: object data,
+1429: object encoder=None,
PyObject *__pyx_v_encoder = ((PyObject *)Py_None);
+1430: object as_objects=False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False);
+1431: 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; 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_v_e = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_v_converted_item = NULL; PyObject *__pyx_v_set_data = NULL; PyObject *__pyx_v_processed_set = 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; } } } }
1432: ):
1433: """
1434: Parse a value to a typing type.
1435: """
1436: # local cdef variables:
1437: cdef object origin, targs
+1438: 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, 1438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_name = __pyx_t_1; __pyx_t_1 = 0;
+1439: cdef object sub = None # for subtypes, local cache
__Pyx_INCREF(Py_None);
__pyx_v_sub = Py_None;
+1440: cdef object result = None
__Pyx_INCREF(Py_None);
__pyx_v_result = Py_None;
+1441: cdef object inner_type = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_type = Py_None;
+1442: cdef bint inner_is_dc = 0 # field._inner_is_dc or is_dataclass(inner_type)
__pyx_v_inner_is_dc = 0;
1443:
+1444: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+1445: return None # no data, short-circuiting
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1446:
1447: # Use cached values only if T is exactly the field's declared type.
+1448: 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, 1448, __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, 1448, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1448, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L4; }
+1449: origin = field.origin
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_origin = __pyx_t_3; __pyx_t_3 = 0;
+1450: targs = field.args
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_args_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_targs = __pyx_t_3; __pyx_t_3 = 0;
+1451: elif field._inner_type and field._inner_type == inner_type:
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1451, __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_L5_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_v_inner_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1451, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1451, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L4; }
+1452: 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, 1452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+1453: 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, 1453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_targs = __pyx_t_1; __pyx_t_1 = 0;
1454: else:
+1455: origin = get_origin(T)
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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_T}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 1455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+1456: targs = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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_T}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 1456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_targs = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L4:;
1457:
1458: # For generic (typing) fields, reuse cached inner type info if available.
+1459: if origin in (list, set, frozenset) and targs:
__Pyx_INCREF(__pyx_v_origin); __pyx_t_1 = __pyx_v_origin; __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1459, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1459, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_7) { } else { __pyx_t_4 = __pyx_t_7; goto __pyx_L10_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PySet_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1459, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1459, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_7) { } else { __pyx_t_4 = __pyx_t_7; goto __pyx_L10_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyFrozenSet_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1459, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1459, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __pyx_t_7; __pyx_L10_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __pyx_t_4; if (__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L8_bool_binop_done; } __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_targs); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1459, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L8_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L7; }
+1460: 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, 1460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__pyx_t_1 != Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L13; }
+1461: 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, 1461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0;
+1462: 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, 1462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_inner_origin = __pyx_t_1; __pyx_t_1 = 0;
1463: # Optionally, also use cached type arguments for the inner type.
1464: else:
+1465: inner_type = targs[0] if targs else Any
/*else*/ { __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_targs); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1465, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0;
+1466: inner_origin = get_origin(inner_type)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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_inner_type}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_inner_origin = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L13:;
1467: else:
+1468: inner_type = None
/*else*/ { __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_inner_type, Py_None);
+1469: inner_origin = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_origin = Py_None;
}
__pyx_L7:;
1470:
+1471: 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, 1471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L14_bool_binop_done; } __pyx_t_7 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_inner_type); if (unlikely(__pyx_t_7 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1471, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L14_bool_binop_done:; __pyx_v_inner_is_dc = __pyx_t_2;
1472:
1473: # Put more frequently cases first:
+1474: if field.is_dc or is_dc(T):
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_is_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1474, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L17_bool_binop_done; } __pyx_t_7 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_T); if (unlikely(__pyx_t_7 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1474, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L17_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1475: 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, 1475, __pyx_L1_error) __pyx_t_8.__pyx_n = 2; __pyx_t_8.as_objects = __pyx_v_as_objects; __pyx_t_8.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_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1476:
1477: # If the field is a Union and data is a list, use _parse_union_type.
+1478: if origin is Union:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Union); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__pyx_v_origin == __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
1479: # e.g. Optional[...] or Union[A, B]
+1480: if len(targs) == 2 and type(None) in targs:
__pyx_t_9 = PyObject_Length(__pyx_v_targs); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1480, __pyx_L1_error) __pyx_t_7 = (__pyx_t_9 == 2); if (__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L21_bool_binop_done; } __pyx_t_7 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_targs, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1480, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L21_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1481: # Handle Optional[...] that is Union[..., None] cases first:
+1482: 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, 1482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1482, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
1483: # If Optional but non-None is a primitive
+1484: 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, 1484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_t_1, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1484, __pyx_L1_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_L0;
+1485: elif field._inner_is_dc:
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1485, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
1486: # non-None is a Optional Dataclass:
+1487: 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, 1487, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8.__pyx_n = 2; __pyx_t_8.as_objects = __pyx_v_as_objects; __pyx_t_8.parent = Py_None; __pyx_t_1 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, ((PyObject*)__pyx_v_name), __pyx_v_data, __pyx_t_3, &__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1488: else:
+1489: real_type = targs[0] if targs[1] is type(None) else targs[1]
/*else*/ { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_targs, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__pyx_t_3 == ((PyObject *)Py_TYPE(Py_None))); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_targs, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_real_type = __pyx_t_1; __pyx_t_1 = 0;
1490: # Recursively parse the real_type exactly as if it weren't wrapped in Optional[…].
+1491: return _parse_typing(field, real_type, data, encoder, as_objects, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_10.__pyx_n = 3; __pyx_t_10.encoder = __pyx_v_encoder; __pyx_t_10.as_objects = __pyx_v_as_objects; __pyx_t_10.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_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1492: else:
+1493: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L24_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L26_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_L28_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; } }
+1494: 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, 1494, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L28_try_return;
1495: field,
1496: T,
1497: name,
1498: data,
1499: encoder,
1500: origin,
1501: targs
1502: )
+1503: except Exception as e:
__pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_14) { __Pyx_AddTraceback("datamodel.converters._parse_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_5) < 0) __PYX_ERR(0, 1503, __pyx_L26_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L35_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_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 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_14 = __pyx_lineno; __pyx_t_19 = __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_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_14; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20; goto __pyx_L26_except_error; } } } goto __pyx_L26_except_error;
+1504: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_18); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1504, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+1505: f"Union parsing error for {field.name}: {e}"
__pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1505, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_9 = 0; __pyx_t_16 = 127; __Pyx_INCREF(__pyx_kp_u_Union_parsing_error_for); __pyx_t_9 += 24; __Pyx_GIVEREF(__pyx_kp_u_Union_parsing_error_for); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Union_parsing_error_for); __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1505, __pyx_L35_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, 1505, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_9 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__7); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1505, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_15, 4, __pyx_t_9, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1505, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+1506: ) from e
__Pyx_Raise(__pyx_t_15, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __PYX_ERR(0, 1504, __pyx_L35_error) }
1507: # Other Field types
+1508: if field._type_category == 'typing':
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_type_category); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1508, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_2) { /* … */ }
1509: # For example, if the origin is list and the inner type is a dataclass,
1510: # use _handle_dataclass_type on each element.
+1511: if origin is list:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ }
+1512: if inner_is_dc:
if (__pyx_v_inner_is_dc) { /* … */ }
+1513: return _parse_list_type(field, T, data, encoder, targs, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_27.__pyx_n = 1; __pyx_t_27._parent = __pyx_v_parent; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, &__pyx_t_27); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1514: else:
+1515: return _parse_typing_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_28.__pyx_n = 1; __pyx_t_28.as_objects = __pyx_v_as_objects; __pyx_t_5 = __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_28); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; }
1516: field, T, name, data, encoder, origin, targs, as_objects
1517: )
+1518: elif origin is set:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_2) { /* … */ }
+1519: if targs and targs[0] is not Any:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_targs); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1519, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L45_bool_binop_done; } __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = (__pyx_t_5 != __pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_7; __pyx_L45_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1520: if isinstance(data, (list, tuple)):
__pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L48_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_7; __pyx_L48_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1521: result = set()
__pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); __pyx_t_3 = 0;
+1522: 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_9 = 0; __pyx_t_29 = NULL; } else { __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_29 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 1522, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_29)) { 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, 1522, __pyx_L1_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 1522, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #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, 1522, __pyx_L1_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 1522, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_29(__pyx_t_3); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1522, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5); __pyx_t_5 = 0; /* … */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1523: converted_item = _parse_type(field, targs[0], item, encoder, False)
__pyx_t_5 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_30.__pyx_n = 2; __pyx_t_30.encoder = __pyx_v_encoder; __pyx_t_30.as_objects = Py_False; __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_t_5, __pyx_v_item, &__pyx_t_30); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_converted_item, __pyx_t_1); __pyx_t_1 = 0;
+1524: result.add(converted_item)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_add); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_v_converted_item}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1525: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+1526: elif isinstance(data, set):
__pyx_t_2 = PySet_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
1527: # Already a set, just validate/convert the elements
+1528: result = set()
__pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); __pyx_t_3 = 0;
+1529: 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_9 = 0; __pyx_t_29 = NULL; } else { __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_29 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 1529, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_29)) { 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, 1529, __pyx_L1_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 1529, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1529, __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, 1529, __pyx_L1_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 1529, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_29(__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, 1529, __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;
+1530: converted_item = _parse_type(field, targs[0], item, encoder, False)
__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, 1530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_30.__pyx_n = 2; __pyx_t_30.encoder = __pyx_v_encoder; __pyx_t_30.as_objects = Py_False; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_t_1, __pyx_v_item, &__pyx_t_30); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_converted_item, __pyx_t_5); __pyx_t_5 = 0;
+1531: result.add(converted_item)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_add); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_v_converted_item}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1532: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1533: else:
1534: # Single value, convert and wrap in a set
+1535: converted_item = _parse_type(field, targs[0], data, encoder, False)
/*else*/ { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_targs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_30.__pyx_n = 2; __pyx_t_30.encoder = __pyx_v_encoder; __pyx_t_30.as_objects = Py_False; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_type(__pyx_v_field, __pyx_t_3, __pyx_v_data, &__pyx_t_30); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_converted_item = __pyx_t_5; __pyx_t_5 = 0;
+1536: return {converted_item} if data is not None else set()
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_converted_item) < 0) __PYX_ERR(0, 1536, __pyx_L1_error) __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; }
1537: else:
1538: # Untyped set, just convert to a set without validating elements
+1539: if isinstance(data, (list, tuple)):
/*else*/ { __pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L57_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_7; __pyx_L57_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1540: return set(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1540, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
+1541: elif isinstance(data, set):
__pyx_t_2 = PySet_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1542: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1543: else:
+1544: return {data} if data is not None else set()
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1544, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_data) < 0) __PYX_ERR(0, 1544, __pyx_L1_error) __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1544, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; } }
1545: else:
+1546: return _parse_typing_type(
/*else*/ { __Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_28.__pyx_n = 1; __pyx_t_28.as_objects = __pyx_v_as_objects; __pyx_t_5 = __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_28); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; }
1547: field, T, name, data, encoder, origin, targs, as_objects
1548: )
1549: # Handle container types with proper recursive processing
1550: # List types
+1551: elif origin is list:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ }
+1552: return _parse_list_type(field, T, data, encoder, targs, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_27.__pyx_n = 1; __pyx_t_27._parent = __pyx_v_parent; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, &__pyx_t_27); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1552, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1553:
1554: # Set types
+1555: elif origin is set:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_2) { /* … */ }
+1556: return _parse_set_type(field, T, data, encoder, targs, parent)
__Pyx_XDECREF(__pyx_r); __pyx_t_31.__pyx_n = 1; __pyx_t_31._parent = __pyx_v_parent; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_set_type(__pyx_v_field, __pyx_v_T, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, &__pyx_t_31); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1557:
1558: # FrozenSet types - process as set, then convert to frozenset
+1559: elif origin is frozenset:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PyFrozenSet_Type))); if (__pyx_t_2) { /* … */ }
+1560: try:
{ /*try:*/ { /* … */ } __pyx_L59_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L61_except_error:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11); goto __pyx_L1_error; __pyx_L63_try_return:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11); goto __pyx_L0; __pyx_L62_except_return:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11); goto __pyx_L0; }
1561: # Convert to set first if needed
+1562: if isinstance(data, (list, tuple, set)):
__pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L66_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L66_bool_binop_done; } __pyx_t_7 = PySet_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_7; __pyx_L66_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L65; }
+1563: set_data = set(data)
__pyx_t_5 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1563, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_set_data = __pyx_t_5; __pyx_t_5 = 0;
+1564: elif isinstance(data, frozenset):
__pyx_t_2 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_2) { /* … */ goto __pyx_L65; }
+1565: set_data = data
__Pyx_INCREF(__pyx_v_data);
__pyx_v_set_data = __pyx_v_data;
1566: else:
+1567: set_data = {data} if data is not None else set()
/*else*/ { __pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1567, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_data) < 0) __PYX_ERR(0, 1567, __pyx_L59_error) __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1567, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_set_data = __pyx_t_5; __pyx_t_5 = 0; } __pyx_L65:;
1568:
1569: # Process as a set
+1570: processed_set = _parse_set_type(field, T, set_data, encoder, targs, parent)
__pyx_t_31.__pyx_n = 1; __pyx_t_31._parent = __pyx_v_parent; __pyx_t_5 = __pyx_f_9datamodel_10converters__parse_set_type(__pyx_v_field, __pyx_v_T, __pyx_v_set_data, __pyx_v_encoder, __pyx_v_targs, &__pyx_t_31); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1570, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_processed_set = __pyx_t_5; __pyx_t_5 = 0;
1571:
1572: # Convert back to frozenset
+1573: return frozenset(processed_set)
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyFrozenSet_New(__pyx_v_processed_set); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1573, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L63_try_return;
+1574: except Exception as e:
__pyx_t_19 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_19) { __Pyx_AddTraceback("datamodel.converters._parse_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 1574, __pyx_L61_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_v_e = __pyx_t_3; /*try:*/ { /* … */ /*finally:*/ { __pyx_L74_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_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 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_19 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_32 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 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_19; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_32; goto __pyx_L61_except_error; } __pyx_L73_return: { __pyx_t_21 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; __pyx_r = __pyx_t_21; __pyx_t_21 = 0; goto __pyx_L62_except_return; } } } goto __pyx_L61_except_error;
1575: # Be resilient to errors
+1576: if isinstance(data, frozenset):
__pyx_t_2 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_2) { /* … */ }
+1577: 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_5); __pyx_t_5 = 0; goto __pyx_L73_return;
+1578: elif isinstance(data, (set, list, tuple)):
__pyx_t_7 = PySet_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L77_bool_binop_done; } __pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L77_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_7; __pyx_L77_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1579: return frozenset(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_15 = __Pyx_PyFrozenSet_New(__pyx_v_data); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1579, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_15); __pyx_r = __pyx_t_15; __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L73_return;
1580: else:
+1581: return frozenset({data}) if data is not None else frozenset()
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { __pyx_t_18 = PySet_New(0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1581, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_18); if (PySet_Add(__pyx_t_18, __pyx_v_data) < 0) __PYX_ERR(0, 1581, __pyx_L74_error) __pyx_t_17 = __Pyx_PyFrozenSet_New(__pyx_t_18); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1581, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_15 = __pyx_t_17; __pyx_t_17 = 0; } else { __pyx_t_17 = __Pyx_PyFrozenSet_New(((PyObject *)NULL)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1581, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_15 = __pyx_t_17; __pyx_t_17 = 0; } __pyx_r = __pyx_t_15; __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L73_return; } }
1582: # Dict types
+1583: elif origin is dict and isinstance(data, dict):
__pyx_t_7 = (__pyx_v_origin == ((PyObject *)(&PyDict_Type)));
if (__pyx_t_7) {
} else {
__pyx_t_2 = __pyx_t_7;
goto __pyx_L84_bool_binop_done;
}
__pyx_t_7 = PyDict_Check(__pyx_v_data);
__pyx_t_2 = __pyx_t_7;
__pyx_L84_bool_binop_done:;
if (__pyx_t_2) {
/* … */
}
+1584: 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, 1584, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1585: elif origin is not None:
__pyx_t_2 = (__pyx_v_origin != Py_None); if (__pyx_t_2) { /* … */ }
1586: # other advanced generics
+1587: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1588: else:
1589: # fallback to builtin parse
+1590: 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, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1591:
+1592: cdef object _parse_literal_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_literal_type(PyObject *__pyx_v_field, CYTHON_UNUSED PyObject *__pyx_v_T, PyObject *__pyx_v_data, CYTHON_UNUSED PyObject *__pyx_v_encoder) { PyObject *__pyx_v_targs = 0; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("datamodel.converters._parse_literal_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_targs); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1593: object field,
1594: object T,
1595: object data,
1596: object encoder
1597: ):
1598: """
1599: _parse_literal_type parses a typing.Literal[...] annotation.
1600:
1601: :param field: A Field object (or similar) containing metadata
1602: :param T: The full annotated type (e.g. typing.Literal['text/plain', 'text/html']).
1603: :param data: The input value to check.
1604: :param encoder: Optional encoder (not usually used for literal).
1605: :return: Returns 'data' if it matches one of the literal choices, otherwise raises ValueError.
1606: """
1607:
1608: # Each element in `targs` is a valid literal value, e.g. a string, int, etc.
1609: # If data is exactly in that set, it's valid.
+1610: cdef tuple targs = field.args
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_args_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1610, __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, 1610, __pyx_L1_error) __pyx_v_targs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1611: cdef tuple i
+1612: for arg in targs:
if (unlikely(__pyx_v_targs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1612, __pyx_L1_error) } __pyx_t_1 = __pyx_v_targs; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { 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, 1612, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 1612, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1613: if data == arg:
__pyx_t_3 = PyObject_RichCompare(__pyx_v_data, __pyx_v_arg, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1613, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1613, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { /* … */ }
+1614: 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;
1615:
1616: # If we get here, data didn't match any literal value
+1617: raise ValueError(
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1617, __pyx_L1_error)
+1618: f"Literal parse error for field '{field.name}': "
__pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Literal_parse_error_for_field); __pyx_t_2 += 31; __Pyx_GIVEREF(__pyx_kp_u_Literal_parse_error_for_field); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Literal_parse_error_for_field); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u_value); __pyx_t_2 += 9; __Pyx_GIVEREF(__pyx_kp_u_value); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_value); /* … */ __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1619: f"value={data!r} is not one of {targs}"
__pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_data), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u_is_not_one_of); __pyx_t_2 += 15; __Pyx_GIVEREF(__pyx_kp_u_is_not_one_of); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_is_not_one_of); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v_targs, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_6); __pyx_t_6 = 0;
1620: )
1621:
+1622: 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_8genexpr6__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr6__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; };
1623: object field,
1624: str name,
1625: object value,
1626: object _type,
+1627: object as_objects = False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False);
+1628: 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_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_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);
1629: ):
1630: """
1631: _handle_dataclass_type.
1632:
1633: Process a field that is annotated as SomeDataclass.
1634: If there's a registered converter for the dataclass, call it;
1635: otherwise, build the dataclass using default logic.
1636: """
+1637: cdef tuple key = (_type, name)
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1637, __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, 1637, __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, 1637, __pyx_L1_error); __pyx_v_key = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1638: 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, 1638, __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, 1638, __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, 1638, __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, 1638, __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, 1638, __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;
+1639: 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, 1639, __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, 1639, __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, 1639, __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, 1639, __pyx_L1_error) __pyx_t_3 = __pyx_t_5; } __pyx_v_isdc = __pyx_t_3;
+1640: 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, 1640, __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, 1640, __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, 1640, __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;
+1641: 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, 1641, __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, 1641, __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, 1641, __pyx_L1_error) __pyx_v_alias = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1642:
+1643: 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, 1643, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L6_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1644: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
+1645: 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, 1645, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+1646: 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; }
1647: # If alias exists, adjust the key passed to the dataclass
+1648: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
1649: # if alias exists on type, preserve the alias:
+1650: 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, 1650, __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, 1650, __pyx_L9_error) __pyx_t_3 = __pyx_t_4; __pyx_L17_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1651: value = value.copy()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1651, __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, 1651, __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;
+1652: 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, 1652, __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, 1652, __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, 1652, __pyx_L9_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1653: # convert the dictionary to the dataclass
+1654: 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, 1654, __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, 1654, __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, 1654, __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, 1654, __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;
+1655: 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, 1655, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_6);
1656: # Ensure keys are strings
+1657: 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, 1657, __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, 1657, __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, 1657, __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, 1657, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GOTREF(__pyx_t_17); __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_k, __pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_v, __pyx_t_17); __pyx_t_17 = 0; __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_8genexpr6__pyx_v_k); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1657, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_17); if (unlikely(PyDict_SetItem(__pyx_t_12, (PyObject*)__pyx_t_17, (PyObject*)__pyx_8genexpr6__pyx_v_v))) __PYX_ERR(0, 1657, __pyx_L23_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 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_L26_exit_scope; __pyx_L23_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_L11_except_error; __pyx_L26_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_12); __pyx_t_12 = 0;
+1658: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
+1659: value = value.copy()
__pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1659, __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, 1659, __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;
+1660: 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, 1660, __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, 1660, __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, 1660, __pyx_L11_except_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1661: 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, 1661, __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, 1661, __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, 1661, __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, 1661, __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; }
+1662: 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, 1662, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2);
1663: # replace in "value" dictionary the current "name" for "alias"
+1664: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
+1665: value = value.copy()
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1665, __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, 1665, __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;
+1666: 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, 1666, __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, 1666, __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, 1666, __pyx_L11_except_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+1667: 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, 1667, __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, 1667, __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, 1667, __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, 1667, __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; }
+1668: 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, 1668, __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;
+1669: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1669, __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, 1669, __pyx_L36_error) }
+1670: f"Invalid value for {name}:{_type} == {value}, error: {exc}"
__pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1670, __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, 1670, __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, 1670, __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, 1670, __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, 1670, __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, 1670, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1671: )
+1672: 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; }
+1673: if PyObject_IsInstance(value, (list, tuple)):
__pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1673, __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, 1673, __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, 1673, __pyx_L42_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1673, __pyx_L42_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { /* … */ }
+1674: return _type(*value)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1674, __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, 1674, __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;
1675: else:
1676: # If a converter exists for this type, use it:
+1677: if converter:
/*else*/ { __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1677, __pyx_L42_error) if (__pyx_t_3) { /* … */ }
+1678: 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, 1678, __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;
+1679: if as_objects:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_as_objects); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1679, __pyx_L42_error) if (__pyx_t_3) { /* … */ }
1680: # If alias exists, adjust the key passed to the dataclass
+1681: 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) {
/* … */
}
+1682: alias = name
__Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_alias, __pyx_v_name);
1683: # convert the list to the dataclass
+1684: return _type(**{alias: value})
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1684, __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, 1684, __pyx_L42_error) } else { if (PyDict_SetItem(__pyx_t_1, __pyx_v_alias, __pyx_v_value) < 0) __PYX_ERR(0, 1684, __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, 1684, __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;
+1685: if PyObject_IsInstance(value, (int, str, UUID)):
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_UUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1685, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1685, __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, 1685, __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, 1685, __pyx_L42_error); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_6)) __PYX_ERR(0, 1685, __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, 1685, __pyx_L42_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* … */ }
+1686: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L46_try_return;
+1687: if isdc:
if (__pyx_v_isdc) { /* … */ }
+1688: 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) {
/* … */
}
+1689: alias = name
__Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_alias, __pyx_v_name);
+1690: return _type(**{alias: value})
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1690, __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, 1690, __pyx_L42_error) } else { if (PyDict_SetItem(__pyx_t_1, __pyx_v_alias, __pyx_v_value) < 0) __PYX_ERR(0, 1690, __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, 1690, __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;
1691: else:
+1692: 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, 1692, __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; } }
+1693: 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, 1693, __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;
+1694: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1694, __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, 1694, __pyx_L60_error) }
+1695: f"Invalid value for {name}:{_type} == {value}, error: {exc}"
__pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1695, __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, 1695, __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, 1695, __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, 1695, __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, 1695, __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, 1695, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1696: )
1697:
+1698: 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; };
1699: object field,
1700: str name,
1701: object value,
1702: object _type,
+1703: 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; } }
1704: ):
1705: """
1706: _handle_list_of_dataclasses.
1707:
1708: Process a list field that is annotated as List[SomeDataclass].
1709: If there's a registered converter for the sub-dataclass, call it;
1710: otherwise, build the sub-dataclass using default logic.
1711: """
+1712: 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:; }
+1713: 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, 1713, __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, 1713, __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;
+1714: 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, 1714, __pyx_L3_error) if (__pyx_t_6) { /* … */ }
+1715: key = (sub_type, name)
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1715, __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, 1715, __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, 1715, __pyx_L3_error); __pyx_v_key = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1716: 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, 1716, __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, 1716, __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, 1716, __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, 1716, __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, 1716, __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;
+1717: new_list = []
__pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1717, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_new_list = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1718: 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, 1718, __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, 1718, __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, 1718, __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, 1718, __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, 1718, __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, 1718, __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, 1718, __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, 1718, __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, 1718, __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;
+1719: if converter:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1719, __pyx_L3_error) if (__pyx_t_6) { /* … */ goto __pyx_L14; }
+1720: 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, 1720, __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, 1720, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1721: elif isinstance(item, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_item);
if (__pyx_t_6) {
/* … */
goto __pyx_L14;
}
+1722: 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, 1722, __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, 1722, __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, 1722, __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, 1722, __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, 1722, __pyx_L3_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1723: else:
+1724: 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, 1724, __pyx_L3_error) } __pyx_L14:;
+1725: return new_list
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_list); __pyx_r = __pyx_v_new_list; goto __pyx_L7_try_return;
+1726: except ValueError:
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_13) { __Pyx_AddTraceback("datamodel.converters._handle_list_of_dataclasses", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 1726, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4);
+1727: raise
__Pyx_GIVEREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_9, __pyx_t_4); __pyx_t_5 = 0; __pyx_t_9 = 0; __pyx_t_4 = 0; __PYX_ERR(0, 1727, __pyx_L5_except_error) }
+1728: 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;
1729: pass
+1730: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1731:
1732: # Helper function to handle sets of dataclasses
+1733: cdef object _handle_set_of_dataclasses(
static PyObject *__pyx_f_9datamodel_10converters__handle_set_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_set_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_set_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_set); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__handle_set_of_dataclasses { int __pyx_n; PyObject *parent; };
1734: object field,
1735: str name,
1736: object value,
1737: object _type,
+1738: 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_set = 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; } }
1739: ):
1740: """
1741: _handle_set_of_dataclasses.
1742:
1743: Process a set field that is annotated as Set[SomeDataclass].
1744: If there's a registered converter for the sub-dataclass, call it;
1745: otherwise, build the sub-dataclass using default logic.
1746: """
+1747: 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:; }
+1748: 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, 1748, __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, 1748, __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;
+1749: 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, 1749, __pyx_L3_error) if (__pyx_t_6) { /* … */ }
+1750: key = (sub_type, name)
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1750, __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, 1750, __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, 1750, __pyx_L3_error); __pyx_v_key = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1751: 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, 1751, __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, 1751, __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, 1751, __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, 1751, __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, 1751, __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;
+1752: new_set = set()
__pyx_t_5 = PySet_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1752, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_new_set = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1753: 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, 1753, __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, 1753, __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, 1753, __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, 1753, __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, 1753, __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, 1753, __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, 1753, __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, 1753, __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, 1753, __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;
+1754: if converter:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1754, __pyx_L3_error) if (__pyx_t_6) { /* … */ goto __pyx_L14; }
+1755: new_set.add(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, 1755, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_12 = PySet_Add(__pyx_v_new_set, __pyx_t_4); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1755, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1756: elif isinstance(item, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_item);
if (__pyx_t_6) {
/* … */
goto __pyx_L14;
}
+1757: new_set.add(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, 1757, __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, 1757, __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, 1757, __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, 1757, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = PySet_Add(__pyx_v_new_set, __pyx_t_9); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1757, __pyx_L3_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1758: else:
+1759: new_set.add(item)
/*else*/ { __pyx_t_12 = PySet_Add(__pyx_v_new_set, __pyx_v_item); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1759, __pyx_L3_error) } __pyx_L14:;
+1760: return new_set
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_set); __pyx_r = __pyx_v_new_set; goto __pyx_L7_try_return;
+1761: except (AttributeError, IndexError):
__pyx_t_13 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_AttributeError, __pyx_builtin_IndexError);
if (__pyx_t_13) {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L4_exception_handled;
}
goto __pyx_L5_except_error;
1762: pass
+1763: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1764:
+1765: 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; }
1766: object obj,
1767: str name,
1768: object value,
1769: object default_func,
1770: object default_is_callable
1771: ):
1772: """Handle default value of fields."""
1773: # If value is callable, try calling it directly
+1774: if PyCallable_Check(value):
__pyx_t_1 = PyCallable_Check(__pyx_v_value);
if (__pyx_t_1) {
/* … */
}
+1775: 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:; }
+1776: 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, 1776, __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;
+1777: 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, 1777, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+1778: 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;
+1779: 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, 1779, __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;
+1780: 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, 1780, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15);
+1781: 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;
+1782: 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, 1782, __pyx_L1_error)
+1783: return new_val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_val); __pyx_r = __pyx_v_new_val; goto __pyx_L0;
1784:
1785: # If f.default is callable and value is None
+1786: 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, 1786, __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) { /* … */ }
+1787: 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:; }
+1788: 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, 1788, __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;
+1789: 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, 1789, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+1790: 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;
+1791: 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, 1791, __pyx_L1_error)
+1792: return new_val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_val); __pyx_r = __pyx_v_new_val; goto __pyx_L0;
1793:
1794: # If there's a non-missing default and no value
+1795: 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, 1795, __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, 1795, __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) { /* … */ }
+1796: 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, 1796, __pyx_L1_error)
+1797: return default_func
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default_func); __pyx_r = __pyx_v_default_func; goto __pyx_L0;
1798:
1799: # Otherwise, return value as-is
+1800: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1801:
+1802: 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; }
1803: """
1804: _build_error.
1805:
1806: Build a tuple containing an error message and the name of the field.
1807: """
+1808: 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, 1808, __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, 1808, __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, 1808, __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, 1808, __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;
+1809: return {name: error_message}
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1809, __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, 1809, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
1810:
+1811: 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_set_value = NULL; PyObject *__pyx_v__case = 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_59); __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_set_value); __Pyx_XDECREF(__pyx_v__case); __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, 1811, __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, 1811, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("processing_fields", 1, 2, 2, 1); __PYX_ERR(0, 1811, __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, 1811, __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, 1811, __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, 1811, __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, 1811, __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, 1811, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46); /* … */ __pyx_t_3 = __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_3)) __PYX_ERR(0, 1811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_processing_fields, __pyx_t_3) < 0) __PYX_ERR(0, 1811, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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, 1811, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 1811, __pyx_L1_error)
1812: """
1813: Process the fields (columns) of a dataclass object.
1814:
1815: For each field, if a custom parser is attached (i.e. f.parser is not None),
1816: it is used to convert the value. Otherwise, the standard conversion logic
1817: (parse_basic, parse_typing, etc.) is applied.
1818: """
1819: cdef object new_val
+1820: cdef object _encoder = None
__Pyx_INCREF(Py_None);
__pyx_v__encoder = Py_None;
+1821: cdef object _default = None
__Pyx_INCREF(Py_None);
__pyx_v__default = Py_None;
+1822: cdef object _type = None
__Pyx_INCREF(Py_None);
__pyx_v__type = Py_None;
+1823: 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, 1823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_meta = __pyx_t_1; __pyx_t_1 = 0;
+1824: 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, 1824, __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, 1824, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_as_objects = __pyx_t_2;
+1825: 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, 1825, __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, 1825, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_no_nesting = __pyx_t_2;
+1826: cdef tuple type_args = ()
__Pyx_INCREF(__pyx_empty_tuple);
__pyx_v_type_args = __pyx_empty_tuple;
1827: # Error handling
+1828: cdef dict errors = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_errors = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1829: # Type Information
+1830: cdef dict _typeinfo = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__typeinfo = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1831: # Column information:
1832: cdef tuple c_col
1833: cdef str name
1834: cdef object f
1835: cdef object value
1836: cdef object newval
1837:
+1838: for c_col in columns:
if (unlikely(__pyx_v_columns == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1838, __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, 1838, __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, 1838, __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, 1838, __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, 1838, __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;
+1839: name = c_col[0]
if (unlikely(__pyx_v_c_col == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1839, __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, 1839, __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, 1839, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_name, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+1840: f = c_col[1]
if (unlikely(__pyx_v_c_col == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1840, __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, 1840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_4); __pyx_t_4 = 0;
+1841: value = getattr(obj, name)
__pyx_t_4 = __Pyx_GetAttr(__pyx_v_obj, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0;
1842: # Use the precomputed field type category:
+1843: 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, 1843, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_field_category, __pyx_t_4); __pyx_t_4 = 0;
1844:
+1845: 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, 1845, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
1846: # Handle descriptor-specific logic
+1847: 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:; }
+1848: 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, 1848, __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, 1848, __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;
+1849: 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, 1849, __pyx_L6_error)
+1850: 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, 1850, __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;
+1851: 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, 1851, __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, 1851, __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, 1851, __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, 1851, __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, 1851, __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; }
+1852: continue
goto __pyx_L3_continue;
1853:
1854: # get type and default:
+1855: _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, 1855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v__type, __pyx_t_9); __pyx_t_9 = 0;
+1856: _default = f.default
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_default); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1856, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v__default, __pyx_t_9); __pyx_t_9 = 0;
+1857: 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, 1857, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_typeinfo, __pyx_t_9); __pyx_t_9 = 0;
+1858: 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, 1858, __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, 1858, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_type_args, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+1859: 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:; }
+1860: metadata = f.metadata
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_metadata); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1860, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_metadata, __pyx_t_9); __pyx_t_9 = 0;
+1861: 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, 1861, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4);
+1862: 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, 1862, __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;
1863:
1864: # _default_callable = typeinfo.get('default_callable', False)
1865: # Check if object is empty
+1866: 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, 1866, __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, 1866, __pyx_L1_error) __pyx_t_25 = (!__pyx_t_24); __pyx_t_2 = __pyx_t_25; __pyx_L36_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1867: 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, 1867, __pyx_L1_error) __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 1867, __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) { /* … */ }
+1868: 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, 1868, __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, 1868, __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, 1868, __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;
1869: # PyObject_SetAttr(obj, name, value)
+1870: 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, 1870, __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, 1870, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1871: if _default is not None:
__pyx_t_2 = (__pyx_v__default != Py_None); if (__pyx_t_2) { /* … */ }
+1872: 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, 1872, __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, 1872, __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;
+1873: 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_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:; }
+1874: _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, 1874, __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, 1874, __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;
+1875: newval = value
__Pyx_INCREF(__pyx_v_value); __Pyx_XDECREF_SET(__pyx_v_newval, __pyx_v_value);
1876:
+1877: 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, 1877, __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; }
1878: # If a custom parser is attached to Field, use it
+1879: 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_L52_exception_handled:; __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_L58_try_end:; }
+1880: 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, 1880, __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, 1880, __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;
+1881: 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, 1881, __pyx_L51_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1881, __pyx_L51_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
+1882: 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, 1882, __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, 1882, __pyx_L51_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1883: 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, 1883, __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:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L66; } __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_L66:; } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L52_exception_handled; } goto __pyx_L53_except_error;
+1884: errors.update(
__pyx_t_12 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1884, __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; }
+1885: _build_error(name, f"Error parsing *{name}* = *{value}*", ex)
__pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1885, __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, 1885, __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, 1885, __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, 1885, __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, 1885, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1886: )
+1887: 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, 1887, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1888: 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_L72_exception_handled:; __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_L78_try_end:; }
+1889: 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, 1889, __pyx_L71_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+1890: 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, 1890, __pyx_L71_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1890, __pyx_L71_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ }
+1891: 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, 1891, __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, 1891, __pyx_L71_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+1892: 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, 1892, __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:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L86; } __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_L86:; } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L72_exception_handled; } goto __pyx_L73_except_error;
+1893: errors.update(
__pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1893, __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; }
+1894: _build_error(name, f"Error parsing {name}: ", ex)
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1894, __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, 1894, __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, 1894, __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, 1894, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
1895: )
+1896: 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, 1896, __pyx_L42_error) if (__pyx_t_2) { goto __pyx_L50; }
1897: # TODO: support multiple types
1898: pass
+1899: 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, 1899, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1900: 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_L98_try_end; __pyx_L91_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_L93_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_L97_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_L98_try_end:; }
+1901: if no_nesting is False:
__pyx_t_2 = (__pyx_v_no_nesting == 0); if (__pyx_t_2) { /* … */ }
+1902: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L100; }
+1903: 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, 1903, __pyx_L91_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;
+1904: 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, 1904, __pyx_L91_error) __Pyx_GOTREF(__pyx_t_8);
1905: )
1906: else:
+1907: 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, 1907, __pyx_L91_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_L100:;
+1908: 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, 1908, __pyx_L91_error) __Pyx_GOTREF(__pyx_t_4);
1909: )
+1910: 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, 1910, __pyx_L91_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1910, __pyx_L91_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
1911: # PyObject_SetAttr(obj, name, newval)
+1912: 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, 1912, __pyx_L91_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1912, __pyx_L91_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1913: except ValueError:
__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_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1913, __pyx_L93_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+1914: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_4, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 1914, __pyx_L93_except_error) }
+1915: 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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1915, __pyx_L93_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_L109_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_33 = __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_33; goto __pyx_L93_except_error; } __pyx_L106_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L104_except_continue; } } __pyx_L104_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_L97_try_continue; } goto __pyx_L93_except_error;
+1916: errors.update(
__pyx_t_12 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1916, __pyx_L109_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1917: _build_error(name, f"Error parsing Dataclass: {name}: ", ex)
__pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1917, __pyx_L109_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_Dataclass); __pyx_t_13 += 25; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_Dataclass); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing_Dataclass); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1917, __pyx_L109_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_PyUnicode_Join(__pyx_t_15, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1917, __pyx_L109_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, 1917, __pyx_L109_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1918: )
+1919: continue
goto __pyx_L106_continue; }
+1920: 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, 1920, __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, 1920, __pyx_L42_error) __pyx_t_24 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 1920, __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_L117_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, 1920, __pyx_L42_error) __pyx_t_25 = __pyx_t_24; __pyx_L117_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_L115_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, 1920, __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, 1920, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_24; __pyx_L115_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1921: 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_L126_try_end; __pyx_L119_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_L121_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_L125_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_L126_try_end:; }
+1922: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L127; }
+1923: newval = _handle_list_of_dataclasses(f, name, value, _type, obj)
__pyx_t_34.__pyx_n = 1; __pyx_t_34.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_34); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1923, __pyx_L119_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
1924: else:
+1925: newval = _handle_list_of_dataclasses(f, name, value, _type, None)
/*else*/ { __pyx_t_34.__pyx_n = 1; __pyx_t_34.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_34); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1925, __pyx_L119_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L127:;
+1926: 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, 1926, __pyx_L119_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1926, __pyx_L119_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1927: except ValueError:
__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_8, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1927, __pyx_L121_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+1928: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_4, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 1928, __pyx_L121_except_error) }
+1929: except Exception as ex:
__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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1929, __pyx_L121_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_L135_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_35 = __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_35; goto __pyx_L121_except_error; } __pyx_L132_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L130_except_continue; } } __pyx_L130_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_L125_try_continue; } goto __pyx_L121_except_error;
+1930: errors.update(
__pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1930, __pyx_L135_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+1931: _build_error(name, f"Error handling list of dataclasses at {name}: ", ex)
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1931, __pyx_L135_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_handling_list_of_dataclass); __pyx_t_13 += 38; __Pyx_GIVEREF(__pyx_kp_u_Error_handling_list_of_dataclass); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Error_handling_list_of_dataclass); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1931, __pyx_L135_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, 1931, __pyx_L135_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, 1931, __pyx_L135_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
1932: )
+1933: continue
goto __pyx_L132_continue; }
1934: # Handle set of dataclasses
+1935: elif f.origin in (set, 'set') and getattr(f, '_inner_is_dc', False):
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1935, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)(&PySet_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1935, __pyx_L42_error) __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 1935, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_25) { } else { __pyx_t_24 = __pyx_t_25; goto __pyx_L143_bool_binop_done; } __pyx_t_25 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_set, Py_EQ)); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 1935, __pyx_L42_error) __pyx_t_24 = __pyx_t_25; __pyx_L143_bool_binop_done:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_25 = __pyx_t_24; if (__pyx_t_25) { } else { __pyx_t_2 = __pyx_t_25; goto __pyx_L141_bool_binop_done; } __pyx_t_8 = __Pyx_GetAttr3(__pyx_v_f, __pyx_n_u_inner_is_dc, Py_False); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1935, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 1935, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_25; __pyx_L141_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1936: 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_L152_try_end; __pyx_L145_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_L147_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_L151_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_L152_try_end:; }
+1937: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L153; }
+1938: newval = _handle_set_of_dataclasses(f, name, value, _type, obj)
__pyx_t_36.__pyx_n = 1; __pyx_t_36.parent = __pyx_v_obj; __pyx_t_8 = __pyx_f_9datamodel_10converters__handle_set_of_dataclasses(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_36); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1938, __pyx_L145_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
1939: else:
+1940: newval = _handle_set_of_dataclasses(f, name, value, _type, None)
/*else*/ { __pyx_t_36.__pyx_n = 1; __pyx_t_36.parent = Py_None; __pyx_t_8 = __pyx_f_9datamodel_10converters__handle_set_of_dataclasses(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, &__pyx_t_36); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1940, __pyx_L145_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L153:;
+1941: 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, 1941, __pyx_L145_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1941, __pyx_L145_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1942: except ValueError:
__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_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1942, __pyx_L147_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+1943: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_4, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 1943, __pyx_L147_except_error) }
+1944: 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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1944, __pyx_L147_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_L161_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_37 = __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_37; goto __pyx_L147_except_error; } __pyx_L158_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L156_except_continue; } } __pyx_L156_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_L151_try_continue; } goto __pyx_L147_except_error;
+1945: errors.update(
__pyx_t_12 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1945, __pyx_L161_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1946: _build_error(name, f"Error handling set of dataclasses at {name}: ", ex)
__pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1946, __pyx_L161_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_handling_set_of_dataclasse); __pyx_t_13 += 37; __Pyx_GIVEREF(__pyx_kp_u_Error_handling_set_of_dataclasse); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_handling_set_of_dataclasse); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1946, __pyx_L161_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_PyUnicode_Join(__pyx_t_15, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1946, __pyx_L161_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, 1946, __pyx_L161_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1947: )
+1948: continue
goto __pyx_L158_continue; }
+1949: 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, 1949, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1950: 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, 1950, __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, 1950, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+1951: 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_L175_try_end; __pyx_L168_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_L170_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_L174_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_L175_try_end:; }
1952: # means that is_dataclass(T)
+1953: 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, 1953, __pyx_L168_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, 1953, __pyx_L168_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;
+1954: 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, 1954, __pyx_L168_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1954, __pyx_L168_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1955: except ValueError:
__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_4, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 1955, __pyx_L170_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+1956: raise
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_8, __pyx_t_9); __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 1956, __pyx_L170_except_error) }
+1957: except Exception as ex:
__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_9, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 1957, __pyx_L170_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_v_ex = __pyx_t_8; /*try:*/ { /* … */ /*finally:*/ { __pyx_L183_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_38 = __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_38; goto __pyx_L170_except_error; } __pyx_L180_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L178_except_continue; } } __pyx_L178_except_continue:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L174_try_continue; } goto __pyx_L170_except_error;
+1958: errors.update(_build_error(name, f"Error handling dataclass {name}: ", ex))
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1958, __pyx_L183_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_handling_dataclass); __pyx_t_13 += 25; __Pyx_GIVEREF(__pyx_kp_u_Error_handling_dataclass); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Error_handling_dataclass); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1958, __pyx_L183_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, 1958, __pyx_L183_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, 1958, __pyx_L183_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, 1958, __pyx_L183_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+1959: continue
goto __pyx_L180_continue; }
+1960: elif f.origin is Literal:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1960, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Literal); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1960, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_4 == __pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+1961: 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_L196_try_end; __pyx_L189_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_L191_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_L195_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_L196_try_end:; }
1962: # e.g. Literal[...]
+1963: newval = _parse_literal_type(f, _type, value, _encoder)
__pyx_t_8 = __pyx_f_9datamodel_10converters__parse_literal_type(__pyx_v_f, __pyx_v__type, __pyx_v_value, __pyx_v__encoder); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1963, __pyx_L189_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
+1964: 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, 1964, __pyx_L189_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1964, __pyx_L189_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1965: except ValueError:
__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_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1965, __pyx_L191_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+1966: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_4, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 1966, __pyx_L191_except_error) }
+1967: 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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1967, __pyx_L191_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_L204_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_39 = __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_39; goto __pyx_L191_except_error; } __pyx_L201_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L199_except_continue; } } __pyx_L199_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_L195_try_continue; } goto __pyx_L191_except_error;
+1968: errors.update(_build_error(name, f"Error parsing Literal {name}: ", ex))
__pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1968, __pyx_L204_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_Literal); __pyx_t_13 += 22; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_Literal); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing_Literal); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1968, __pyx_L204_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_PyUnicode_Join(__pyx_t_15, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1968, __pyx_L204_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, 1968, __pyx_L204_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, 1968, __pyx_L204_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1969: continue
goto __pyx_L201_continue; }
+1970: elif f.origin is list:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1970, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_8 == ((PyObject *)(&PyList_Type))); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+1971: 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_L217_try_end; __pyx_L210_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_L212_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_L216_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_L217_try_end:; }
1972: # Other typical case is when is a List of primitives.
+1973: 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, 1973, __pyx_L210_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1973, __pyx_L210_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L218; }
+1974: newval = _parse_list_type(
__pyx_t_40.__pyx_n = 1; __pyx_t_40._parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_f, __pyx_v__type, __pyx_v_value, __pyx_v__encoder, __pyx_t_8, &__pyx_t_40); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1974, __pyx_L210_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;
1975: f,
1976: _type,
1977: value,
1978: _encoder,
+1979: f.args,
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1979, __pyx_L210_error) __Pyx_GOTREF(__pyx_t_8);
1980: obj
1981: )
1982: else:
+1983: try:
/*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; goto __pyx_L226_try_end; __pyx_L219_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_L221_except_error:; __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_27); goto __pyx_L210_error; __pyx_L226_try_end:; } } __pyx_L218:;
+1984: newval = _parse_typing(
__pyx_t_41.__pyx_n = 3; __pyx_t_41.encoder = __pyx_v__encoder; __pyx_t_41.as_objects = __pyx_t_4; __pyx_t_41.parent = __pyx_v_obj; __pyx_t_8 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_41); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1984, __pyx_L219_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;
1985: f,
1986: _type,
1987: value,
1988: _encoder,
+1989: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1989, __pyx_L219_error) __Pyx_GOTREF(__pyx_t_4);
1990: obj
1991: )
+1992: 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_8, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 1992, __pyx_L221_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_4); /*try:*/ { /* … */ /*finally:*/ { __pyx_L232_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 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_43, &__pyx_t_44, &__pyx_t_45); 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_43); __Pyx_XGOTREF(__pyx_t_44); __Pyx_XGOTREF(__pyx_t_45); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_42 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_43); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_45); __Pyx_ExceptionReset(__pyx_t_43, __pyx_t_44, __pyx_t_45); } __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_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_42; goto __pyx_L221_except_error; } } } goto __pyx_L221_except_error;
+1993: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1993, __pyx_L232_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 1993, __pyx_L232_error) }
+1994: f"Error parsing List: {name}: {e}"
__pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1994, __pyx_L232_error) __Pyx_GOTREF(__pyx_t_12); __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_12, 0, __pyx_kp_u_Error_parsing_List); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1994, __pyx_L232_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_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1994, __pyx_L232_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, 3, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_12, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1994, __pyx_L232_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1995: )
+1996: 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, 1996, __pyx_L210_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_t_9, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 1996, __pyx_L210_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+1997: except ValueError:
__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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 1997, __pyx_L212_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8);
+1998: raise
__Pyx_GIVEREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_4, __pyx_t_8); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_8 = 0; __PYX_ERR(0, 1998, __pyx_L212_except_error) }
+1999: 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, 1999, __pyx_L212_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_L245_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_45 = 0; __pyx_t_44 = 0; __pyx_t_43 = 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_45, &__pyx_t_44, &__pyx_t_43); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_45); __Pyx_XGOTREF(__pyx_t_44); __Pyx_XGOTREF(__pyx_t_43); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_46 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_45); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_43); __Pyx_ExceptionReset(__pyx_t_45, __pyx_t_44, __pyx_t_43); } __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_29); __Pyx_ErrRestore(__pyx_t_27, __pyx_t_28, __pyx_t_29); __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_45 = 0; __pyx_t_44 = 0; __pyx_t_43 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_46; goto __pyx_L212_except_error; } __pyx_L242_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L240_except_continue; } } __pyx_L240_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_L216_try_continue; } goto __pyx_L212_except_error;
+2000: errors.update(
__pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2000, __pyx_L245_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2001: _build_error(name, f"Error parsing List {name}: ", ex)
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2001, __pyx_L245_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_List_2); __pyx_t_13 += 19; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_List_2); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Error_parsing_List_2); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2001, __pyx_L245_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, 2001, __pyx_L245_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, 2001, __pyx_L245_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
2002: )
+2003: continue
goto __pyx_L242_continue; }
+2004: elif f.origin is set:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2004, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = (__pyx_t_9 == ((PyObject *)(&PySet_Type))); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+2005: 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_L258_try_end; __pyx_L251_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_L253_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_L257_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_L258_try_end:; }
+2006: if isinstance(value, list):
__pyx_t_2 = PyList_Check(__pyx_v_value);
if (__pyx_t_2) {
/* … */
goto __pyx_L259;
}
+2007: newval = set(value) # Simple conversion for bare set
__pyx_t_9 = PySet_New(__pyx_v_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2007, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+2008: elif f._inner_priv is True:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_priv); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2008, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = (__pyx_t_9 == Py_True); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L259; }
2009: # is a primitive typing Set.
+2010: newval = _parse_set_type(
__pyx_t_47.__pyx_n = 1; __pyx_t_47._parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_set_type(__pyx_v_f, __pyx_v__type, __pyx_v_value, __pyx_v__encoder, __pyx_t_9, &__pyx_t_47); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2010, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
2011: f,
2012: _type,
2013: value,
2014: _encoder,
+2015: f.args,
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2015, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_9);
2016: obj
2017: )
2018: else:
+2019: try:
/*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_43); __pyx_t_43 = 0; __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0; __Pyx_XDECREF(__pyx_t_45); __pyx_t_45 = 0; goto __pyx_L267_try_end; __pyx_L260_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_L262_except_error:; __Pyx_XGIVEREF(__pyx_t_43); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_45); __Pyx_ExceptionReset(__pyx_t_43, __pyx_t_44, __pyx_t_45); goto __pyx_L251_error; __pyx_L267_try_end:; } } __pyx_L259:;
+2020: newval = _parse_typing(
__pyx_t_41.__pyx_n = 3; __pyx_t_41.encoder = __pyx_v__encoder; __pyx_t_41.as_objects = __pyx_t_4; __pyx_t_41.parent = __pyx_v_obj; __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_41); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2020, __pyx_L260_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
2021: f,
2022: _type,
2023: value,
2024: _encoder,
+2025: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2025, __pyx_L260_error) __Pyx_GOTREF(__pyx_t_4);
2026: obj
2027: )
+2028: 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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 2028, __pyx_L262_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_4); /*try:*/ { /* … */ /*finally:*/ { __pyx_L273_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 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; 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_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_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_48 = __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_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18); } __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_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_48; goto __pyx_L262_except_error; } } } goto __pyx_L262_except_error;
+2029: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2029, __pyx_L273_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, 2029, __pyx_L273_error) }
+2030: f"Error parsing Set: {name}: {e}"
__pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2030, __pyx_L273_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_Set); __pyx_t_13 += 19; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_Set); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing_Set); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2030, __pyx_L273_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, 2030, __pyx_L273_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, 2030, __pyx_L273_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
2031: )
+2032: 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, 2032, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2032, __pyx_L251_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2033: except ValueError:
__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_4, &__pyx_t_9) < 0) __PYX_ERR(0, 2033, __pyx_L253_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2034: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_4, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 2034, __pyx_L253_except_error) }
+2035: 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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 2035, __pyx_L253_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_L286_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_45 = 0; __pyx_t_44 = 0; __pyx_t_43 = 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_45, &__pyx_t_44, &__pyx_t_43) < 0)) __Pyx_ErrFetch(&__pyx_t_45, &__pyx_t_44, &__pyx_t_43); __Pyx_XGOTREF(__pyx_t_45); __Pyx_XGOTREF(__pyx_t_44); __Pyx_XGOTREF(__pyx_t_43); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_49 = __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_45); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_43); __Pyx_ErrRestore(__pyx_t_45, __pyx_t_44, __pyx_t_43); __pyx_t_45 = 0; __pyx_t_44 = 0; __pyx_t_43 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_49; goto __pyx_L253_except_error; } __pyx_L283_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L281_except_continue; } } __pyx_L281_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_L257_try_continue; } goto __pyx_L253_except_error;
+2036: errors.update(_build_error(name, f"Error parsing Set: ", ex))
__pyx_t_15 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, __pyx_kp_u_Error_parsing_Set, __pyx_v_ex); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2036, __pyx_L286_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_12 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2036, __pyx_L286_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+2037: continue
goto __pyx_L283_continue; }
2038: # FrozenSet type
+2039: elif f.origin is frozenset:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2039, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_8 == ((PyObject *)(&PyFrozenSet_Type))); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+2040: 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_L299_try_end; __pyx_L292_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_L294_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_L298_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_L299_try_end:; }
+2041: if value is not None:
__pyx_t_2 = (__pyx_v_value != Py_None); if (__pyx_t_2) { /* … */ goto __pyx_L300; }
2042: # Convert to set first if needed
+2043: set_value = value if isinstance(value, (set, frozenset)) else set(value) if isinstance(value, (list, tuple)) else {value}
__pyx_t_25 = PySet_Check(__pyx_v_value); if (!__pyx_t_25) { } else { __pyx_t_2 = __pyx_t_25; goto __pyx_L301_bool_binop_done; } __pyx_t_25 = PyFrozenSet_Check(__pyx_v_value); __pyx_t_2 = __pyx_t_25; __pyx_L301_bool_binop_done:; if (__pyx_t_2) { __Pyx_INCREF(__pyx_v_value); __pyx_t_8 = __pyx_v_value; } else { __pyx_t_24 = PyList_Check(__pyx_v_value); if (!__pyx_t_24) { } else { __pyx_t_25 = __pyx_t_24; goto __pyx_L303_bool_binop_done; } __pyx_t_24 = PyTuple_Check(__pyx_v_value); __pyx_t_25 = __pyx_t_24; __pyx_L303_bool_binop_done:; if (__pyx_t_25) { __pyx_t_9 = PySet_New(__pyx_v_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2043, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __pyx_t_9; __pyx_t_9 = 0; } else { __pyx_t_9 = PySet_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2043, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_9); if (PySet_Add(__pyx_t_9, __pyx_v_value) < 0) __PYX_ERR(0, 2043, __pyx_L292_error) __pyx_t_4 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_t_8 = __pyx_t_4; __pyx_t_4 = 0; } __Pyx_XDECREF_SET(__pyx_v_set_value, __pyx_t_8); __pyx_t_8 = 0;
+2044: newval = frozenset(_parse_set_type(
__pyx_t_47.__pyx_n = 1; __pyx_t_47._parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_set_type(__pyx_v_f, __pyx_v__type, __pyx_v_set_value, __pyx_v__encoder, __pyx_t_8, &__pyx_t_47); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2044, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyFrozenSet_New(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2044, __pyx_L292_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;
2045: f,
2046: _type,
2047: set_value,
2048: _encoder,
+2049: f.args,
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2049, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_8);
2050: obj
2051: ))
2052: else:
+2053: newval = frozenset()
/*else*/ { __pyx_t_8 = __Pyx_PyFrozenSet_New(((PyObject *)NULL)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2053, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L300:;
+2054: 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, 2054, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2054, __pyx_L292_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2055: except ValueError:
__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_8, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 2055, __pyx_L294_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2056: raise
__Pyx_GIVEREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_4, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 2056, __pyx_L294_except_error) }
+2057: except Exception as ex:
__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_9, &__pyx_t_4, &__pyx_t_8) < 0) __PYX_ERR(0, 2057, __pyx_L294_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_L312_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 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_43, &__pyx_t_44, &__pyx_t_45); 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_43); __Pyx_XGOTREF(__pyx_t_44); __Pyx_XGOTREF(__pyx_t_45); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_50 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_43); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_45); __Pyx_ExceptionReset(__pyx_t_43, __pyx_t_44, __pyx_t_45); } __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_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_50; goto __pyx_L294_except_error; } __pyx_L309_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L307_except_continue; } } __pyx_L307_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_L298_try_continue; } goto __pyx_L294_except_error;
+2058: errors.update(_build_error(name, f"Error parsing FrozenSet {name}: ", ex))
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2058, __pyx_L312_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_FrozenSet); __pyx_t_13 += 24; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_FrozenSet); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_Error_parsing_FrozenSet); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2058, __pyx_L312_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, 2058, __pyx_L312_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, 2058, __pyx_L312_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, 2058, __pyx_L312_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2059: continue
goto __pyx_L309_continue; }
+2060: elif f.origin is tuple:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2060, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_8 == ((PyObject *)(&PyTuple_Type))); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+2061: 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_L325_try_end; __pyx_L318_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_L320_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_L324_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_L325_try_end:; }
+2062: newval = _parse_tuple_type(f, _type, value, _encoder, f.args)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2062, __pyx_L318_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_tuple_type(__pyx_v_f, __pyx_v__type, __pyx_v_value, __pyx_v__encoder, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2062, __pyx_L318_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;
+2063: 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, 2063, __pyx_L318_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2063, __pyx_L318_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2064: except ValueError:
__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_4, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 2064, __pyx_L320_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+2065: raise
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_8, __pyx_t_9); __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 2065, __pyx_L320_except_error) }
+2066: 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_9, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 2066, __pyx_L320_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_v_ex = __pyx_t_8; /*try:*/ { /* … */ /*finally:*/ { __pyx_L333_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_45 = 0; __pyx_t_44 = 0; __pyx_t_43 = 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_45, &__pyx_t_44, &__pyx_t_43) < 0)) __Pyx_ErrFetch(&__pyx_t_45, &__pyx_t_44, &__pyx_t_43); __Pyx_XGOTREF(__pyx_t_45); __Pyx_XGOTREF(__pyx_t_44); __Pyx_XGOTREF(__pyx_t_43); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_51 = __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_45); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_43); __Pyx_ErrRestore(__pyx_t_45, __pyx_t_44, __pyx_t_43); __pyx_t_45 = 0; __pyx_t_44 = 0; __pyx_t_43 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_51; goto __pyx_L320_except_error; } __pyx_L330_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L328_except_continue; } } __pyx_L328_except_continue:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L324_try_continue; } goto __pyx_L320_except_error;
+2067: errors.update(_build_error(name, f"Error parsing Tuple {name}: ", ex))
__pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2067, __pyx_L333_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_Tuple); __pyx_t_13 += 20; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_Tuple); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_parsing_Tuple); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2067, __pyx_L333_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_PyUnicode_Join(__pyx_t_15, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2067, __pyx_L333_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, 2067, __pyx_L333_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, 2067, __pyx_L333_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+2068: continue
goto __pyx_L330_continue; }
2069: # If the field is a Union and data is a list, use _parse_union_type.
+2070: elif f.origin is Union:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2070, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Union); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2070, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = (__pyx_t_4 == __pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+2071: 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_L346_try_end; __pyx_L339_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_L341_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_L345_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_L346_try_end:; }
+2072: 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, 2072, __pyx_L339_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, 2072, __pyx_L339_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_25 = (__pyx_t_13 == 2); if (__pyx_t_25) { } else { __pyx_t_2 = __pyx_t_25; goto __pyx_L348_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, 2072, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_25 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_t_8, Py_EQ)); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 2072, __pyx_L339_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_25; __pyx_L348_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L347; }
2073: # e.g. Optional[...] or Union[A, B]
+2074: if value is None:
__pyx_t_2 = (__pyx_v_value == Py_None); if (__pyx_t_2) { /* … */ goto __pyx_L350; }
+2075: newval = None
__Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_newval, Py_None);
+2076: elif 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, 2076, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2076, __pyx_L339_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L350; }
2077: # If Optional but non-None is a primitive
+2078: 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, 2078, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_f, __pyx_t_8, __pyx_v_value, __pyx_v__encoder); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2078, __pyx_L339_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;
+2079: elif f._inner_is_dc:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2079, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2079, __pyx_L339_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L350; }
2080: # non-None is a Optional Dataclass Optional[dataclass]
+2081: 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_9 = __pyx_f_9datamodel_10converters__handle_dataclass_type(Py_None, __pyx_v_name, __pyx_v_value, __pyx_t_4, &__pyx_t_32); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2081, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+2082: None, name, value, f._inner_type, as_objects, None
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2082, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2082, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8);
2083: )
+2084: elif f._inner_origin is list:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2084, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = (__pyx_t_9 == ((PyObject *)(&PyList_Type))); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L350; }
+2085: if f._inner_type.__module__ == 'typing':
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2085, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_module); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2085, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2085, __pyx_L339_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L351; }
+2086: newval = _parse_list_typing(
__pyx_t_52.__pyx_n = 1; __pyx_t_52.as_objects = __pyx_v_obj; __pyx_t_12 = __pyx_f_9datamodel_10converters__parse_list_typing(__pyx_v_f, ((PyObject*)__pyx_t_8), __pyx_v_value, __pyx_v__encoder, __pyx_t_9, __pyx_t_4, &__pyx_t_52); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2086, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_12); __pyx_t_12 = 0;
2087: f,
+2088: f._typing_args,
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_typing_args); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2088, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8); if (!(likely(PyTuple_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_8))) __PYX_ERR(0, 2088, __pyx_L339_error)
2089: value,
2090: _encoder,
+2091: f._inner_origin,
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2091, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9);
+2092: f._typing_args,
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_typing_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2092, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4);
2093: obj
2094: )
2095: else:
+2096: newval = _parse_list_type(
/*else*/ { /* … */ __pyx_t_40.__pyx_n = 1; __pyx_t_40._parent = __pyx_v_obj; __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_f, __pyx_t_12, __pyx_v_value, __pyx_v__encoder, __pyx_t_4, &__pyx_t_40); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2096, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0; } __pyx_L351:;
2097: f,
+2098: f._inner_type,
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2098, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_12);
2099: value,
2100: _encoder,
+2101: f._inner_targs,
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_targs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2101, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4);
2102: obj
2103: )
+2104: elif f._inner_origin is dict and not isinstance(value, dict) and value is not None:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2104, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_25 = (__pyx_t_9 == ((PyObject *)(&PyDict_Type))); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_25) { } else { __pyx_t_2 = __pyx_t_25; goto __pyx_L352_bool_binop_done; } __pyx_t_25 = PyDict_Check(__pyx_v_value); __pyx_t_24 = (!__pyx_t_25); if (__pyx_t_24) { } else { __pyx_t_2 = __pyx_t_24; goto __pyx_L352_bool_binop_done; } __pyx_t_24 = (__pyx_v_value != Py_None); __pyx_t_2 = __pyx_t_24; __pyx_L352_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L350; }
+2105: newval = _parse_dict_type(f, f._inner_type, value, _encoder, f.args)
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2105, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2105, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_12 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_f, __pyx_t_9, __pyx_v_value, __pyx_v__encoder, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2105, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_12); __pyx_t_12 = 0;
2106: else:
+2107: try:
/*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; goto __pyx_L362_try_end; __pyx_L355_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_L357_except_error:; __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); goto __pyx_L339_error; __pyx_L362_try_end:; } } __pyx_L350:;
+2108: newval = _parse_typing(f, f._inner_type, value, _encoder, as_objects, obj)
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2108, __pyx_L355_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2108, __pyx_L355_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_41.__pyx_n = 3; __pyx_t_41.encoder = __pyx_v__encoder; __pyx_t_41.as_objects = __pyx_t_4; __pyx_t_41.parent = __pyx_v_obj; __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_t_12, __pyx_v_value, &__pyx_t_41); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2108, __pyx_L355_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+2109: except ValueError:
__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_12) < 0) __PYX_ERR(0, 2109, __pyx_L357_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_12);
+2110: raise
__Pyx_GIVEREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_4, __pyx_t_12); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 2110, __pyx_L357_except_error) }
+2111: 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_12, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 2111, __pyx_L357_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_e, __pyx_t_4); /*try:*/ { /* … */ /*finally:*/ { __pyx_L370_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_43, &__pyx_t_44, &__pyx_t_45) < 0)) __Pyx_ErrFetch(&__pyx_t_43, &__pyx_t_44, &__pyx_t_45); __Pyx_XGOTREF(__pyx_t_43); __Pyx_XGOTREF(__pyx_t_44); __Pyx_XGOTREF(__pyx_t_45); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_53 = __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_43); __Pyx_XGIVEREF(__pyx_t_44); __Pyx_XGIVEREF(__pyx_t_45); __Pyx_ErrRestore(__pyx_t_43, __pyx_t_44, __pyx_t_45); __pyx_t_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_53; goto __pyx_L357_except_error; } } } goto __pyx_L357_except_error;
+2112: raise ValueError(
__pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2112, __pyx_L370_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 2112, __pyx_L370_error) }
+2113: f"Error parsing Optional: {name}: {e}"
__pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2113, __pyx_L370_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_Optional); __pyx_t_13 += 24; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_Optional); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_Error_parsing_Optional); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2113, __pyx_L370_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_8, 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_8, 2, __pyx_kp_u__7); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2113, __pyx_L370_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_8, 3, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2113, __pyx_L370_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2114: )
2115: else:
+2116: newval = _parse_typing(
/*else*/ { /* … */ __pyx_t_41.__pyx_n = 3; __pyx_t_41.encoder = __pyx_v__encoder; __pyx_t_41.as_objects = __pyx_t_9; __pyx_t_41.parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_41); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2116, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0; } __pyx_L347:;
2117: f,
2118: _type,
2119: value,
2120: _encoder,
+2121: as_objects,
__pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2121, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9);
2122: obj
2123: )
+2124: 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, 2124, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2124, __pyx_L339_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2125: except ValueError:
__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_4, &__pyx_t_9, &__pyx_t_12) < 0) __PYX_ERR(0, 2125, __pyx_L341_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12);
+2126: raise
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_9, __pyx_t_12); __pyx_t_4 = 0; __pyx_t_9 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 2126, __pyx_L341_except_error) }
+2127: 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_12, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 2127, __pyx_L341_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __pyx_v_ex = __pyx_t_9; /*try:*/ { /* … */ /*finally:*/ { __pyx_L383_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27); 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_29); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_27); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_54 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_27); } __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_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_54; goto __pyx_L341_except_error; } __pyx_L380_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L378_except_continue; } } __pyx_L378_except_continue:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L345_try_continue; } goto __pyx_L341_except_error;
+2128: errors.update(_build_error(name, f"Error parsing Union {name}: ", ex))
__pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2128, __pyx_L383_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_Union); __pyx_t_13 += 20; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_Union); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_Error_parsing_Union); __pyx_t_15 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2128, __pyx_L383_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_8, 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_8, 2, __pyx_kp_u__7); __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2128, __pyx_L383_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_15), __pyx_v_ex); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2128, __pyx_L383_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2128, __pyx_L383_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2129: continue
goto __pyx_L380_continue; }
2130: else:
+2131: 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_L396_try_end; __pyx_L389_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_L391_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_L395_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_L396_try_end:; } } __pyx_L167:;
+2132: newval = _parse_typing(
__pyx_t_41.__pyx_n = 3; __pyx_t_41.encoder = __pyx_v__encoder; __pyx_t_41.as_objects = __pyx_t_4; __pyx_t_41.parent = __pyx_v_obj; __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_41); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2132, __pyx_L389_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
2133: f,
2134: _type,
2135: value,
2136: _encoder,
+2137: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2137, __pyx_L389_error) __Pyx_GOTREF(__pyx_t_4);
2138: obj
2139: )
+2140: 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, 2140, __pyx_L389_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_t_9, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2140, __pyx_L389_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2141: except ValueError:
__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_12) < 0) __PYX_ERR(0, 2141, __pyx_L391_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_12);
+2142: raise
__Pyx_GIVEREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_4, __pyx_t_12); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 2142, __pyx_L391_except_error) }
+2143: except Exception as ex:
__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_12, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 2143, __pyx_L391_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_v_ex = __pyx_t_4; /*try:*/ { /* … */ /*finally:*/ { __pyx_L404_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_27, &__pyx_t_28, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_55 = __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_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_29); __Pyx_ErrRestore(__pyx_t_27, __pyx_t_28, __pyx_t_29); __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_55; goto __pyx_L391_except_error; } __pyx_L401_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L399_except_continue; } } __pyx_L399_except_continue:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L395_try_continue; } goto __pyx_L391_except_error;
+2144: errors.update(_build_error(name, f"Error parsing Typing: ", ex))
__pyx_t_15 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, __pyx_kp_u_Error_parsing_Typing, __pyx_v_ex); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2144, __pyx_L404_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_8 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2144, __pyx_L404_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2145: continue
goto __pyx_L401_continue; }
+2146: 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_L410_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_L410_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+2147: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L412; }
+2148: newval = _handle_list_of_dataclasses(f, name, value, _type, obj)
__pyx_t_34.__pyx_n = 1; __pyx_t_34.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_34); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2148, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
2149: else:
+2150: newval = _handle_list_of_dataclasses(f, name, value, _type, None)
/*else*/ { __pyx_t_34.__pyx_n = 1; __pyx_t_34.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_34); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2150, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0; } __pyx_L412:;
+2151: 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, 2151, __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, 2151, __pyx_L42_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2152: elif field_category == 'set':
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_field_category, __pyx_n_u_set, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2152, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+2153: 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_L420_try_end; __pyx_L413_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_L415_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_L419_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_L420_try_end:; }
+2154: newval = _parse_set_type(
__pyx_t_47.__pyx_n = 1; __pyx_t_47._parent = __pyx_v_obj; __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_set_type(__pyx_v_f, __pyx_v__type, __pyx_v_value, __pyx_v__encoder, __pyx_v_type_args, &__pyx_t_47); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2154, __pyx_L413_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
2155: f,
2156: _type,
2157: value,
2158: _encoder,
2159: type_args,
2160: obj
2161: )
+2162: 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, 2162, __pyx_L413_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_t_9, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2162, __pyx_L413_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2163: except ValueError:
__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_9, &__pyx_t_4, &__pyx_t_12) < 0) __PYX_ERR(0, 2163, __pyx_L415_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_12);
+2164: raise
__Pyx_GIVEREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_4, __pyx_t_12); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 2164, __pyx_L415_except_error) }
+2165: 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_12, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 2165, __pyx_L415_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_v_ex = __pyx_t_4; /*try:*/ { /* … */ /*finally:*/ { __pyx_L428_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27); 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_29); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_27); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_56 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_29); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_27); } __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_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_56; goto __pyx_L415_except_error; } __pyx_L425_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L423_except_continue; } } __pyx_L423_except_continue:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L419_try_continue; } goto __pyx_L415_except_error;
+2166: errors.update(_build_error(name, f"Error parsing Set: ", ex))
__pyx_t_8 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, __pyx_kp_u_Error_parsing_Set, __pyx_v_ex); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2166, __pyx_L428_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2166, __pyx_L428_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2167: continue
goto __pyx_L425_continue; }
2168: else:
2169: # fallback to builtin parse
+2170: 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_L441_try_end; __pyx_L434_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_L436_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_L440_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_L441_try_end:; } } __pyx_L50:;
+2171: newval = _parse_typing(
__pyx_t_41.__pyx_n = 3; __pyx_t_41.encoder = __pyx_v__encoder; __pyx_t_41.as_objects = __pyx_t_9; __pyx_t_41.parent = __pyx_v_obj; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_f, __pyx_v__type, __pyx_v_value, &__pyx_t_41); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2171, __pyx_L434_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_4); __pyx_t_4 = 0;
2172: f,
2173: _type,
2174: value,
2175: _encoder,
+2176: as_objects,
__pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2176, __pyx_L434_error) __Pyx_GOTREF(__pyx_t_9);
2177: obj
2178: )
+2179: 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, 2179, __pyx_L434_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely((PyObject_SetItem(__pyx_t_4, __pyx_v_name, __pyx_v_newval) < 0))) __PYX_ERR(0, 2179, __pyx_L434_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2180: except ValueError:
__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_4, &__pyx_t_9, &__pyx_t_12) < 0) __PYX_ERR(0, 2180, __pyx_L436_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12);
+2181: raise
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_9, __pyx_t_12); __pyx_t_4 = 0; __pyx_t_9 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 2181, __pyx_L436_except_error) }
+2182: except Exception as ex:
__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_12, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 2182, __pyx_L436_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); __pyx_v_ex = __pyx_t_9; /*try:*/ { /* … */ /*finally:*/ { __pyx_L449_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_27, &__pyx_t_28, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_29); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_57 = __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_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_29); __Pyx_ErrRestore(__pyx_t_27, __pyx_t_28, __pyx_t_29); __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_57; goto __pyx_L436_except_error; } __pyx_L446_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L444_except_continue; } } __pyx_L444_except_continue:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L440_try_continue; } goto __pyx_L436_except_error;
+2183: errors.update(_build_error(name, f"Error parsing Typing: ", ex))
__pyx_t_15 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, __pyx_kp_u_Error_parsing_Typing, __pyx_v_ex); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2183, __pyx_L449_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_8 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2183, __pyx_L449_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2184: continue
goto __pyx_L446_continue; }
2185: # then, call the validation process:
+2186: 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, 2186, __pyx_L42_error) __pyx_t_58.__pyx_n = 1; __pyx_t_58.as_objects = __pyx_v_as_objects; __pyx_t_4 = __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_58); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2186, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_error, __pyx_t_4); __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2186, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ }
+2187: errors[name] = error
if (unlikely((PyDict_SetItem(__pyx_v_errors, __pyx_v_name, __pyx_v_error) < 0))) __PYX_ERR(0, 2187, __pyx_L42_error)
+2188: except (TypeError, ValueError) as ex:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_ValueError); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters.processing_fields", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_12) < 0) __PYX_ERR(0, 2188, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_ex, __pyx_t_9); /*try:*/ { /* … */ /*finally:*/ { __pyx_L461_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_59); __pyx_t_59 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_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_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_16 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_60 = __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_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_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_60; goto __pyx_L44_except_error; } __pyx_L458_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L456_except_continue; } } __pyx_L456_except_continue:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L48_try_continue; }
+2189: _case = ex.__class__.__name__
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_ex, __pyx_n_s_class); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2189, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2189, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v__case, __pyx_t_15); __pyx_t_15 = 0;
+2190: 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, 2190, __pyx_L461_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)) { /* … */ }
+2191: raise
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_9, __pyx_t_12); __pyx_t_4 = 0; __pyx_t_9 = 0; __pyx_t_12 = 0; __PYX_ERR(0, 2191, __pyx_L461_error)
2192: else:
+2193: errors.update(_build_error(name, f"{_case}: at {f.name}: {f.type}", ex))
/*else*/ { __pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_14 = 127; __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_v__case, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u_at); __pyx_t_13 += 5; __Pyx_GIVEREF(__pyx_kp_u_at); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_kp_u_at); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_name_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_59 = __Pyx_PyObject_FormatSimple(__pyx_t_8, __pyx_empty_unicode); if (unlikely(!__pyx_t_59)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_59); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_59) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_59) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_59); __Pyx_GIVEREF(__pyx_t_59); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_59); __pyx_t_59 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_kp_u__7); __pyx_t_59 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_2); if (unlikely(!__pyx_t_59)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_59); __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_t_59, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_59); __pyx_t_59 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_15, 5, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_8), __pyx_v_ex); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2193, __pyx_L461_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2194: continue
goto __pyx_L458_continue; } }
+2195: 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_12, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 2195, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4);
+2196: raise
__Pyx_GIVEREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestoreWithState(__pyx_t_12, __pyx_t_9, __pyx_t_4); __pyx_t_12 = 0; __pyx_t_9 = 0; __pyx_t_4 = 0; __PYX_ERR(0, 2196, __pyx_L44_except_error) }
+2197: except Exception as ex:
__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_9, &__pyx_t_12) < 0) __PYX_ERR(0, 2197, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_ex, __pyx_t_9); /*try:*/ { /* … */ /*finally:*/ { __pyx_L475_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_59); __pyx_t_59 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_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_23); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_11 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_61 = __pyx_filename; { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 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_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_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_61; goto __pyx_L44_except_error; } __pyx_L472_continue: { __Pyx_DECREF(__pyx_v_ex); __pyx_v_ex = 0; goto __pyx_L470_except_continue; } } __pyx_L470_except_continue:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L48_try_continue; } goto __pyx_L44_except_error;
+2198: errors.update(_build_error(name, f"Wrong Type for {f.name}: {f.type}", ex))
__pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_8); __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_8, 0, __pyx_kp_u_Wrong_Type_for); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_name_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_59 = __Pyx_PyObject_FormatSimple(__pyx_t_15, __pyx_empty_unicode); if (unlikely(!__pyx_t_59)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_59); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_59) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_59) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_59); __Pyx_GIVEREF(__pyx_t_59); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_59); __pyx_t_59 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_13 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u__7); __pyx_t_59 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_type_2); if (unlikely(!__pyx_t_59)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_59); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_59, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_59); __pyx_t_59 = 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_8, 3, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __pyx_f_9datamodel_10converters__build_error(__pyx_v_name, ((PyObject*)__pyx_t_15), __pyx_v_ex); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_errors, __pyx_t_8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2198, __pyx_L475_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2199: continue
goto __pyx_L472_continue; }
2200: # Return Errors (if any)
+2201: return errors
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_errors); __pyx_r = __pyx_v_errors; goto __pyx_L0;
2202:
+2203: 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_15); __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_XDECREF(__pyx_v_inner_type); __Pyx_XDECREF(__pyx_v_item); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_9datamodel_10converters__validation_ { int __pyx_n; int as_objects; };
2204: str name,
2205: object value,
2206: object f,
2207: object _type,
2208: object meta,
2209: str field_category,
+2210: 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_v_inner_type = NULL; PyObject *__pyx_v_item = 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; } }
2211: ):
2212: """
2213: _validation_.
2214: TODO: cover validations as length, not_null, required, max, min, etc
2215: """
+2216: cdef object val_type = type(value)
__Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_value)));
__pyx_v_val_type = ((PyObject *)Py_TYPE(__pyx_v_value));
+2217: cdef str error = None
__Pyx_INCREF(Py_None);
__pyx_v_error = ((PyObject*)Py_None);
2218: cdef dict err = {
+2219: "field": name,
__pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2219, __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, 2219, __pyx_L1_error)
+2220: "value": value,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_value_2, __pyx_v_value) < 0) __PYX_ERR(0, 2219, __pyx_L1_error)
+2221: "error": None
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_error_3, Py_None) < 0) __PYX_ERR(0, 2219, __pyx_L1_error) __pyx_v_err = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
2222: }
2223:
+2224: 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, 2224, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2224, __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, 2224, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2224, __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, 2224, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+2225: 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; }
+2226: _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, 2226, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2227: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L11_try_return;
+2228: 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, 2228, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+2229: 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, 2229, __pyx_L9_except_error) } goto __pyx_L9_except_error;
2230:
+2231: if isinstance(value, set):
__pyx_t_2 = PySet_Check(__pyx_v_value);
if (__pyx_t_2) {
/* … */
}
2232: # Just validate that all elements match the expected type if specified
+2233: if hasattr(f, '_inner_type') and f._inner_type is not None and not is_empty(value):
__pyx_t_3 = __Pyx_HasAttr(__pyx_v_f, __pyx_n_u_inner_type); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 2233, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L17_bool_binop_done; } __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = (__pyx_t_9 != Py_None); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L17_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, 2233, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_3); __pyx_t_2 = __pyx_t_10; __pyx_L17_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+2234: inner_type = f._inner_type
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_inner_type = __pyx_t_9; __pyx_t_9 = 0;
2235: # For primitive types, we can use isinstance
+2236: if inner_type in (str, int, float, bool):
__Pyx_INCREF(__pyx_v_inner_type); __pyx_t_9 = __pyx_v_inner_type; __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2236, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L21_bool_binop_done; } __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2236, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L21_bool_binop_done; } __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2236, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L21_bool_binop_done; } __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject*)&PyBool_Type), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2236, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2236, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_10; __pyx_L21_bool_binop_done:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = __pyx_t_2; if (__pyx_t_10) { /* … */ }
+2237: for item in value:
if (likely(PyList_CheckExact(__pyx_v_value)) || PyTuple_CheckExact(__pyx_v_value)) { __pyx_t_9 = __pyx_v_value; __Pyx_INCREF(__pyx_t_9); __pyx_t_11 = 0; __pyx_t_12 = NULL; } else { __pyx_t_11 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2237, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_12)) { if (likely(PyList_CheckExact(__pyx_t_9))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2237, __pyx_L1_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_11); __Pyx_INCREF(__pyx_t_8); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 2237, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2237, __pyx_L1_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_11); __Pyx_INCREF(__pyx_t_8); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 2237, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_12(__pyx_t_9); 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, 2237, __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_9); __pyx_t_9 = 0;
+2238: if not isinstance(item, inner_type):
__pyx_t_10 = PyObject_IsInstance(__pyx_v_item, __pyx_v_inner_type); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 2238, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_10); if (__pyx_t_2) { /* … */ }
+2239: err["error"] = f"Set item {item} is not of expected type {inner_type.__name__}"
__pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Set_item); __pyx_t_13 += 9; __Pyx_GIVEREF(__pyx_kp_u_Set_item); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_Set_item); __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_item, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_is_not_of_expected_type); __pyx_t_13 += 25; __Pyx_GIVEREF(__pyx_kp_u_is_not_of_expected_type); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u_is_not_of_expected_type); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_inner_type, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_8, 3, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely((PyDict_SetItem(__pyx_v_err, __pyx_n_u_error_3, __pyx_t_15) < 0))) __PYX_ERR(0, 2239, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2240: return err
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_err); __pyx_r = __pyx_v_err; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L0;
+2241: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2242:
2243: # If the field has a cached validator, use it.
+2244: 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, 2244, __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) { /* … */ }
+2245: try:
{ /*try:*/ { /* … */ } __pyx_L30_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L32_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_L34_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; }
+2246: error = f.validator(f, name, value, _type)
__pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_validator); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2246, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_8 = NULL; __pyx_t_16 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_16 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_8, __pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_16, 4+__pyx_t_16); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2246, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } if (!(likely(PyUnicode_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_9))) __PYX_ERR(0, 2246, __pyx_L30_error) __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+2247: if error:
__pyx_t_2 = (__pyx_v_error != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_error) != 0);
if (__pyx_t_2) {
/* … */
}
+2248: err["error"] = error
if (unlikely((PyDict_SetItem(__pyx_v_err, __pyx_n_u_error_3, __pyx_v_error) < 0))) __PYX_ERR(0, 2248, __pyx_L30_error)
+2249: return err
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_err); __pyx_r = __pyx_v_err; goto __pyx_L34_try_return;
2250: else:
2251: # calling validation_constraints:
+2252: if _type in (str, int, float):
/*else*/ { __Pyx_INCREF(__pyx_v__type); __pyx_t_9 = __pyx_v__type; __pyx_t_15 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)(&PyUnicode_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2252, __pyx_L30_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2252, __pyx_L30_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L38_bool_binop_done; } __pyx_t_15 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2252, __pyx_L30_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2252, __pyx_L30_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L38_bool_binop_done; } __pyx_t_15 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2252, __pyx_L30_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2252, __pyx_L30_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_2 = __pyx_t_10; __pyx_L38_bool_binop_done:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = __pyx_t_2; if (__pyx_t_10) { /* … */ } }
+2253: return _validate_constraints(f, name, value, _type, val_type)
__Pyx_XDECREF(__pyx_r); __pyx_t_9 = __pyx_f_9datamodel_10validation__validate_constraints(__pyx_v_f, __pyx_v_name, __pyx_v_value, __pyx_v__type, __pyx_v_val_type); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2253, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_9); __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L34_try_return;
+2254: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L34_try_return;
+2255: 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_15, &__pyx_t_8) < 0) __PYX_ERR(0, 2255, __pyx_L32_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_8);
+2256: raise
__Pyx_GIVEREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_15, __pyx_t_8); __pyx_t_9 = 0; __pyx_t_15 = 0; __pyx_t_8 = 0; __PYX_ERR(0, 2256, __pyx_L32_except_error) } goto __pyx_L32_except_error;
2257: else:
2258: # capturing other errors from validator:
+2259: return _validation(f, name, value, _type, val_type, field_category, as_objects)
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_validation); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = NULL; __pyx_t_16 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_16 = 1; } } #endif { PyObject *__pyx_callargs[8] = {__pyx_t_1, __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_8 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_16, 7+__pyx_t_16); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_r = __pyx_t_8; __pyx_t_8 = 0; goto __pyx_L0; }
2260:
+2261: 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; }
2262: # Validate Primary Key
+2263: 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, 2263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_metadata = __pyx_t_1; __pyx_t_1 = 0;
+2264: 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:; }
+2265: 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, 2265, __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, 2265, __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, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14);
+2266: 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, 2266, __pyx_L3_error) if (likely(__pyx_t_6)) { goto __pyx_L10; }
2267: pass
2268: else:
+2269: raise ValueError(
/*else*/ { /* … */ __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2269, __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, 2269, __pyx_L3_error) } __pyx_L10:;
+2270: f":: Missing Primary Key *{name}*"
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2270, __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, 2270, __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, 2270, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2271: )
+2272: 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;
2273: pass
2274: # Validate Required
+2275: 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:; }
+2276: 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, 2276, __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, 2276, __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, 2276, __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, 2276, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15);
+2277: 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, 2277, __pyx_L11_error) if (__pyx_t_6) { /* … */ }
+2278: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L15_try_return;
+2279: if value is not None:
__pyx_t_6 = (__pyx_v_value != Py_None); if (__pyx_t_6) { /* … */ }
+2280: 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;
+2281: raise ValueError(
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2281, __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, 2281, __pyx_L11_error)
+2282: f":: Missing Required Field *{name}*"
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2282, __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, 2282, __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, 2282, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2283: )
+2284: 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, 2284, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_11);
+2285: 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, 2285, __pyx_L13_except_error) }
+2286: 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, 2286, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1);
+2287: 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;
2288: # Nullable:
+2289: 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:; }
+2290: 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, 2290, __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, 2290, __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, 2290, __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, 2290, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16);
+2291: raise ValueError(
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2291, __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, 2291, __pyx_L26_error)
+2292: f":: *{name}* Cannot be null."
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2292, __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, 2292, __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, 2292, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2293: )
+2294: 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, 2294, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_11);
+2295: 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, 2295, __pyx_L28_except_error) }
+2296: 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, 2296, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5);
+2297: 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;
+2298: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2299:
2300:
+2301: 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_8genexpr7__pyx_v_k = NULL; PyObject *__pyx_8genexpr7__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_8genexpr7__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr7__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, 2301, __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, 2301, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, 1); __PYX_ERR(0, 2301, __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, 2301, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, 2); __PYX_ERR(0, 2301, __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, 2301, __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, 2301, __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, 2301, __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, 2301, __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, 2301, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__48); __Pyx_GIVEREF(__pyx_tuple__48); /* … */ __pyx_t_3 = __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_3)) __PYX_ERR(0, 2301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_tuple__45); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_type, __pyx_t_3) < 0) __PYX_ERR(0, 2301, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ struct __pyx_opt_args_9datamodel_10converters_parse_type { int __pyx_n; PyObject *encoder; };
+2302: cdef object origin = get_origin(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2302, __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, 2302, __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;
+2303: cdef tuple args = None
__Pyx_INCREF(Py_None);
__pyx_v_args = ((PyObject*)Py_None);
+2304: 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, 2304, __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, 2304, __pyx_L1_error) __pyx_v_type_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2305: 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, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_type_args = __pyx_t_1; __pyx_t_1 = 0;
+2306: 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, 2306, __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, 2306, __pyx_L1_error) __pyx_v_typeinfo = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
2307:
+2308: if isinstance(T, NewType):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_NewType); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2308, __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, 2308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
2309: # change type if is a NewType object.
+2310: T = T.__supertype__
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_T, __pyx_n_s_supertype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_T, __pyx_t_1); __pyx_t_1 = 0;
2311:
2312: # Check if the data is already of the correct type
+2313: 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, 2313, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+2314: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2315:
+2316: 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, 2316, __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, 2316, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ goto __pyx_L5; }
+2317: args = type_args or ()
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_type_args); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2317, __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, 2317, __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;
+2318: 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, 2318, __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; }
+2319: if args:
__pyx_t_5 = (__pyx_v_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_args) != 0);
if (__pyx_t_5) {
/* … */
}
+2320: 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, 2320, __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, 2320, __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, 2320, __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, 2320, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_k, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr7__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, 2320, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __pyx_f_9datamodel_10converters_parse_type(__pyx_v_field, __pyx_t_10, __pyx_8genexpr7__pyx_v_v, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2320, __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_8genexpr7__pyx_v_k, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 2320, __pyx_L14_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_k); __pyx_8genexpr7__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_v); __pyx_8genexpr7__pyx_v_v = 0; goto __pyx_L17_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_k); __pyx_8genexpr7__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_v); __pyx_8genexpr7__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;
2321:
+2322: 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, 2322, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+2323: 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) { /* … */ }
+2324: data = [data]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2324, __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, 2324, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+2325: arg_type = args[0]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 2325, __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, 2325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+2326: 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, 2326, __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, 2326, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+2327: 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; }
+2328: 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, 2328, __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, 2328, __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;
+2329: 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, 2329, __pyx_L22_error) if (__pyx_t_6) { /* … */ }
+2330: result = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2330, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_result = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2331: 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, 2331, __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, 2331, __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, 2331, __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, 2331, __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, 2331, __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, 2331, __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, 2331, __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, 2331, __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, 2331, __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;
+2332: if isinstance(x, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_x);
if (__pyx_t_6) {
/* … */
goto __pyx_L31;
}
+2333: 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, 2333, __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, 2333, __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, 2333, __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, 2333, __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, 2333, __pyx_L22_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2334: 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; }
+2335: result.append(t(*x))
__pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2335, __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, 2335, __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, 2335, __pyx_L22_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2336: else:
+2337: 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, 2337, __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, 2337, __pyx_L22_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L31:;
+2338: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L26_try_return;
2339: else:
+2340: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L26_try_return; }
+2341: 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, 2341, __pyx_L24_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3);
+2342: 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;
+2343: 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, 2343, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+2344: if isinstance(data, list):
__pyx_t_6 = PyList_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
}
+2345: result = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2346: 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, 2346, __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, 2346, __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, 2346, __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, 2346, __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, 2346, __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, 2346, __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, 2346, __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, 2346, __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, 2346, __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;
2347: # is already a dataclass:
+2348: 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, 2348, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L40; }
+2349: 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, 2349, __pyx_L1_error)
+2350: elif isinstance(d, list):
__pyx_t_6 = PyList_Check(__pyx_v_d);
if (__pyx_t_6) {
/* … */
goto __pyx_L40;
}
+2351: result.append(arg_type(*d))
__pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2351, __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, 2351, __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, 2351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2352: elif isinstance(d, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_d);
if (__pyx_t_6) {
/* … */
goto __pyx_L40;
}
+2353: 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, 2353, __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, 2353, __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, 2353, __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, 2353, __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, 2353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2354: else:
+2355: 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, 2355, __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, 2355, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L40:;
+2356: return result
__Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_result)) { __Pyx_RaiseUnboundLocalError("result"); __PYX_ERR(0, 2356, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
2357: else:
+2358: result = []
/*else*/ { __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2359: if is_iterable(data):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2359, __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, 2359, __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, 2359, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ }
+2360: 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, 2360, __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, 2360, __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, 2360, __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, 2360, __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, 2360, __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, 2360, __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, 2360, __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, 2360, __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, 2360, __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;
2361: # escalar value:
+2362: 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, 2362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_converted_item, __pyx_t_1); __pyx_t_1 = 0;
+2363: 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, 2363, __pyx_L1_error)
+2364: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+2365: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0; }
+2366: 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, 2366, __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, 2366, __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:;
+2367: args = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2367, __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, 2367, __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, 2367, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
2368: # Handling Optional types
+2369: 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, 2369, __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, 2369, __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, 2369, __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, 2369, __pyx_L1_error) __pyx_t_6 = __pyx_t_19; __pyx_L51_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+2370: if data is None:
__pyx_t_6 = (__pyx_v_data == Py_None); if (__pyx_t_6) { /* … */ }
+2371: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2372: # Determine the non-None type.
+2373: 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, 2373, __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, 2373, __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, 2373, __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, 2373, __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, 2373, __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, 2373, __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;
+2374: 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, 2374, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2374, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+2375: field.args = args
if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_v_args) < 0) __PYX_ERR(0, 2375, __pyx_L1_error)
+2376: 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, 2376, __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, 2376, __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, 2376, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2377: 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)) { /* … */ }
+2378: 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, 2378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2379: else:
+2380: 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, 2380, __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, 2380, __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, 2380, __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, 2380, __pyx_L1_error) }
2381: # If the non-None type is exactly dict, return the dict as is.
+2382: if non_none_arg is dict:
__pyx_t_6 = (__pyx_v_non_none_arg == ((PyObject *)(&PyDict_Type))); if (__pyx_t_6) { /* … */ }
+2383: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2384: # Otherwise, recursively parse using the non-None type.
+2385: field.args = args
if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_v_args) < 0) __PYX_ERR(0, 2385, __pyx_L1_error)
+2386: 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, 2386, __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, 2386, __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, 2386, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2387: 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, 2387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2388: 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); }
+2389: t = args[0]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 2389, __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, 2389, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_t = __pyx_t_1; __pyx_t_1 = 0;
+2390: 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, 2390, __pyx_L60_error) if (__pyx_t_6) { /* … */ goto __pyx_L66; }
+2391: if isinstance(data, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
goto __pyx_L67;
}
+2392: 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, 2392, __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, 2392, __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, 2392, __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, 2392, __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;
+2393: 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; }
+2394: data = t(*data)
__pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2394, __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, 2394, __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;
2395: else:
2396: ## is already a dataclass, returning
+2397: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return; } __pyx_L67:;
+2398: elif callable(t):
__pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 2398, __pyx_L60_error) if (__pyx_t_6) { /* … */ } __pyx_L66:;
+2399: 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, 2399, __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, 2399, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
2400: # there is also a nested typing:
+2401: 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, 2401, __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, 2401, __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) { /* … */ }
+2402: 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, 2402, __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, 2402, __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;
+2403: 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, 2403, __pyx_L60_error) if (__pyx_t_6) { /* … */ }
+2404: result = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2404, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2405: 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, 2405, __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, 2405, __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, 2405, __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, 2405, __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, 2405, __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, 2405, __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, 2405, __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, 2405, __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, 2405, __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;
+2406: if isinstance(x, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_x);
if (__pyx_t_6) {
/* … */
goto __pyx_L77;
}
+2407: 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, 2407, __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, 2407, __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, 2407, __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, 2407, __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, 2407, __pyx_L60_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2408: else:
+2409: result.append(arg(*x))
/*else*/ { __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2409, __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, 2409, __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, 2409, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L77:;
+2410: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L64_try_return;
+2411: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return;
2412: else:
+2413: 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:; } }
+2414: 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, 2414, __pyx_L79_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2414, __pyx_L79_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ }
+2415: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L83_try_return;
+2416: fn = encoders[t]
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_encoders); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2416, __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, 2416, __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;
+2417: 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:; }
+2418: if data is not None:
__pyx_t_6 = (__pyx_v_data != Py_None); if (__pyx_t_6) { /* … */ }
+2419: 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, 2419, __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;
+2420: 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, 2420, __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; }
2421: pass
+2422: 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, 2422, __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;
+2423: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_27); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2423, __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, 2423, __pyx_L105_error) }
+2424: f"Model: Error parsing {T}, {exc}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2424, __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, 2424, __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, 2424, __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, 2424, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2425: )
+2426: 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;
2427: pass
+2428: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return;
+2429: 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;
2430: pass
+2431: 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) {
/* … */
}
+2432: 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, 2432, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2433: elif origin is list:
__pyx_t_6 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_6) { /* … */ }
+2434: 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, 2434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2435: elif origin is not None:
__pyx_t_6 = (__pyx_v_origin != Py_None); if (__pyx_t_6) { /* … */ }
2436: # Other typing constructs can be handled here
+2437: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2438: else:
+2439: 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, 2439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } __pyx_L5:;