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, Set
__pyx_t_2 = PyList_New(9); 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_INCREF(__pyx_n_s_Set); __Pyx_GIVEREF(__pyx_n_s_Set); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 8, __pyx_n_s_Set)) __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_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Set); 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_Set, __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__20); 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__20 = PyTuple_Pack(3, __pyx_n_s_asyncpg, __pyx_n_s_pgproto, __pyx_n_s_pgproto); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20);
+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__21); 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__21 = PyTuple_Pack(2, __pyx_n_s_datamodel, __pyx_n_s_rs_parsers); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__21); __Pyx_GIVEREF(__pyx_tuple__21);
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_typing(object obj):
static int __pyx_f_9datamodel_10converters_is_typing(PyObject *__pyx_v_obj) { int __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("datamodel.converters.is_typing", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0049: return PyObject_HasAttr(obj, '__module__') and obj.__module__ == 'typing'
__pyx_t_2 = PyObject_HasAttr(__pyx_v_obj, __pyx_n_u_module); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L3_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_module); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_2; __pyx_L3_bool_binop_done:; __pyx_r = __pyx_t_1; goto __pyx_L0;
0050:
+0051: 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; }
0052: """
0053: Determines if a value should be considered empty.
0054:
0055: Enhanced to handle different container types properly, including:
0056: - None
0057: - Empty strings
0058: - Empty lists, tuples, sets
0059: - _MISSING_TYPE (used in default value checks)
0060:
0061: Returns True if the value is considered empty, False otherwise.
0062: """
0063: # None is always empty
+0064: if value is None:
__pyx_t_1 = (__pyx_v_value == Py_None); if (__pyx_t_1) { /* … */ }
+0065: return True
__pyx_r = 1; goto __pyx_L0;
0066:
0067: # Field default missing markers
+0068: 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, 68, __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, 68, __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, 68, __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, 68, __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, 68, __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) { /* … */ }
+0069: return True
__pyx_r = 1; goto __pyx_L0;
0070:
0071: # Empty strings are considered empty
+0072: 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, 72, __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, 72, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L8_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0073: return True
__pyx_r = 1; goto __pyx_L0;
0074:
+0075: 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, 75, __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, 75, __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, 75, __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, 75, __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) { /* … */ }
+0076: return False
__pyx_r = 0; goto __pyx_L0;
0077:
+0078: 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, 78, __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, 78, __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, 78, __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, 78, __pyx_L1_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 78, __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, 78, __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) { /* … */ }
+0079: return True
__pyx_r = 1; goto __pyx_L0;
0080:
0081: # Special case for containers: empty containers are NOT considered empty
0082: # because they are valid initialized values
+0083: if PyObject_IsInstance(value, (list, tuple, set)):
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __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, 83, __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, 83, __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, 83, __pyx_L1_error); __pyx_t_1 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0084: return False # Return False even for empty containers
__pyx_r = 0; goto __pyx_L0;
0085:
0086: # Numeric values of 0 are not considered empty
+0087: if PyObject_IsInstance(value, (int, float)) and value == 0:
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __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, 87, __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, 87, __pyx_L1_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 87, __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, 87, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L18_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+0088: return False
__pyx_r = 0; goto __pyx_L0;
0089:
0090: # Objects with explicit "empty" attribute
+0091: 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, 91, __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, 91, __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, 91, __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) { /* … */ }
+0092: return False
__pyx_r = 0; goto __pyx_L0;
0093:
0094: # Fallback to Python's truthiness
+0095: if not value:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 95, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { /* … */ }
+0096: return True
__pyx_r = 1; goto __pyx_L0;
0097:
0098: # Default: not empty
+0099: return False
__pyx_r = 0; goto __pyx_L0;
0100:
+0101: 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, 101, __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, 101, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("has_attribute", 1, 2, 2, 1); __PYX_ERR(0, 101, __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, 101, __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, 101, __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, 101, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __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__22 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_attr); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* … */ __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__23)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __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, 101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_has_attribute, 101, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 101, __pyx_L1_error)
0102: """Returns True if obj has the attribute attr."""
+0103: return PyObject_HasAttr(obj, attr)
__pyx_r = PyObject_HasAttr(__pyx_v_obj, __pyx_v_attr);
goto __pyx_L0;
0104:
+0105: 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, 105, __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, 105, __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, 105, __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, 105, __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__24 = PyTuple_Pack(1, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); /* … */ __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__25)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 105, __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, 105, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_string_2, 105, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 105, __pyx_L1_error)
0106: """
0107: Returns a string version of an object.
0108: """
+0109: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0110: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0111: if isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0112: 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, 112, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyObject*)__pyx_v_obj); goto __pyx_L0;
+0113: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0114: 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; }
+0115: 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, 115, __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, 115, __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, 115, __pyx_L6_error) __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L10_try_return;
+0116: 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, 116, __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;
+0117: 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, 117, __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, 117, __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, 117, __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, 117, __pyx_L17_error) }
+0118: if isinstance(obj, (int, float, Decimal)):
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 118, __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) { /* … */ }
0119: # its a number
+0120: return str(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_Unicode(__pyx_v_obj); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L0;
+0121: if callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 121, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
0122: # its a function callable returning a value
+0123: 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); }
+0124: 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, 124, __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;
0125: # Recursively call to_string on that result:
+0126: 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, 126, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L32_try_return;
+0127: 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;
0128: pass
0129: # For any other arbitrary type, explicitly fail:
+0130: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 130, __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, 130, __pyx_L1_error)
+0131: 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, 131, __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, 131, __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, 131, __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, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0132: )
0133:
+0134: 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, 134, __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, 134, __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, 134, __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, 134, __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__26)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __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, 134, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_uuid, 134, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 134, __pyx_L1_error)
0135: """Returns a UUID version of a str column.
0136: """
+0137: if isinstance(obj, pgproto.UUID):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __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, 137, __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, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
0138: # If it's asyncpg's UUID, convert by casting to string first
+0139: 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, 139, __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, 139, __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, 139, __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;
+0140: if isinstance(obj, UUID):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __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, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
0141: # already an uuid
+0142: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0143: elif callable(obj):
__pyx_t_3 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 143, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
0144: # its a function callable returning a value
+0145: 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); }
+0146: return UUID(obj())
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __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, 146, __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, 146, __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;
+0147: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0148: pass
+0149: 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; }
+0150: 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, 150, __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, 150, __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, 150, __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;
+0151: 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, 151, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4);
+0152: 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;
0153:
0154:
+0155: 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, 155, __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, 155, __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, 155, __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, 155, __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, 155, __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__27)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __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, 155, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_slugify_camelcase, 155, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 155, __pyx_L1_error)
0156: """slugify_camelcase.
0157:
0158: Converting CamelCase into a spaced version, but don’t double-space
0159: if the string already contains spaces or uppercase letters follow
0160: existing spaces.
0161: """
+0162: 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) {
/* … */
}
+0163: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0164:
+0165: 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, 165, __pyx_L1_error) __pyx_t_4 = __Pyx_PyUnicode_FromOrdinal(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __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, 165, __pyx_L1_error); __pyx_t_4 = 0; __pyx_v_slugified = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0166: 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, 166, __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, 166, __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;
+0167: 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, 167, __pyx_L1_error) __pyx_v_c = __pyx_t_3;
0168: # Condition: if c is uppercase AND the previous character isn't a space,
0169: # insert a space before it.
+0170: 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, 170, __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, 170, __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, 170, __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, 170, __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) { /* … */ }
+0171: 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, 171, __pyx_L1_error)
+0172: slugified.append(c)
__pyx_t_5 = __Pyx_PyUnicode_FromOrdinal(__pyx_v_c); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __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, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
+0173: 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, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L0;
0174:
0175:
+0176: 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, 176, __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, 176, __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, 176, __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, 176, __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__28)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __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, 176, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_date, 176, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 176, __pyx_L1_error)
0177: """to_date.
0178:
0179: Returns obj converted to date.
0180: """
+0181: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0182: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_Date *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0183: elif obj == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __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, 183, __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, 183, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+0184: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_Date *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0185: if isinstance(obj, datetime.date):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_date);
if (__pyx_t_1) {
/* … */
}
+0186: 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, 186, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyDateTime_Date *)__pyx_v_obj); goto __pyx_L0;
+0187: 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) { /* … */ }
+0188: 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, 188, __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, 188, __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, 188, __pyx_L1_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
+0189: 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) {
/* … */
}
+0190: 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, 190, __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, 190, __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;
0191: # Handle Unix epoch via Rust's `to_timestamp`
+0192: 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) { /* … */ }
+0193: 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); }
+0194: 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, 194, __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, 194, __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, 194, __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, 194, __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, 194, __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, 194, __pyx_L13_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L17_try_return;
+0195: 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;
0196: pass
0197: # using rust todate function
+0198: 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); }
+0199: 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, 199, __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, 199, __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, 199, __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, 199, __pyx_L19_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L23_try_return;
+0200: 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;
0201: pass
0202: # Fallback to Cython-native ciso8601 parsing
+0203: 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; }
+0204: 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, 204, __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, 204, __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, 204, __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, 204, __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, 204, __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, 204, __pyx_L25_error) __pyx_r = ((PyDateTime_Date *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L29_try_return;
+0205: 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, 205, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
0206: pass
+0207: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 207, __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, 207, __pyx_L27_except_error) } goto __pyx_L27_except_error;
+0208: f"Can't convert invalid data *{obj}* to date"
__pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 208, __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, 208, __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, 208, __pyx_L27_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
0209: )
0210:
0211:
+0212: 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, 212, __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, 212, __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, 212, __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, 212, __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__29)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __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, 212, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_datetime, 212, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 212, __pyx_L1_error)
0213: """to_datetime.
0214:
0215: Returns obj converted to datetime.
0216: """
+0217: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0218: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_DateTime *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0219: elif obj == _MISSING_TYPE:
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __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, 219, __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, 219, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+0220: return None
__Pyx_XDECREF((PyObject *)__pyx_r); __pyx_r = ((PyDateTime_DateTime *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0;
+0221: if isinstance(obj, datetime.datetime):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_datetime);
if (__pyx_t_1) {
/* … */
}
+0222: 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, 222, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyDateTime_DateTime *)__pyx_v_obj); goto __pyx_L0;
+0223: 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) {
/* … */
}
+0224: 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, 224, __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, 224, __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;
0225: # Handle Unix epoch via Rust's `to_timestamp`
+0226: 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) { /* … */ }
+0227: 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); }
+0228: 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, 228, __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, 228, __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, 228, __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, 228, __pyx_L11_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L15_try_return;
+0229: 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;
0230: pass
+0231: 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); }
+0232: 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, 232, __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, 232, __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, 232, __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, 232, __pyx_L17_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L21_try_return;
+0233: 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;
0234: pass
+0235: 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; }
+0236: 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, 236, __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, 236, __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, 236, __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, 236, __pyx_L23_error) __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L27_try_return;
+0237: 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, 237, __pyx_L25_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
+0238: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 238, __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, 238, __pyx_L25_except_error) } goto __pyx_L25_except_error;
+0239: f"Can't convert invalid data *{obj}* to datetime"
__pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 239, __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, 239, __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, 239, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
0240: )
0241:
0242:
+0243: 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, 243, __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, 243, __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, 243, __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, 243, __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__30)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __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, 243, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_integer, 243, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 243, __pyx_L1_error)
0244: """to_integer.
0245:
0246: Returns object converted to integer.
0247: """
+0248: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0249: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0250: if isinstance(obj, int):
__pyx_t_1 = PyInt_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0251: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0252: if isinstance(obj, unicode):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0253: 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, 253, __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, 253, __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;
+0254: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0255: 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; }
+0256: return int(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L11_try_return;
+0257: 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, 257, __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;
+0258: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 258, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0259: 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, 259, __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, 259, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0260: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 258, __pyx_L18_error) }
+0261: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 261, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L6; }
0262: # its a function callable returning a value
+0263: 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); }
+0264: 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, 264, __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;
+0265: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L25_exception_handled;
}
0266: pass
0267: else:
+0268: 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:;
+0269: return int(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L34_try_return;
+0270: 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, 270, __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;
+0271: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 271, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0272: 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, 272, __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, 272, __pyx_L41_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0273: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 271, __pyx_L41_error) }
0274:
+0275: 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, 275, __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, 275, __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, 275, __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, 275, __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__31)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __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, 275, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_float, 275, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 275, __pyx_L1_error)
0276: """to_float.
0277:
0278: Returns object converted to float.
0279: """
+0280: if isinstance(obj, (float, Decimal)):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __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) { /* … */ }
+0281: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0282: elif isinstance(obj, _MISSING_TYPE):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_MISSING_TYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __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, 282, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0283: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0284: elif callable(obj):
__pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 284, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L3; }
0285: # its a function callable returning a value
+0286: 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); }
+0287: 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, 287, __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;
+0288: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L7_exception_handled;
}
0289: pass
0290: else:
+0291: 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:;
+0292: return float(obj)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Float(__pyx_v_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L16_try_return;
+0293: 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, 293, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8);
+0294: 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;
0295:
+0296: 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, 296, __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, 296, __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, 296, __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, 296, __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__32)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __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, 296, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_decimal, 296, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 296, __pyx_L1_error)
0297: """to_decimal.
0298:
0299: Returns a Decimal version of object.
0300: """
+0301: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0302: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0303: if isinstance(obj, Decimal):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __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, 303, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0304: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0305: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 305, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0306: # its a function callable returning a value
+0307: 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); }
+0308: 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, 308, __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;
+0309: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0310: pass
0311: else:
+0312: 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:;
+0313: return Decimal(obj)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 313, __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, 313, __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;
+0314: 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, 314, __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, 314, __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; } } }
+0315: raise ValueError(
__pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 315, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0316: 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, 316, __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, 316, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0317: ) from ex
__Pyx_Raise(__pyx_t_9, 0, 0, __pyx_v_ex); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 315, __pyx_L22_error) }
+0318: 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, 318, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+0319: 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;
0320:
+0321: 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, 321, __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, 321, __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__33, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __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, 321, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_u_d_1_3_d_1_2_d_1_2_d_1_6); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__33); __Pyx_GIVEREF(__pyx_tuple__33);
0322:
+0323: 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; }
+0324: if not s:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_s); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 324, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0325: return 0
__pyx_r = 0; goto __pyx_L0;
0326: # Pad zeros to ensure the fraction length in microseconds
+0327: 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, 327, __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, 327, __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, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4);
+0328: 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, 328, __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, 328, __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, 328, __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, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__5); __Pyx_GIVEREF(__pyx_slice__5);
0329:
+0330: 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, 330, __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, 330, __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, 330, __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, 330, __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__34)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 330, __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, 330, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_timedelta, 330, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 330, __pyx_L1_error)
0331:
+0332: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0333: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0334: if isinstance(obj, datetime.timedelta):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_timedelta);
if (__pyx_t_1) {
/* … */
}
+0335: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0336:
+0337: 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) {
/* … */
}
+0338: 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, 338, __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, 338, __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;
0339:
+0340: m = TIMEDELTA_RE.match(obj)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_TIMEDELTA_RE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __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, 340, __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, 340, __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;
+0341: if not m:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_m); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 341, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0342: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
0343:
+0344: 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; }
+0345: 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, 345, __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, 345, __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, 345, __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;
+0346: 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, 346, __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, 346, __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, 346, __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, 346, __pyx_L9_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0347: 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, 347, __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, 347, __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;
+0348: 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, 348, __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, 348, __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, 348, __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;
0349: tdelta = (
+0350: 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, 350, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0351: hours=int(hours),
__pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 351, __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, 351, __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, 351, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0352: minutes=int(minutes),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_minutes); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 352, __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, 351, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0353: seconds=int(seconds),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_seconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 353, __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, 351, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+0354: microseconds=int(microseconds),
__pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_microseconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 354, __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, 351, __pyx_L9_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
0355: )
+0356: * negate
__pyx_t_5 = PyNumber_Multiply(__pyx_t_12, __pyx_v_negate); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 356, __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;
0357: )
+0358: return tdelta
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_tdelta); __pyx_r = __pyx_v_tdelta; goto __pyx_L13_try_return;
+0359: 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, 359, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_11);
+0360: raise ValueError(
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __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, 360, __pyx_L11_except_error) } goto __pyx_L11_except_error;
+0361: 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, 361, __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, 361, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0362: )
0363:
+0364: 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, 364, __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, 364, __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__35, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __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, 364, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_u_d_1_2_d_1_2_d_1_2_d_1_6); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35);
0365:
+0366: 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, 366, __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, 366, __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, 366, __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, 366, __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__36)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 366, __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, 366, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_time, 366, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 366, __pyx_L1_error)
0367: """to_time.
0368:
0369: Returns obj converted to datetime.time.
0370: """
+0371: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0372: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0373: if isinstance(obj, datetime.time):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_ptype_7cpython_8datetime_time);
if (__pyx_t_1) {
/* … */
}
+0374: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0375: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 375, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0376: # its a function callable returning a value
+0377: 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); }
+0378: 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, 378, __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;
+0379: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L6_exception_handled;
}
0380: pass
0381: else:
+0382: 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); }
+0383: 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, 383, __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, 383, __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, 383, __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, 383, __pyx_L11_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5)) __PYX_ERR(0, 383, __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, 383, __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, 383, __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, 383, __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;
+0384: 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;
0385: pass
+0386: m = TIME_RE.match(obj)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_TIME_RE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 386, __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, 386, __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, 386, __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;
+0387: if not m:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_m); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 387, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_1); if (__pyx_t_10) { /* … */ }
+0388: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0389: 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:;
+0390: 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, 390, __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, 390, __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, 390, __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;
+0391: 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, 391, __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, 391, __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, 391, __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, 391, __pyx_L18_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0392: 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, 392, __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, 392, __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;
+0393: 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, 393, __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;
+0394: hour=int(hours),
__pyx_t_11 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 394, __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, 394, __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, 394, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0395: minute=int(minutes),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_minutes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 395, __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, 394, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0396: second=int(seconds),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_seconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 396, __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, 394, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0397: microsecond=int(microseconds),
__pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_microseconds); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 397, __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, 394, __pyx_L18_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0398: )
+0399: 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, 399, __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;
+0400: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 400, __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, 400, __pyx_L29_error) }
+0401: f"Invalid Time/Timestamp Object {obj}: {e}"
__pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 401, __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, 401, __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, 401, __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, 401, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0402: )
0403:
0404:
+0405: 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, 405, __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, 405, __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, 405, __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, 405, __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, 405, __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__37 = PyTuple_Pack(1, __pyx_n_s_val); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37); /* … */ __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__38)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_strtobool, __pyx_t_3) < 0) __PYX_ERR(0, 405, __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__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_strtobool, 405, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 405, __pyx_L1_error)
0406: """Convert a string representation of truth to true (1) or false (0).
0407:
0408: True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
0409: are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
0410: 'val' is anything else.
0411: """
+0412: val = val.lower()
__pyx_t_1 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_lower, __pyx_v_val); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __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, 412, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_val, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+0413: 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, 413, __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, 413, __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, 413, __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, 413, __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, 413, __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, 413, __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, 413, __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) { /* … */ }
+0414: return True
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
+0415: 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, 415, __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, 415, __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, 415, __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, 415, __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, 415, __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, 415, __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, 415, __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, 415, __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)) { /* … */ }
+0416: return False
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
0417: else:
+0418: raise ValueError(
/*else*/ { /* … */ __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __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, 418, __pyx_L1_error) }
+0419: f"Invalid truth value for **'{val}'**"
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __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, 419, __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, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0420: )
0421:
+0422: 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, 422, __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, 422, __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, 422, __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, 422, __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__39)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __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, 422, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_boolean, 422, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 422, __pyx_L1_error)
0423: """to_boolean.
0424:
0425: Convert and returns any object value to boolean version.
0426: """
+0427: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0428: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0429: 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, 429, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+0430: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0431: 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) {
/* … */
}
+0432: 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, 432, __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, 432, __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;
+0433: if isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0434: 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, 434, __pyx_L1_error) __pyx_t_2 = __pyx_f_9datamodel_10converters_strtobool(((PyObject*)__pyx_v_obj), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0435: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 435, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L8; }
0436: # its a function callable returning a value
+0437: 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); }
+0438: 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, 438, __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;
+0439: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L10_exception_handled;
}
0440: pass
0441: else:
+0442: 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, 442, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } __pyx_L8:;
0443:
+0444: 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, 444, __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, 444, __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, 444, __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, 444, __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__40)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 444, __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, 444, __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__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_object, 444, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 444, __pyx_L1_error)
+0445: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (__pyx_t_1) { /* … */ }
+0446: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+0447: 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) { /* … */ }
+0448: return obj
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
+0449: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 449, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
0450: # its a function callable returning a value
+0451: 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); }
+0452: 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, 452, __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;
+0453: except:
/*except:*/ {
__Pyx_ErrRestore(0,0,0);
goto __pyx_L9_exception_handled;
}
0454: pass
+0455: elif isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (likely(__pyx_t_1)) {
/* … */
}
+0456: 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; }
+0457: 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, 457, __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, 457, __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, 457, __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;
+0458: 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, 458, __pyx_L16_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7);
+0459: 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;
0460: else:
+0461: raise ValueError(
/*else*/ { /* … */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 461, __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, 461, __pyx_L1_error) } __pyx_L4:;
+0462: f"Can't convert invalid data {obj} to Object"
__pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 462, __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, 462, __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, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0463: )
0464:
+0465: 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, 465, __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, 465, __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, 465, __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, 465, __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__41)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 465, __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, 465, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_to_bytes, 465, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 465, __pyx_L1_error)
0466: """
0467: Convert the given object to bytes.
0468:
0469: - If the object is already bytes, return it directly.
0470: - If the object is a string, encode it (using UTF-8).
0471: - If the object is callable, call it and convert its result.
0472: - Otherwise, attempt to convert the object to bytes.
0473: If conversion fails, raise a ValueError.
0474: """
+0475: if obj is None:
__pyx_t_1 = (__pyx_v_obj == Py_None); if (unlikely(__pyx_t_1)) { /* … */ }
+0476: 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, 476, __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, 476, __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, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9);
0477:
0478: # 1. If already bytes, return as is.
+0479: if isinstance(obj, bytes):
__pyx_t_1 = PyBytes_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0480: 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, 480, __pyx_L1_error) __Pyx_INCREF(__pyx_v_obj); __pyx_r = ((PyObject*)__pyx_v_obj); goto __pyx_L0;
0481:
0482: # 2. If it's a string, encode it to bytes.
+0483: elif isinstance(obj, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_obj);
if (__pyx_t_1) {
/* … */
}
+0484: 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, 484, __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, 484, __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, 484, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0;
0485:
0486: # 3. If it's callable, attempt to call it and convert its result.
+0487: elif callable(obj):
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_obj); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 487, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0488: 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; }
+0489: 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, 489, __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;
0490: # Recursively convert the result.
+0491: 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, 491, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L9_try_return;
+0492: 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, 492, __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;
+0493: 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, 493, __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, 493, __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, 493, __pyx_L16_error) }
0494:
0495: # 4. Try converting the object into bytes using Python's built-in conversion.
+0496: 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; }
+0497: 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, 497, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L26_try_return;
+0498: 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, 498, __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;
+0499: 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, 499, __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, 499, __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, 499, __pyx_L33_error) }
0500:
+0501: 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; }
0502: """
0503: Check if `value` is callable by calling Python's callable(...)
0504: but reacquire the GIL inside.
0505: """
+0506: 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; } } }
+0507: return callable(value)
__pyx_t_1 = __Pyx_PyCallable_Check(__pyx_v_value); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 507, __pyx_L4_error) __pyx_r = __pyx_t_1; goto __pyx_L3_return; }
0508:
0509:
0510: # Encoder List:
0511: encoders = {
+0512: str: to_string,
__pyx_t_3 = __Pyx_PyDict_NewPresized(13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 512, __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, 512, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyUnicode_Type)), __pyx_t_2) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0513: UUID: to_uuid,
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_UUID); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 513, __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, 513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_4) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0514: pgproto.UUID: to_uuid,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pgproto); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __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, 514, __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, 514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_4) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0515: bool: to_boolean,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_boolean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject*)&PyBool_Type), __pyx_t_4) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0516: int: to_integer,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_integer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyInt_Type)), __pyx_t_4) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0517: float: to_float,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_float); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyFloat_Type)), __pyx_t_4) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0518: datetime.date: to_date,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_date); 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_date), __pyx_t_4) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0519: datetime.datetime: to_datetime,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 519, __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, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0520: datetime.timedelta: to_timedelta,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_timedelta); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 520, __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, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0521: datetime.time: to_time,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_to_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 521, __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, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0522: Decimal: to_decimal,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Decimal); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __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, 522, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_t_4, __pyx_t_2) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0523: bytes: to_bytes,
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_to_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, ((PyObject *)(&PyBytes_Type)), __pyx_t_2) < 0) __PYX_ERR(0, 512, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0524: 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, 524, __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, 524, __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, 524, __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, 524, __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, 524, __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, 524, __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, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_4) < 0) __PYX_ERR(0, 512, __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, 511, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0525: }
0526:
0527:
0528: # Maps a type to a conversion callable
+0529: cdef dict TYPE_PARSERS = {}
__pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 529, __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;
0530:
0531:
+0532: 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, 532, __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, 532, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("register_parser", 1, 2, 2, 1); __PYX_ERR(0, 532, __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, 532, __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, 532, __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, 532, __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__42 = PyTuple_Pack(2, __pyx_n_s_type, __pyx_n_s_parser_func); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 532, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42); /* … */ __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__43)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __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, 532, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_register_parser, 532, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 532, __pyx_L1_error)
0533: """register_parser.
0534:
0535: Register a new Parser function for a given type.
0536:
0537: Parameters:
0538: _type (type): The type for which the parser function is registered.
0539: parser_func (function): The parser function to convert the given type.
0540: """
+0541: 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, 541, __pyx_L1_error) } if (unlikely((PyDict_SetItem(__pyx_v_9datamodel_10converters_TYPE_PARSERS, __pyx_v__type, __pyx_v_parser_func) < 0))) __PYX_ERR(0, 541, __pyx_L1_error)
0542:
0543:
0544: ## Parsing Functions
+0545: 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_28); __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_inner_element_type); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_element); __Pyx_XDECREF(__pyx_v_converted); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_processed_item); __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; };
0546: object field,
0547: object T,
0548: object data,
0549: object encoder,
0550: object args,
+0551: 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;
int __pyx_v_is_typing_set;
PyObject *__pyx_v_d = NULL;
PyObject *__pyx_v_inner_element_type = NULL;
PyObject *__pyx_v_item = NULL;
PyObject *__pyx_v_element = NULL;
PyObject *__pyx_v_converted = NULL;
PyObject *__pyx_v_e = NULL;
PyObject *__pyx_v_processed_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);
0552: ):
0553: """
0554: Parse a set of items to a typing type.
0555: """
+0556: 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, 556, __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, 556, __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, 556, __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;
+0557: cdef set result = set()
__pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0558: 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, 558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __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, 558, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error); __pyx_t_1 = 0; __pyx_v_key = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+0559: 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, 559, __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, 559, __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, 559, __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, 559, __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, 559, __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;
+0560: 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, 560, __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, 560, __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;
+0561: cdef bint is_typing_set = hasattr(inner_type, '__origin__') and inner_type.__origin__ is set
__pyx_t_4 = __Pyx_HasAttr(__pyx_v_inner_type, __pyx_n_u_origin); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 561, __pyx_L1_error) 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_inner_type, __pyx_n_s_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = (__pyx_t_3 == ((PyObject *)(&PySet_Type))); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __pyx_L5_bool_binop_done:; __pyx_v_is_typing_set = __pyx_t_2;
0562:
+0563: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+0564: return set() # short-circuit
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
0565:
0566: # If data is not already a collection, put it in a list for processing
+0567: 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_L9_bool_binop_done; } __pyx_t_4 = PyTuple_Check(__pyx_v_data); if (!__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L9_bool_binop_done; } __pyx_t_4 = PySet_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_4; __pyx_L9_bool_binop_done:; __pyx_t_4 = (!__pyx_t_2); if (__pyx_t_4) { /* … */ }
+0568: data = [data]
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __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, 568, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
0569:
0570: # If it's a dataclass
+0571: 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, 571, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+0572: 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, 572, __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, 572, __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, 572, __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, 572, __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, 572, __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, 572, __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, 572, __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, 572, __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, 572, __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;
+0573: 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, 573, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L15; }
+0574: result.add(d)
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_d); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 574, __pyx_L1_error)
+0575: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 575, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L15; }
+0576: result.add(
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0577: 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, 577, __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, 577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; }
0578: )
+0579: elif isinstance(d, dict):
__pyx_t_4 = PyDict_Check(__pyx_v_d);
if (__pyx_t_4) {
/* … */
goto __pyx_L15;
}
+0580: 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, 580, __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, 580, __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, 580, __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, 580, __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, 580, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0581: 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_L16_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_d); __pyx_t_4 = __pyx_t_2; __pyx_L16_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L15; }
+0582: result.add(inner_type(*d))
__pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 582, __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, 582, __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, 582, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0583: else:
+0584: 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, 584, __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, 584, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L15:;
+0585: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+0586: elif is_typing_set:
if (__pyx_v_is_typing_set) { /* … */ goto __pyx_L12; }
0587: # If we're dealing with typing.Set[str] or similar
+0588: inner_element_type = get_args(inner_type)[0] if get_args(inner_type) else Any
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_get_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __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_inner_type}; __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, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_get_args); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __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_inner_type}; __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, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_9; __pyx_t_9 = 0; } else { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_Any); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_v_inner_element_type = __pyx_t_3; __pyx_t_3 = 0;
0589: # If the inner type is a set, we need to process it differently
+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_L24_try_end; __pyx_L19_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L21_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_L24_try_end:; }
+0591: 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, 591, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 591, __pyx_L19_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, 591, __pyx_L19_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, 591, __pyx_L19_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, 591, __pyx_L19_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, 591, __pyx_L19_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, 591, __pyx_L19_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, 591, __pyx_L19_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, 591, __pyx_L19_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;
+0592: if isinstance(item, str):
__pyx_t_4 = PyUnicode_Check(__pyx_v_item);
if (__pyx_t_4) {
/* … */
goto __pyx_L27;
}
0593: # String items are individual elements
+0594: result.add(item)
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 594, __pyx_L19_error)
+0595: elif isinstance(item, (list, tuple, set)):
__pyx_t_2 = PyList_Check(__pyx_v_item); if (!__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L28_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_item); if (!__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L28_bool_binop_done; } __pyx_t_2 = PySet_Check(__pyx_v_item); __pyx_t_4 = __pyx_t_2; __pyx_L28_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L27; }
0596: # Process each element in collections
+0597: for element in item:
if (likely(PyList_CheckExact(__pyx_v_item)) || PyTuple_CheckExact(__pyx_v_item)) { __pyx_t_9 = __pyx_v_item; __Pyx_INCREF(__pyx_t_9); __pyx_t_15 = 0; __pyx_t_16 = NULL; } else { __pyx_t_15 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_item); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 597, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 597, __pyx_L19_error) } for (;;) { if (likely(!__pyx_t_16)) { 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, 597, __pyx_L19_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_15); __Pyx_INCREF(__pyx_t_1); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 597, __pyx_L19_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_1); #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, 597, __pyx_L19_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_15); __Pyx_INCREF(__pyx_t_1); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 597, __pyx_L19_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_16(__pyx_t_9); 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, 597, __pyx_L19_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_1); __pyx_t_1 = 0; /* … */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
0598: # Convert the element to the inner type if needed
+0599: if inner_element_type in encoders and not isinstance(element, inner_element_type):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_encoders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 599, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_inner_element_type, __pyx_t_1, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 599, __pyx_L19_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { } else { __pyx_t_4 = __pyx_t_2; goto __pyx_L34_bool_binop_done; } __pyx_t_2 = PyObject_IsInstance(__pyx_v_element, __pyx_v_inner_element_type); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 599, __pyx_L19_error) __pyx_t_17 = (!__pyx_t_2); __pyx_t_4 = __pyx_t_17; __pyx_L34_bool_binop_done:; if (__pyx_t_4) { /* … */ goto __pyx_L33; }
+0600: converted = encoders[inner_element_type](element)
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_encoders); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 600, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_t_8, __pyx_v_inner_element_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 600, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_element}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_10, __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, 600, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_XDECREF_SET(__pyx_v_converted, __pyx_t_1); __pyx_t_1 = 0;
+0601: result.add(converted)
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_converted); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 601, __pyx_L19_error)
0602: else:
+0603: result.add(element)
/*else*/ { __pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_element); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 603, __pyx_L19_error) } __pyx_L33:;
0604: else:
0605: # Single non-string item
+0606: result.add(item)
/*else*/ { __pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 606, __pyx_L19_error) } __pyx_L27:;
+0607: except Exception as e:
__pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_18) { __Pyx_AddTraceback("datamodel.converters._parse_set_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_1) < 0) __PYX_ERR(0, 607, __pyx_L21_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __pyx_v_e = __pyx_t_9; /*try:*/ { /* … */ /*finally:*/ { __pyx_L43_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_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_18 = __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_18; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21; goto __pyx_L21_except_error; } } } goto __pyx_L21_except_error;
+0608: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 608, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+0609: f"Error parsing set item of {inner_type}: {e}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 609, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = 0; __pyx_t_19 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_set_item_of); __pyx_t_5 += 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_8 = __Pyx_PyObject_FormatSimple(__pyx_v_inner_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_19; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_5 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u__7); __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_19; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_5, __pyx_t_19); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0610: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 608, __pyx_L43_error) }
+0611: elif converter:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 611, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L12; }
+0612: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __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, 612, __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, 612, __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_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 612, __pyx_L1_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #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, 612, __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_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 612, __pyx_L1_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } } else { __pyx_t_9 = __pyx_t_6(__pyx_t_1); 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, 612, __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_1); __pyx_t_1 = 0;
+0613: result.add(
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0614: converter(field.name, item, inner_type, _parent)
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_converter); __pyx_t_10 = __pyx_v_converter; __pyx_t_8 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_8, __pyx_t_3, __pyx_v_item, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_11, 4+__pyx_t_11); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; }
0615: )
+0616: elif is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __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[2] = {__pyx_t_10, __pyx_v_inner_type}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 616, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* … */ goto __pyx_L12; }
0617: # Process each item with appropriate converters
+0618: 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_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 618, __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, 618, __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, 618, __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_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 618, __pyx_L1_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #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, 618, __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_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 618, __pyx_L1_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif } } else { __pyx_t_9 = __pyx_t_6(__pyx_t_1); 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, 618, __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_1); __pyx_t_1 = 0;
+0619: 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_L61_try_end; __pyx_L54_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L56_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_L61_try_end:; }
0620: # If a specific encoder exists for this type, use it
+0621: if encoder:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 621, __pyx_L54_error) if (__pyx_t_4) { /* … */ goto __pyx_L62; }
+0622: processed_item = encoder(item)
__Pyx_INCREF(__pyx_v_encoder); __pyx_t_10 = __pyx_v_encoder; __pyx_t_3 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_item}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 622, __pyx_L54_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_XDECREF_SET(__pyx_v_processed_item, __pyx_t_9); __pyx_t_9 = 0;
0623: else:
0624: # Otherwise try to use builtin converters
+0625: processed_item = _parse_builtin_type(field, inner_type, item, None)
/*else*/ { __pyx_t_9 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L54_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_processed_item, __pyx_t_9); __pyx_t_9 = 0; } __pyx_L62:;
+0626: 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, 626, __pyx_L54_error)
+0627: except Exception as e:
__pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_20) { __Pyx_AddTraceback("datamodel.converters._parse_set_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_3) < 0) __PYX_ERR(0, 627, __pyx_L56_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __pyx_v_e = __pyx_t_10; /*try:*/ { /* … */ /*finally:*/ { __pyx_L68_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_28); __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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_18 = __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_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_18; __pyx_filename = __pyx_t_29; goto __pyx_L56_except_error; } } } goto __pyx_L56_except_error;
+0628: raise ValueError(
__pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_28); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 628, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
+0629: f"Error parsing set item of {inner_type}: {e}"
__pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 629, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_15 = 0; __pyx_t_19 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_set_item_of); __pyx_t_15 += 26; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_set_item_of); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_Error_parsing_set_item_of); __pyx_t_28 = __Pyx_PyObject_FormatSimple(__pyx_v_inner_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 629, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_28); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_28); __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_28); __pyx_t_28 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_15 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_8, 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, 629, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_28); __pyx_t_19 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) > __pyx_t_19) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28) : __pyx_t_19; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_28); __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_28); __pyx_t_28 = 0; __pyx_t_28 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, __pyx_t_15, __pyx_t_19); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 629, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_28); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+0630: ) from e
__Pyx_Raise(__pyx_t_8, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 628, __pyx_L68_error) }
0631: else:
+0632: for item in data:
/*else*/ { if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __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, 632, __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, 632, __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, 632, __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, 632, __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, 632, __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, 632, __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, 632, __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, 632, __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_1); __pyx_t_1 = 0; } __pyx_L12:;
+0633: result.add(
__pyx_t_7 = PySet_Add(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0634: _parse_typing(field, T=inner_type, data=item, encoder=encoder, as_objects=False)
__pyx_t_30.__pyx_n = 2; __pyx_t_30.encoder = __pyx_v_encoder; __pyx_t_30.as_objects = Py_False; __pyx_t_3 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, &__pyx_t_30); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3);
0635: )
+0636: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0637:
+0638: 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; }
0639: object field,
0640: object T,
0641: object data,
0642: object encoder,
0643: object args
0644: ):
+0645: 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, 645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_key_type = __pyx_t_1; __pyx_t_1 = 0;
+0646: 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, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_val_type = __pyx_t_1; __pyx_t_1 = 0;
+0647: cdef dict new_dict = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_new_dict = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
0648: cdef object val_origin, val_args
0649:
0650: # Check if we have type args (Dict[K, V])
+0651: 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, 651, __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, 651, __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) { /* … */ }
+0652: 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;
0653:
0654: # Get origin and args of value type to check if it's a nested Dict
+0655: val_origin = get_origin(val_type)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 655, __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, 655, __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;
+0656: val_args = get_args(val_type)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_get_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 656, __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, 656, __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;
0657:
0658: # Process each key-value pair
+0659: 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, 659, __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, 659, __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, 659, __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;
0660: # Convert the key if needed
+0661: 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, 661, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 661, __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; }
+0662: k = str(k)
__pyx_t_7 = __Pyx_PyObject_Unicode(__pyx_v_k); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_7); __pyx_t_7 = 0;
+0663: 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, 663, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 663, __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:;
+0664: 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:; }
+0665: k = int(k)
__pyx_t_7 = __Pyx_PyNumber_Int(__pyx_v_k); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 665, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_7); __pyx_t_7 = 0;
+0666: 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;
0667: pass
0668:
0669: # If value type is a nested Dict
+0670: 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, 670, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L22_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L21; }
+0671: if isinstance(v, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_v);
if (__pyx_t_2) {
/* … */
goto __pyx_L24;
}
0672: # Recursively process nested dict
+0673: 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, 673, __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, 673, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0674: else:
0675: # Not a dict but should be - create empty dict
+0676: new_dict[k] = {}
/*else*/ { __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 676, __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, 676, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_L24:;
0677: # If value type is a primitive type
+0678: elif is_primitive(val_type):
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 678, __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, 678, __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, 678, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L21; }
+0679: 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, 679, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 679, __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; }
+0680: 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:; }
+0681: new_dict[k] = int(v)
__pyx_t_7 = __Pyx_PyNumber_Int(__pyx_v_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 681, __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, 681, __pyx_L28_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0682: 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, 682, __pyx_L30_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_15);
+0683: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 683, __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;
+0684: 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, 684, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 684, __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; }
+0685: 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:; }
+0686: new_dict[k] = float(v)
__pyx_t_15 = __Pyx_PyNumber_Float(__pyx_v_v); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 686, __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, 686, __pyx_L40_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+0687: 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, 687, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+0688: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 688, __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;
+0689: 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, 689, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 689, __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; }
+0690: 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:; }
+0691: 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, 691, __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, 691, __pyx_L52_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0692: 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, 692, __pyx_L54_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_15);
+0693: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 693, __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;
+0694: elif val_type in encoders:
__Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_encoders); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 694, __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, 694, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L25; }
+0695: 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:; }
+0696: new_dict[k] = encoders[val_type](v)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_encoders); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 696, __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, 696, __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, 696, __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, 696, __pyx_L62_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+0697: 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, 697, __pyx_L64_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6);
+0698: new_dict[k] = v
if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 698, __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;
0699: else:
+0700: new_dict[k] = v
/*else*/ { if (unlikely((PyDict_SetItem(__pyx_v_new_dict, __pyx_v_k, __pyx_v_v) < 0))) __PYX_ERR(0, 700, __pyx_L1_error) } __pyx_L25:;
0701: # Other non-primitive types
0702: else:
+0703: 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, 703, __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, 703, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L21:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0704:
+0705: return new_dict
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_dict); __pyx_r = __pyx_v_new_dict; goto __pyx_L0;
0706:
+0707: cdef object _parse_list_type(
static PyObject *__pyx_f_9datamodel_10converters__parse_list_type(PyObject *__pyx_v_field, 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_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_30); __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_origin); __Pyx_XDECREF(__pyx_v_type_args); __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; };
0708: object field,
0709: object T,
0710: object data,
0711: object encoder,
0712: object args,
+0713: 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_origin = 0;
PyObject *__pyx_v_type_args = 0;
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);
0714: ):
0715: """
0716: Parse a list of items to a typing type.
0717: """
+0718: 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, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+0719: cdef list result = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0720: 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, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __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, 720, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error); __pyx_t_1 = 0; __pyx_v_key = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
0721: cdef object converter
+0722: 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, 722, __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, 722, __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; } __Pyx_INCREF(__pyx_v_arg_type); __pyx_t_2 = __pyx_v_arg_type; __pyx_L3_bool_binop_done:; __pyx_v_inner_type = __pyx_t_2; __pyx_t_2 = 0;
+0723: cdef bint is_optional = False
__pyx_v_is_optional = 0;
+0724: cdef object origin = field._inner_origin or get_origin(T)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 724, __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, 724, __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_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 724, __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_T}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_L5_bool_binop_done:; __pyx_v_origin = __pyx_t_2; __pyx_t_2 = 0;
+0725: cdef tuple type_args = field._typing_args or get_args(T)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_typing_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 725, __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, 725, __pyx_L1_error) if (!__pyx_t_3) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L7_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_get_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 725, __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_T}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_L7_bool_binop_done:; __pyx_v_type_args = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
0726:
0727: # Debug information if needed
0728: # print(f"_parse_list_type: field={field.name}, T={T}, data={data}, args={args}")
0729:
+0730: if data is None:
__pyx_t_3 = (__pyx_v_data == Py_None); if (__pyx_t_3) { /* … */ }
+0731: return [] # short-circuit
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0732:
0733: # Compute the Inner Type:
+0734: if hasattr(field, '_inner_type') and field._inner_type is not None:
__pyx_t_7 = __Pyx_HasAttr(__pyx_v_field, __pyx_n_u_inner_type); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 734, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = (__pyx_t_2 != Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_7; __pyx_L11_bool_binop_done:; if (__pyx_t_3) { /* … */ goto __pyx_L10; }
+0735: inner_type = field._inner_type
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_2); __pyx_t_2 = 0;
0736: # Then try to get it from the type's args
+0737: elif type_args and len(type_args) > 0:
__pyx_t_7 = (__pyx_v_type_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_type_args) != 0); if (__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L13_bool_binop_done; } if (unlikely(__pyx_v_type_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 737, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyTuple_GET_SIZE(__pyx_v_type_args); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 737, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 > 0); __pyx_t_3 = __pyx_t_7; __pyx_L13_bool_binop_done:; if (__pyx_t_3) { /* … */ goto __pyx_L10; }
+0738: inner_type = type_args[0]
if (unlikely(__pyx_v_type_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 738, __pyx_L1_error) } __pyx_t_2 = __Pyx_GetItemInt_Tuple(__pyx_v_type_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_2); __pyx_t_2 = 0;
0739: # Finally try to get it from args parameter
+0740: elif args and isinstance(args, (list, tuple)) and len(args) > 0:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 740, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L15_bool_binop_done; } __pyx_t_9 = PyList_Check(__pyx_v_args); if (!__pyx_t_9) { } else { __pyx_t_7 = __pyx_t_9; goto __pyx_L18_bool_binop_done; } __pyx_t_9 = PyTuple_Check(__pyx_v_args); __pyx_t_7 = __pyx_t_9; __pyx_L18_bool_binop_done:; if (__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L15_bool_binop_done; } __pyx_t_8 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 740, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 > 0); __pyx_t_3 = __pyx_t_7; __pyx_L15_bool_binop_done:; if (__pyx_t_3) { /* … */ goto __pyx_L10; }
+0741: if hasattr(args[0], '__origin__') and args[0].__origin__ is list and hasattr(args[0], '__args__'):
__pyx_t_2 = __Pyx_GetItemInt(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_HasAttr(__pyx_t_2, __pyx_n_u_origin); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L21_bool_binop_done; } __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_args, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_origin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (__pyx_t_1 == ((PyObject *)(&PyList_Type))); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L21_bool_binop_done; } __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, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_u_args); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_7; __pyx_L21_bool_binop_done:; if (__pyx_t_3) { /* … */ goto __pyx_L20; }
0742: # This is typing.List[T]
+0743: 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, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_arg_type, __pyx_t_1); __pyx_t_1 = 0;
+0744: inner_type = arg_type.__args__[0] if arg_type.__args__ else Any
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __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, 744, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Any); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0;
0745: else:
+0746: inner_type = args[0]
/*else*/ { __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, 746, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L20:;
0747: else:
+0748: inner_type = Any
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Any); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L10:;
0749:
+0750: if not isinstance(data, (list, tuple)):
__pyx_t_7 = PyList_Check(__pyx_v_data); if (!__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L25_bool_binop_done; } __pyx_t_7 = PyTuple_Check(__pyx_v_data); __pyx_t_3 = __pyx_t_7; __pyx_L25_bool_binop_done:; __pyx_t_7 = (!__pyx_t_3); if (__pyx_t_7) { /* … */ }
+0751: data = [data]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __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, 751, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
0752:
0753: # Get the converter if available
+0754: key = (inner_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, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_inner_type); __Pyx_GIVEREF(__pyx_v_inner_type); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_inner_type)) __PYX_ERR(0, 754, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_key, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+0755: 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, 755, __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, 755, __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, 755, __pyx_L1_error) if (!__pyx_t_7) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L27_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, 755, __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, 755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_L27_bool_binop_done:; __pyx_v_converter = __pyx_t_4; __pyx_t_4 = 0;
0756:
0757: # If it's a dataclass
+0758: if is_dc(inner_type):
__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, 758, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+0759: for d in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_4 = __pyx_v_data; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_10 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 759, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 759, __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_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 759, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 759, __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_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 759, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_10(__pyx_t_4); 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, 759, __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_4); __pyx_t_4 = 0;
+0760: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L39_try_end; __pyx_L32_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L34_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_L39_try_end:; }
+0761: if is_dc(d):
__pyx_t_7 = __pyx_f_9datamodel_10converters_is_dc(__pyx_v_d); if (unlikely(__pyx_t_7 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 761, __pyx_L32_error) if (__pyx_t_7) { /* … */ goto __pyx_L40; }
+0762: result.append(d)
__pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_d); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 762, __pyx_L32_error)
+0763: elif converter:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 763, __pyx_L32_error) if (__pyx_t_7) { /* … */ goto __pyx_L40; }
+0764: result.append(
__pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 764, __pyx_L32_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0765: converter(field.name, d, inner_type, _parent)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_converter); __pyx_t_5 = __pyx_v_converter; __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(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[5] = {__pyx_t_15, __pyx_t_2, __pyx_v_d, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 4+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
0766: )
+0767: elif isinstance(d, dict):
__pyx_t_7 = PyDict_Check(__pyx_v_d);
if (__pyx_t_7) {
/* … */
goto __pyx_L40;
}
+0768: 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, 768, __pyx_L32_error) } if (likely(PyDict_CheckExact(__pyx_v_d))) { __pyx_t_1 = PyDict_Copy(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L32_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, 768, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_inner_type, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 768, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_5); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 768, __pyx_L32_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0769: elif isinstance(d, (list, tuple)):
__pyx_t_3 = PyList_Check(__pyx_v_d); if (!__pyx_t_3) { } else { __pyx_t_7 = __pyx_t_3; goto __pyx_L41_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_d); __pyx_t_7 = __pyx_t_3; __pyx_L41_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L40; }
+0770: result.append(inner_type(*d))
__pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 770, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_inner_type, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 770, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 770, __pyx_L32_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0771: else:
+0772: result.append(inner_type(d))
/*else*/ { __Pyx_INCREF(__pyx_v_inner_type); __pyx_t_5 = __pyx_v_inner_type; __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, __pyx_v_d}; __pyx_t_1 = __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_1)) __PYX_ERR(0, 772, __pyx_L32_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 772, __pyx_L32_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L40:;
+0773: except Exception as e:
__pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_16) { __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L34_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_v_e = __pyx_t_5; /*try:*/ { /* … */ /*finally:*/ { __pyx_L48_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); __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_XGOTREF(__pyx_t_28); __pyx_t_16 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_22 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28); } __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25); __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_22; goto __pyx_L34_except_error; } } } goto __pyx_L34_except_error;
0774: # Propagate the error with more context
+0775: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_20); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 775, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+0776: f"Error creating {inner_type.__name__} from {d}: {e}"
__pyx_t_15 = PyTuple_New(6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 776, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_17 = 0; __pyx_t_18 = 127; __Pyx_INCREF(__pyx_kp_u_Error_creating); __pyx_t_17 += 15; __Pyx_GIVEREF(__pyx_kp_u_Error_creating); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_kp_u_Error_creating); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_inner_type, __pyx_n_s_name); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 776, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_20 = __Pyx_PyObject_FormatSimple(__pyx_t_19, __pyx_empty_unicode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 776, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) : __pyx_t_18; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_20); __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_20); __pyx_t_20 = 0; __Pyx_INCREF(__pyx_kp_u_from); __pyx_t_17 += 6; __Pyx_GIVEREF(__pyx_kp_u_from); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u_from); __pyx_t_20 = __Pyx_PyObject_FormatSimple(__pyx_v_d, __pyx_empty_unicode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 776, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) : __pyx_t_18; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_20); __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_20); __pyx_t_20 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_17 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_kp_u__7); __pyx_t_20 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 776, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) : __pyx_t_18; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_20); __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_15, 5, __pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = __Pyx_PyUnicode_Join(__pyx_t_15, 6, __pyx_t_17, __pyx_t_18); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 776, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+0777: ) from e
__Pyx_Raise(__pyx_t_15, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __PYX_ERR(0, 775, __pyx_L48_error) }
+0778: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+0779: elif is_typing(inner_type):
__pyx_t_7 = __pyx_f_9datamodel_10converters_is_typing(__pyx_v_inner_type); if (unlikely(__pyx_t_7 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 779, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L29; }
+0780: if isinstance(data, list):
__pyx_t_7 = PyList_Check(__pyx_v_data);
if (__pyx_t_7) {
/* … */
}
+0781: result = _parse_list_typing(
__pyx_t_29.__pyx_n = 1; __pyx_t_29.as_objects = Py_None; __pyx_t_4 = __pyx_f_9datamodel_10converters__parse_list_typing(__pyx_v_field, __pyx_v_type_args, __pyx_v_data, __pyx_v_encoder, __pyx_v_origin, __pyx_v_args, &__pyx_t_29); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_4))) __PYX_ERR(0, 781, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
0782: field,
0783: type_args,
0784: data,
0785: encoder,
0786: origin,
0787: args,
0788: None
0789: )
+0790: elif converter:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 790, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L29; }
+0791: for item in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_4 = __pyx_v_data; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_10 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 791, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 791, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 791, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0; /* … */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0792: result.append(
__pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 792, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0793: converter(field.name, item, inner_type, _parent)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 793, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_converter); __pyx_t_1 = __pyx_v_converter; __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(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[5] = {__pyx_t_15, __pyx_t_5, __pyx_v_item, __pyx_v_inner_type, __pyx_v__parent}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 4+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 793, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
0794: )
+0795: elif is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_inner_type}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 795, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 795, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_7) { /* … */ goto __pyx_L29; }
+0796: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L64_try_end; __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_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_L60_exception_handled:; __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); __pyx_L64_try_end:; }
+0797: for item in data:
if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_4 = __pyx_v_data; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_10 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 797, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 797, __pyx_L59_error) } for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 797, __pyx_L59_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 797, __pyx_L59_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 797, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 797, __pyx_L59_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 797, __pyx_L59_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 797, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 797, __pyx_L59_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0; /* … */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0798: if encoder:
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 798, __pyx_L59_error) if (__pyx_t_7) { /* … */ }
+0799: result.append(encoder(item))
__Pyx_INCREF(__pyx_v_encoder); __pyx_t_1 = __pyx_v_encoder; __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_v_item}; __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; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 799, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 799, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0800: if inner_type == int and isinstance(item, str):
__pyx_t_2 = PyObject_RichCompare(__pyx_v_inner_type, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 800, __pyx_L59_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 800, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { } else { __pyx_t_7 = __pyx_t_3; goto __pyx_L69_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_item); __pyx_t_7 = __pyx_t_3; __pyx_L69_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L68; }
+0801: result.append(int(item))
__pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 801, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0802: elif inner_type == float and isinstance(item, str):
__pyx_t_2 = PyObject_RichCompare(__pyx_v_inner_type, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L59_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 802, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { } else { __pyx_t_7 = __pyx_t_3; goto __pyx_L71_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_item); __pyx_t_7 = __pyx_t_3; __pyx_L71_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L68; }
+0803: result.append(float(item))
__pyx_t_2 = __Pyx_PyNumber_Float(__pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 803, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0804: else:
+0805: if inner_type in encoders:
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_encoders); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_inner_type, __pyx_t_2, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 805, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_7) { /* … */ goto __pyx_L73; }
+0806: result.append(encoders[inner_type](item))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_encoders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_inner_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_item}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 806, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 806, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0807: else:
+0808: result.append(
/*else*/ { /* … */ __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 808, __pyx_L59_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L73:; } __pyx_L68:;
+0809: _parse_builtin_type(field, inner_type, item, None)
__pyx_t_2 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 809, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_2);
0810: )
+0811: except Exception as e:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_21) { __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(0, 811, __pyx_L61_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_v_e = __pyx_t_2; /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L81; } __pyx_L80_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_32 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_34, &__pyx_t_33, &__pyx_t_32); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28) < 0)) __Pyx_ErrFetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); __Pyx_XGOTREF(__pyx_t_26); __Pyx_XGOTREF(__pyx_t_27); __Pyx_XGOTREF(__pyx_t_28); __Pyx_XGOTREF(__pyx_t_34); __Pyx_XGOTREF(__pyx_t_33); __Pyx_XGOTREF(__pyx_t_32); __pyx_t_16 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_35 = __pyx_filename; { __Pyx_XDECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_34); __Pyx_XGIVEREF(__pyx_t_33); __Pyx_XGIVEREF(__pyx_t_32); __Pyx_ExceptionReset(__pyx_t_34, __pyx_t_33, __pyx_t_32); } __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_ErrRestore(__pyx_t_26, __pyx_t_27, __pyx_t_28); __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_32 = 0; __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_35; goto __pyx_L61_except_error; } __pyx_L81:; } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L60_exception_handled; } goto __pyx_L61_except_error;
+0812: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0; __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0; goto __pyx_L89_try_end; __pyx_L82_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; /* … */ __pyx_L84_except_error:; __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_ExceptionReset(__pyx_t_28, __pyx_t_27, __pyx_t_26); goto __pyx_L80_error; __pyx_L89_try_end:; } }
+0813: result = rc.to_list(inner_type, data)
__Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_rc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 813, __pyx_L82_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_to_list); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 813, __pyx_L82_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_20))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_v_inner_type, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_20, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L82_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_1))) __PYX_ERR(0, 813, __pyx_L82_error) __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
0814: # return data
+0815: except Exception as e:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_21) { __Pyx_AddTraceback("datamodel.converters._parse_list_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_20, &__pyx_t_15) < 0) __PYX_ERR(0, 815, __pyx_L84_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_t_20); __Pyx_DECREF_SET(__pyx_v_e, __pyx_t_20); /*try:*/ { /* … */ /*finally:*/ { __pyx_L95_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 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_25, &__pyx_t_24, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_32); __Pyx_XGOTREF(__pyx_t_33); __Pyx_XGOTREF(__pyx_t_34); __pyx_t_21 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_31 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 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_25); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ErrRestore(__pyx_t_25, __pyx_t_24, __pyx_t_23); __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_31; goto __pyx_L84_except_error; } } } goto __pyx_L84_except_error;
+0816: raise ValueError(
__pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_30); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 816, __pyx_L95_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
+0817: f"Error parsing list of {inner_type}: {e}"
__pyx_t_19 = PyTuple_New(4); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 817, __pyx_L95_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_8 = 0; __pyx_t_18 = 127; __Pyx_INCREF(__pyx_kp_u_Error_parsing_list_of); __pyx_t_8 += 22; __Pyx_GIVEREF(__pyx_kp_u_Error_parsing_list_of); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_kp_u_Error_parsing_list_of); __pyx_t_30 = __Pyx_PyObject_FormatSimple(__pyx_v_inner_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 817, __pyx_L95_error) __Pyx_GOTREF(__pyx_t_30); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_30) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_30) : __pyx_t_18; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_30); __Pyx_GIVEREF(__pyx_t_30); PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_30); __pyx_t_30 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_8 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_kp_u__7); __pyx_t_30 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 817, __pyx_L95_error) __Pyx_GOTREF(__pyx_t_30); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_30) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_30) : __pyx_t_18; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_30); __Pyx_GIVEREF(__pyx_t_30); PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_30); __pyx_t_30 = 0; __pyx_t_30 = __Pyx_PyUnicode_Join(__pyx_t_19, 4, __pyx_t_8, __pyx_t_18); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 817, __pyx_L95_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+0818: ) from e
__Pyx_Raise(__pyx_t_19, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __PYX_ERR(0, 816, __pyx_L95_error) }
+0819: elif inner_type is Any:
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_Any); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = (__pyx_v_inner_type == __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_7) { /* … */ }
0820: # If no type is specified, return the list as-is
+0821: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0822: else:
0823: # Default: process each item with _parse_typing
+0824: for item in data:
/*else*/ { if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_5 = __pyx_v_data; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0; __pyx_t_10 = NULL; } else { __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 824, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_10)) { 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, 824, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 824, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #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, 824, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 824, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 824, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0; /* … */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_L29:;
+0825: result.append(
__pyx_t_14 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_2); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 825, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0826: _parse_typing(field, T=inner_type, data=item, encoder=encoder, as_objects=False)
__pyx_t_36.__pyx_n = 2; __pyx_t_36.encoder = __pyx_v_encoder; __pyx_t_36.as_objects = Py_False; __pyx_t_2 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_inner_type, __pyx_v_item, &__pyx_t_36); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
0827: )
+0828: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0829:
+0830: 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, 830, __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; };
0831: object field,
0832: object T,
0833: object data,
0834: object encoder,
0835: object args
0836: ):
0837: """
0838: Parse a tuple of items to their respective types.
0839: Handles both heterogeneous tuples (Tuple[T1, T2, ...]) and
0840: homogeneous tuples (Tuple[T, ...])
0841: """
+0842: cdef tuple result = ()
__Pyx_INCREF(__pyx_empty_tuple);
__pyx_v_result = __pyx_empty_tuple;
0843:
0844: # Handle empty data
+0845: if data is None:
__pyx_t_1 = (__pyx_v_data == Py_None); if (__pyx_t_1) { /* … */ }
+0846: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
0847:
0848: # Ensure data is in tuple form
+0849: 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) { /* … */ }
+0850: data = (data,)
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 850, __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, 850, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
0851:
0852: # Check for homogeneous tuple with ellipsis: Tuple[T, ...]
+0853: 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, 853, __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, 853, __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; }
0854: # All elements should be of type args[0]
+0855: 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, 855, __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;
+0856: result = tuple(
__pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 856, __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;
+0857: _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, 857, __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, 857, __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, 857, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 857, __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, 857, __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, 857, __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, 857, __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, 857, __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 *); };
+0858: if is_primitive(element_type) else
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 858, __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, 858, __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, 858, __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, 858, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) {
+0859: _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, 859, __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, 859, __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, 859, __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, 859, __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, 857, __pyx_L1_error)
+0860: for item in data
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 860, __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, 860, __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, 860, __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, 860, __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, 860, __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, 860, __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, 860, __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, 860, __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, 860, __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, 860, __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);
0861: )
0862: # Handle heterogeneous tuple: Tuple[T1, T2, ...]
+0863: elif len(args) > 0:
__pyx_t_4 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 863, __pyx_L1_error) __pyx_t_2 = (__pyx_t_4 > 0); if (__pyx_t_2) { /* … */ goto __pyx_L7; }
0864: # Validate tuple length
+0865: 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, 865, __pyx_L1_error) __pyx_t_6 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 865, __pyx_L1_error) __pyx_t_2 = (__pyx_t_4 != __pyx_t_6); if (unlikely(__pyx_t_2)) { /* … */ }
+0866: raise ValueError(
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 866, __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, 866, __pyx_L1_error)
+0867: 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, 867, __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, 867, __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, 867, __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, 867, __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, 867, __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, 867, __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, 867, __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, 867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
0868: )
0869:
0870: # Convert each element according to its type
+0871: converted_elements = []
__pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 871, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_converted_elements = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0872: 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, 872, __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, 872, __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, 872, __pyx_L1_error); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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, 872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 872, __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, 872, __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, 872, __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, 872, __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, 872, __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;
+0873: 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:; }
+0874: if is_primitive(item_type):
__Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 874, __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, 874, __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, 874, __pyx_L15_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L23; }
+0875: 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, 875, __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, 875, __pyx_L15_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
0876: else:
+0877: 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, 877, __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, 877, __pyx_L15_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L23:;
+0878: 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, 878, __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;
+0879: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_22); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 879, __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, 879, __pyx_L29_error) }
+0880: f"Error parsing tuple element {i} of {field.name}: {e}"
__pyx_t_12 = PyTuple_New(6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 880, __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, 880, __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, 880, __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, 880, __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, 880, __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, 880, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
0881: )
0882:
+0883: result = tuple(converted_elements)
__pyx_t_5 = PyList_AsTuple(__pyx_v_converted_elements); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
0884: else:
0885: # No type args, just return the tuple
+0886: result = tuple(data)
/*else*/ { __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 886, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0; } __pyx_L7:;
0887:
+0888: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
0889:
+0890: 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; }
+0891: if isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0892: 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, 892, __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, 892, __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, 892, __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, 892, __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;
+0893: 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) { /* … */ }
+0894: return T(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 894, __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, 894, __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;
0895: else:
+0896: 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, 896, __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; }
0897:
+0898: 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; }
+0899: if encoder is not None:
__pyx_t_1 = (__pyx_v_encoder != Py_None); if (__pyx_t_1) { /* … */ }
+0900: 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; }
+0901: 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, 901, __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;
+0902: 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, 902, __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;
+0903: raise ValueError(f"Error parsing type {T}, {e}")
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 903, __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, 903, __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, 903, __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, 903, __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, 903, __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, 903, __pyx_L15_error) }
+0904: 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, 904, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 904, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0905: 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, 905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0906: 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, 906, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 906, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0907: 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, 907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0908: 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, 908, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 908, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0909: 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, 909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0910: 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, 910, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 910, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0911: 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, 911, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0912: 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, 912, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 912, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0913: 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, 913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;
+0914: if T == UUID:
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_UUID); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 914, __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, 914, __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, 914, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { /* … */ }
+0915: 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, 915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0916: 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, 916, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0917: 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, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+0918: elif T == Path:
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 918, __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, 918, __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, 918, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0919: if isinstance(data, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0920: return Path(data)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 920, __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, 920, __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;
+0921: elif isinstance(data, Path):
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 921, __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, 921, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+0922: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0923: else:
+0924: 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; } }
+0925: 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, 925, __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, 925, __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, 925, __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;
+0926: 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, 926, __pyx_L30_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+0927: raise ValueError(f"Cannot convert {data} to Path")
__pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 927, __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, 927, __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, 927, __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, 927, __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, 927, __pyx_L30_except_error) }
+0928: 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, 928, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 928, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_1) { /* … */ }
+0929: if not isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
__pyx_t_22 = (!__pyx_t_1);
if (unlikely(__pyx_t_22)) {
/* … */
}
+0930: raise ValueError(
__pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 930, __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, 930, __pyx_L1_error)
+0931: 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, 931, __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, 931, __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, 931, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0932: )
+0933: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0934: 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, 934, __pyx_L1_error) __pyx_t_22 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_22 < 0))) __PYX_ERR(0, 934, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_22) { /* … */ }
+0935: 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) { /* … */ }
+0936: data = [data]
__pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 936, __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, 936, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_6); __pyx_t_6 = 0;
+0937: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0938: else:
0939: # Try encoders dict:
+0940: 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; } }
+0941: 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, 941, __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) { /* … */ }
+0942: field._encoder_fn = encoders[T]
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_encoders); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 942, __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, 942, __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, 942, __pyx_L40_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0943: 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, 943, __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, 943, __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;
+0944: 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, 944, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
0945: # attempt direct construction:
+0946: if isinstance(T, type):
__pyx_t_1 = PyType_Check(__pyx_v_T);
if (__pyx_t_1) {
/* … */
}
+0947: 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:; }
+0948: if isinstance(data, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0949: 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, 949, __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, 949, __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, 949, __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, 949, __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;
+0950: 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) { /* … */ }
+0951: return T(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 951, __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, 951, __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;
+0952: elif isinstance(data, str):
__pyx_t_1 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_1) {
/* … */
}
+0953: 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, 953, __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;
+0954: 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;
0955: pass
+0956: 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; }
+0957: 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, 957, __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; } } }
+0958: raise TypeError(f"Error type {T}: {e}") from e
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 958, __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, 958, __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, 958, __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, 958, __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, 958, __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, 958, __pyx_L66_error) }
+0959: 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, 959, __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;
+0960: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 960, __pyx_L77_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+0961: f"Error parsing type {T}: {e}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 961, __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, 961, __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, 961, __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, 961, __pyx_L77_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0962: ) from e
__Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 960, __pyx_L77_error) }
0963:
+0964: 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, 964, __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, 964, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_basic", 0, 2, 3, 1); __PYX_ERR(0, 964, __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, 964, __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, 964, __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, 964, __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, 964, __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__44 = PyTuple_Pack(3, __pyx_n_s_T, __pyx_n_s_data, __pyx_n_s_encoder); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 964, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44); __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_parse_basic, 964, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 964, __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__45)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_tuple__46); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_basic, __pyx_t_3) < 0) __PYX_ERR(0, 964, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_tuple__46 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 964, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46); /* … */ struct __pyx_opt_args_9datamodel_10converters_parse_basic { int __pyx_n; PyObject *encoder; };
0965: """parse_basic.
0966:
0967: Parse a value to primitive types as str or int.
0968: --- (int, float, str, bool, bytes)
0969: """
+0970: 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, 970, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 970, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0971: if isinstance(data, str):
__pyx_t_2 = PyUnicode_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0972: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0973: elif data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0974: return str(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_Unicode(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0975: 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, 975, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 975, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0976: if isinstance(data, int):
__pyx_t_2 = PyInt_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+0977: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+0978: elif data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0979: return int(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0980: 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, 980, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 980, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0981: if data is not None:
__pyx_t_2 = (__pyx_v_data != Py_None); if (__pyx_t_2) { /* … */ }
+0982: 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, 982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0983: if T == UUID or T == pgproto.UUID:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_UUID); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __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, 983, __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, 983, __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, 983, __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, 983, __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, 983, __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, 983, __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) { /* … */ }
+0984: 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, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+0985: 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, 985, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0986: 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, 986, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0987: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0988: # function encoder:
+0989: if encoder:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encoder); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 989, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+0990: 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, 990, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
0991: # using a function encoder:
+0992: 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; }
+0993: 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, 993, __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;
+0994: 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, 994, __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; } } }
+0995: raise TypeError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 995, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0996: 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, 996, __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, 996, __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, 996, __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, 996, __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, 996, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+0997: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 995, __pyx_L27_error) }
+0998: 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, 998, __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; } } }
+0999: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 999, __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, 999, __pyx_L38_error) }
+1000: f"Error parsing type {T}, {e}"
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1000, __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, 1000, __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, 1000, __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, 1000, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1001: )
+1002: 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, 1002, __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;
+1003: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+1004: 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;
+1005: raise AttributeError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1005, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+1006: 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, 1006, __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, 1006, __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, 1006, __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, 1006, __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, 1006, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+1007: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 1005, __pyx_L49_error) }
1008: # Using the encoders for basic types:
+1009: 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); }
+1010: 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, 1010, __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, 1010, __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, 1010, __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;
+1011: 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; }
1012: pass
+1013: 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, 1013, __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; } } }
+1014: raise TypeError(f"Error type {T}: {e}") from e
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1014, __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, 1014, __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, 1014, __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, 1014, __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, 1014, __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, 1014, __pyx_L67_error) }
+1015: 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, 1015, __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;
+1016: raise ValueError(
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1016, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+1017: f"Error parsing type {T}: {e}"
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1017, __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, 1017, __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, 1017, __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, 1017, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+1018: ) from e
__Pyx_Raise(__pyx_t_11, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 1016, __pyx_L78_error) }
1019:
1020:
+1021: 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; };
1022: object field,
1023: object T,
1024: object name,
1025: object data,
1026: object encoder,
1027: object origin,
1028: object args,
+1029: 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, 1021, __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);
1030: ):
1031: """
1032: Handle field_type='typing' scenario.
1033: """
+1034: 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, 1034, __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, 1034, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_type_args = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1035:
+1036: 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_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1036, __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, 1036, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1036, __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, 1036, __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, 1036, __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, 1036, __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, 1036, __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, 1036, __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) { /* … */ }
+1037: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (likely(__pyx_t_2)) {
/* … */
}
+1038: 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) {
/* … */
}
1039: # e.g. Dict[K, V]
+1040: 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, 1040, __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, 1040, __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, 1040, __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, 1040, __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, 1040, __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, 1040, __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, 1040, __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, 1040, __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;
+1041: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1042: else:
+1043: 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, 1043, __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, 1043, __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, 1043, __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, 1043, __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, 1043, __pyx_L1_error) }
1044:
+1045: 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_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1045, __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, 1045, __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_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1045, __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, 1045, __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, 1045, __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) { /* … */ }
+1046: 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) { /* … */ }
+1047: 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, 1047, __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, 1047, __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, 1047, __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, 1047, __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) { /* … */ }
1048: # Homogeneous tuple: e.g. Tuple[float, ...]
+1049: return tuple(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1049, __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;
+1050: _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, 1050, __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, 1050, __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, 1050, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 1050, __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, 1050, __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, 1050, __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, 1050, __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, 1050, __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, 1050, __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, 1050, __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 *); };
+1051: for datum in data
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1051, __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, 1051, __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, 1051, __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, 1051, __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, 1051, __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, 1051, __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, 1051, __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, 1051, __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, 1051, __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, 1051, __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);
1052: )
+1053: 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, 1053, __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, 1053, __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, 1053, __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) { /* … */ }
1054: # Heterogeneous tuple: Convert each element to its corresponding type
+1055: return tuple(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __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;
+1056: _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, 1056, __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, 1056, __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, 1056, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_field)) { __Pyx_RaiseClosureNameError("field"); __PYX_ERR(0, 1056, __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, 1056, __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, 1056, __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, 1056, __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, 1056, __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 *); };
+1057: for typ, datum in zip(type_args, data)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __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, 1057, __pyx_L1_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1058: )
+1059: 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, 1059, __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, 1059, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = (__pyx_t_7 > 0); if (unlikely(__pyx_t_2)) { /* … */ }
1060: # Length mismatch but we have type arguments - try to convert what we can
+1061: 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, 1061, __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, 1061, __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, 1061, __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, 1061, __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, 1061, __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, 1061, __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, 1061, __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, 1061, __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, 1061, __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;
+1062: raise ValueError(error)
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1062, __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, 1062, __pyx_L1_error)
1063: # If we can't process it, just return as-is
+1064: 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, 1064, __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;
1065:
+1066: 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, 1066, __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, 1066, __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_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1066, __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, 1066, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1066, __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, 1066, __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, 1066, __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, 1066, __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) { /* … */ }
+1067: 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) { /* … */ }
+1068: data = [data]
__pyx_t_12 = PyList_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1068, __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, 1068, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_12); __pyx_t_12 = 0;
+1069: 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, 1069, __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;
+1070: field,
__pyx_t_12 = __pyx_cur_scope->__pyx_v_field;
__Pyx_INCREF(__pyx_t_12);
+1071: type_args,
__pyx_t_6 = __pyx_cur_scope->__pyx_v_type_args;
__Pyx_INCREF(__pyx_t_6);
1072: data,
+1073: encoder,
__pyx_t_1 = __pyx_cur_scope->__pyx_v_encoder;
__Pyx_INCREF(__pyx_t_1);
1074: origin,
1075: args,
1076: as_objects=as_objects
1077: )
1078:
1079: # handle None, Optional, Union:
+1080: 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, 1080, __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, 1080, __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) { /* … */ }
+1081: 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, 1081, __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;
1082:
+1083: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1084:
+1085: 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; };
1086: object field,
1087: tuple type_args,
1088: object data,
1089: object encoder,
1090: object origin,
1091: object args,
1092: object as_objects=False,
1093: dict typeinfo=None
1094: ):
1095: """
1096: Handle List[T] logic, trying to reduce overhead from repeated lookups.
1097: """
+1098: cdef list result = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1099: cdef list processed_sublist = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1099, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_processed_sublist = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1100: cdef list out = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_out = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1101: 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, 1101, __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, 1101, __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;
+1102: 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, 1102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_module = __pyx_t_1; __pyx_t_1 = 0;
+1103: 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, 1103, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_is_nested_typing = __pyx_t_2;
1104:
1105: # If no type args, we can't proceed with further logic
+1106: 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) {
/* … */
}
+1107: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1108:
+1109: if is_nested_typing:
if (__pyx_v_is_nested_typing) { /* … */ }
1110: # nested typing: e.g. List[List[Foo]] or List[Optional[Foo]] etc.
+1111: 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; }
+1112: 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, 1112, __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, 1112, __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;
+1113: 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, 1113, __pyx_L5_error) if (__pyx_t_4) { /* … */ }
+1114: 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, 1114, __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, 1114, __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, 1114, __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, 1114, __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, 1114, __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, 1114, __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, 1114, __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, 1114, __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, 1114, __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;
+1115: 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, 1115, __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, 1115, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1116: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
+1117: 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, 1117, __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) { /* … */ }
+1118: inner_type = subT
__Pyx_INCREF(__pyx_v_subT);
__pyx_v_inner_type = __pyx_v_subT;
+1119: 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, 1119, __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, 1119, __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, 1119, __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, 1119, __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, 1119, __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, 1119, __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, 1119, __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, 1119, __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, 1119, __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;
+1120: 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) { /* … */ }
1121: # Convert single items to lists if needed
+1122: sublist = [sublist]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1122, __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, 1122, __pyx_L5_error); __Pyx_DECREF_SET(__pyx_v_sublist, __pyx_t_1); __pyx_t_1 = 0;
+1123: processed_sublist = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1123, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_processed_sublist, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+1124: 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, 1124, __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, 1124, __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, 1124, __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, 1124, __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, 1124, __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, 1124, __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, 1124, __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, 1124, __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, 1124, __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;
1125: # Convert each item to the expected inner type
+1126: if is_primitive(inner_type):
__Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1126, __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, 1126, __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, 1126, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L22; }
+1127: 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, 1127, __pyx_L5_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1127, __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; }
+1128: processed_sublist.append(int(item))
__pyx_t_13 = __Pyx_PyNumber_Int(__pyx_v_item); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1128, __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, 1128, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+1129: 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, 1129, __pyx_L5_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1129, __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; }
+1130: processed_sublist.append(float(item))
__pyx_t_13 = __Pyx_PyNumber_Float(__pyx_v_item); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1130, __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, 1130, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1131: else:
+1132: 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, 1132, __pyx_L5_error) } __pyx_L23:;
1133: else:
+1134: 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, 1134, __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, 1134, __pyx_L5_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_L22:;
+1135: 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, 1135, __pyx_L5_error)
+1136: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
1137: # Handle List[Optional[T]] or List[Union[...]]
+1138: 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, 1138, __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, 1138, __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) { /* … */ }
+1139: 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, 1139, __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, 1139, __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, 1139, __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, 1139, __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, 1139, __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, 1139, __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, 1139, __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, 1139, __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, 1139, __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;
+1140: 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, 1140, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_processed_item, __pyx_t_3); __pyx_t_3 = 0;
+1141: 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, 1141, __pyx_L5_error)
+1142: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L9_try_return;
1143: else:
1144: # fallback
+1145: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L9_try_return; }
+1146: 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, 1146, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_13);
+1147: 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;
+1148: 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, 1148, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L35_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1149: # build list of dataclasses
+1150: 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, 1150, __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, 1150, __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, 1150, __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, 1150, __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, 1150, __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, 1150, __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, 1150, __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, 1150, __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, 1150, __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;
+1151: 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, 1151, __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, 1151, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1152: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+1153: elif is_primitive(arg_type):
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1153, __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, 1153, __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, 1153, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (__pyx_t_2) { /* … */ }
1154: # For simple primitive types, don't create nested lists
+1155: result = []
__pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_13)); __pyx_t_13 = 0;
+1156: 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, 1156, __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, 1156, __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, 1156, __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, 1156, __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, 1156, __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, 1156, __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, 1156, __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, 1156, __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, 1156, __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;
1157: # Convert the item to the expected type
+1158: 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, 1158, __pyx_L1_error) __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_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; }
+1159: result.append(int(item))
__pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __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, 1159, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1160: 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, 1160, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1160, __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; }
+1161: result.append(float(item))
__pyx_t_3 = __Pyx_PyNumber_Float(__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1161, __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, 1161, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1162: 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, 1162, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1162, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L42; }
+1163: result.append(str(item))
__pyx_t_3 = __Pyx_PyObject_Unicode(__pyx_v_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1163, __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, 1163, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1164: 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, 1164, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1164, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L42; }
+1165: 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, 1165, __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, 1165, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1166: else:
+1167: 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, 1167, __pyx_L1_error) } __pyx_L42:;
+1168: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1169: else:
+1170: 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, 1170, __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, 1170, __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, 1170, __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, 1170, __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, 1170, __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, 1170, __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, 1170, __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, 1170, __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, 1170, __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; }
+1171: 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; }
+1172: 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, 1172, __pyx_L1_error)
1173: else:
1174: # Convert the item to the expected type
+1175: 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, 1175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_3); __pyx_t_3 = 0;
+1176: 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, 1176, __pyx_L1_error) } __pyx_L50:;
+1177: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1178:
+1179: 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 */
1180: """
1181: Helper for instantiating a dataclass.
1182: """
+1183: 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, 1183, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+1184: return val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_val); __pyx_r = __pyx_v_val; goto __pyx_L0;
+1185: if isinstance(val, dict):
__pyx_t_1 = PyDict_Check(__pyx_v_val);
if (__pyx_t_1) {
/* … */
}
+1186: 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, 1186, __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, 1186, __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, 1186, __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, 1186, __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;
+1187: 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) { /* … */ }
+1188: return cls(*val)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_val); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1188, __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, 1188, __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;
1189: else:
+1190: 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, 1190, __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; }
1191:
+1192: 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 */
1193: object field,
1194: object T,
1195: object data,
1196: object encoder,
1197: object origin,
1198: object args
1199: ):
1200: """
1201: Handle Optional or Union logic.
1202: """
1203: cdef object non_none_arg
+1204: 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, 1204, __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, 1204, __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;
+1205: cdef bint matched = False
__pyx_v_matched = 0;
1206:
1207: # Safety check to avoid null pointer dereference
+1208: 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, 1208, __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) { /* … */ }
+1209: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1210:
1211: # Early exit for None values in Optional types
+1212: 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, 1212, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1213: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1214:
+1215: 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, 1215, __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, 1215, __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, 1215, __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, 1215, __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, 1215, __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, 1215, __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, 1215, __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, 1215, __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, 1215, __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;
+1216: 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, 1216, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L12_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1217: # For container types, we still need to process their contents
+1218: 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, 1218, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1218, __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, 1218, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1218, __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, 1218, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1218, __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, 1218, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1218, __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, 1218, __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, 1218, __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, 1218, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1218, __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, 1218, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1218, __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, 1218, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1218, __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, 1218, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1218, __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; }
1219: # Continue to process contents
1220: pass
1221: else:
+1222: 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:;
1223:
1224: # e.g. Optional[T] is Union[T, NoneType]
+1225: 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, 1225, __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, 1225, __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, 1225, __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, 1225, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L27_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1226: # Pick the non-None type (assumes only two types in the Union)
+1227: 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, 1227, __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, 1227, __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, 1227, __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;
+1228: if non_none_arg is None:
__pyx_t_2 = (__pyx_v_non_none_arg == Py_None); if (__pyx_t_2) { /* … */ }
1229: # If only None type is in the Union, return None
+1230: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+1231: 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, 1231, __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, 1231, __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;
+1232: if non_none_origin is list:
__pyx_t_2 = (__pyx_v_non_none_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ }
1233: # Distinguish between typing.List and list
+1234: 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, 1234, __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, 1234, __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, 1234, __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) { /* … */ }
1235: # It's typing.List - use _parse_list_typing
+1236: 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, 1236, __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;
1237: field,
+1238: get_args(non_none_arg),
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1238, __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, 1238, __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, 1238, __pyx_L1_error)
1239: data,
1240: encoder,
1241: non_none_origin,
+1242: get_args(non_none_arg),
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_get_args); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1242, __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, 1242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; }
1243: None
1244: )
1245: else:
1246: # It's a plain list - use _parse_list_type
+1247: 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, 1247, __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; }
1248: field,
1249: non_none_arg,
1250: data,
1251: encoder,
+1252: get_args(non_none_arg),
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1252, __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, 1252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
1253: None
1254: )
1255: else:
+1256: 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, 1256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1257: field,
1258: T=non_none_arg,
1259: data=data,
1260: encoder=encoder,
1261: as_objects=False
1262: )
1263: # Remove None from args.
+1264: 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, 1264, __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, 1264, __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, 1264, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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, 1264, __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 *); };
1265: # If there are no non-None types left, simply return data.
+1266: if not args:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_args); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1266, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_2); if (__pyx_t_4) { /* … */ }
+1267: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1268:
+1269: 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, 1269, __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, 1269, __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, 1269, __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, 1269, __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, 1269, __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, 1269, __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, 1269, __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, 1269, __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, 1269, __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:;
+1270: 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, 1270, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+1271: matched = True
__pyx_v_matched = 1;
+1272: break
goto __pyx_L36_break;
+1273: if not matched:
__pyx_t_4 = (!__pyx_v_matched); if (unlikely(__pyx_t_4)) { /* … */ }
+1274: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1274, __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, 1274, __pyx_L1_error)
+1275: 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, 1275, __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, 1275, __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, 1275, __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, 1275, __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, 1275, __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, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1276: )
+1277: 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); }
+1278: 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, 1278, __pyx_L40_error) if (__pyx_t_4) { /* … */ }
+1279: if isinstance(data, dict):
__pyx_t_4 = PyDict_Check(__pyx_v_data);
if (__pyx_t_4) {
/* … */
}
+1280: 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, 1280, __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, 1280, __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, 1280, __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, 1280, __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;
+1281: 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) { /* … */ }
+1282: return t(*data)
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1282, __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, 1282, __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;
1283: else:
+1284: 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; } }
+1285: 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, 1285, __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;
+1286: 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, 1286, __pyx_L52_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1);
+1287: 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;
+1288: elif callable(t):
__pyx_t_4 = __Pyx_PyCallable_Check(__pyx_v_t); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1288, __pyx_L40_error) if (__pyx_t_4) { /* … */ }
+1289: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L44_try_return;
+1290: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L44_try_return;
+1291: 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;
1292: pass
+1293: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1294:
+1295: 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; CYTHON_UNUSED 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; CYTHON_UNUSED int __pyx_v_has_list_type; PyObject *__pyx_v_errors = 0; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_v_arg_type = NULL; PyObject *__pyx_v_subtype_origin = NULL; PyObject *__pyx_v_exc = NULL; PyObject *__pyx_v_error_msg = 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_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __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_errors); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XDECREF(__pyx_v_arg_type); __Pyx_XDECREF(__pyx_v_subtype_origin); __Pyx_XDECREF(__pyx_v_exc); __Pyx_XDECREF(__pyx_v_error_msg); __Pyx_XDECREF(__pyx_gb_9datamodel_10converters_17_parse_union_type_2generator4); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1296: object field,
1297: object T,
1298: object name,
1299: object data,
1300: object encoder,
1301: object origin,
1302: object targs
1303: ):
1304: """
1305: Attempt each type in the Union until one parses successfully
1306: or raise an error if all fail.
1307: If T is Optional[...] (i.e. a Union with NoneType), unwrap it.
1308: """
+1309: 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, 1309, __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, 1309, __pyx_L1_error) __pyx_v_field_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1310: cdef str error = None
__Pyx_INCREF(Py_None);
__pyx_v_error = ((PyObject*)Py_None);
+1311: cdef object non_none_arg = None
__Pyx_INCREF(Py_None);
__pyx_v_non_none_arg = Py_None;
+1312: cdef tuple inner_targs = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_targs = ((PyObject*)Py_None);
+1313: cdef bint is_typing = False
__pyx_v_is_typing = 0;
+1314: cdef bint has_list_type = False
__pyx_v_has_list_type = 0;
+1315: cdef list errors = [] # Collect all errors to report if all types fail
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_errors = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1316:
1317:
1318: # First, check for None in Optional types
+1319: if type(None) in targs and data is None:
__pyx_t_3 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_targs, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1319, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = (__pyx_v_data == Py_None); __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1320: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1321:
1322: # If the union includes NoneType, unwrap it and use only the non-None type.
+1323: 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, 1323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyObject_RichCompare(__pyx_v_origin, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L7_bool_binop_done; } __pyx_t_3 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(Py_None)), __pyx_v_targs, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1323, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1324: for arg in targs:
if (likely(PyList_CheckExact(__pyx_v_targs)) || PyTuple_CheckExact(__pyx_v_targs)) { __pyx_t_4 = __pyx_v_targs; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_targs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1324, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1324, __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_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1324, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1324, __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_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1324, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_4); 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, 1324, __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_4); __pyx_t_4 = 0; goto __pyx_L12_for_end; __pyx_L10_break:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L12_for_end; __pyx_L12_for_end:;
+1325: if arg is not type(None):
__pyx_t_2 = (__pyx_v_arg != ((PyObject *)Py_TYPE(Py_None))); if (__pyx_t_2) { /* … */ }
+1326: non_none_arg = arg
__Pyx_INCREF(__pyx_v_arg); __Pyx_DECREF_SET(__pyx_v_non_none_arg, __pyx_v_arg);
+1327: break
goto __pyx_L10_break;
+1328: is_typing = hasattr(non_none_arg, '__module__') and non_none_arg.__module__ == 'typing'
__pyx_t_3 = __Pyx_HasAttr(__pyx_v_non_none_arg, __pyx_n_u_module); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1328, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L13_bool_binop_done; } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_non_none_arg, __pyx_n_s_module); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_typing, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1328, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L13_bool_binop_done:; __pyx_v_is_typing = __pyx_t_2;
1329:
+1330: if non_none_arg is not None and is_typing is True:
__pyx_t_3 = (__pyx_v_non_none_arg != Py_None); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L16_bool_binop_done; } __pyx_t_3 = (__pyx_v_is_typing == 1); __pyx_t_2 = __pyx_t_3; __pyx_L16_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1331: # Invoke the parse_typing_type
+1332: 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, 1332, __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_4 = __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_4)) __PYX_ERR(0, 1332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_t_4) < 0) __PYX_ERR(0, 1332, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1333: 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, 1333, __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_4 = __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_4)) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_origin_2, __pyx_t_4) < 0) __PYX_ERR(0, 1333, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1334: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1335: 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_4 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_non_none_arg, __pyx_v_data, &__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
1336: field,
1337: non_none_arg,
1338: data,
1339: encoder,
1340: False
1341: )
1342:
1343: # First check for dataclasses in the union
+1344: for arg_type in targs:
if (likely(PyList_CheckExact(__pyx_v_targs)) || PyTuple_CheckExact(__pyx_v_targs)) { __pyx_t_4 = __pyx_v_targs; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_targs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1344, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1344, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1344, __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_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1344, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1344, __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_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 1344, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1344, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_6(__pyx_t_4); 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, 1344, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_arg_type, __pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_L19_continue:; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1345: subtype_origin = field._inner_origin or get_origin(arg_type)
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_origin); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1345, __pyx_L1_error) if (!__pyx_t_2) { __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { __Pyx_INCREF(__pyx_t_7); __pyx_t_1 = __pyx_t_7; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L21_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_v_arg_type}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_INCREF(__pyx_t_7); __pyx_t_1 = __pyx_t_7; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_L21_bool_binop_done:; __Pyx_XDECREF_SET(__pyx_v_subtype_origin, __pyx_t_1); __pyx_t_1 = 0;
+1346: 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, 1346, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+1347: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1348: try:
{ /*try:*/ { /* … */ } __pyx_L25_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L27_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_L31_try_continue:; __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_L19_continue; __pyx_L29_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; }
+1349: 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, 1349, __pyx_L25_error) } if (likely(PyDict_CheckExact(__pyx_v_data))) { __pyx_t_1 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1349, __pyx_L25_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, 1349, __pyx_L25_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, 1349, __pyx_L25_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_4); __pyx_t_4 = 0; goto __pyx_L29_try_return;
+1350: except Exception as exc:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_10) < 0) __PYX_ERR(0, 1350, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L38_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_26, &__pyx_t_27, &__pyx_t_28); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); __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_XGOTREF(__pyx_t_28); __pyx_t_15 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_22 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28); } __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25); __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_22; goto __pyx_L27_except_error; } __pyx_L35_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L33_except_continue; } } __pyx_L33_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L31_try_continue; } goto __pyx_L27_except_error;
+1351: errors.append(f"Failed to create dataclass {arg_type.__name__} from dict: {exc}")
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1351, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_11); __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_11, 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, 1351, __pyx_L38_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, 1351, __pyx_L38_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_11, 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_11, 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, 1351, __pyx_L38_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_11, 3, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_11, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1351, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_19); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1351, __pyx_L38_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+1352: continue
goto __pyx_L35_continue; }
+1353: 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, 1353, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+1354: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
1355: else:
1356: # For string inputs, don't accept them as dataclasses
+1357: if isinstance(data, (str, int, float, bool)):
/*else*/ { __Pyx_INCREF(((PyObject*)&PyBool_Type)); __pyx_t_10 = ((PyObject*)&PyBool_Type); __pyx_t_3 = PyUnicode_Check(__pyx_v_data); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L45_bool_binop_done; } __pyx_t_3 = PyInt_Check(__pyx_v_data); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L45_bool_binop_done; } __pyx_t_3 = PyFloat_Check(__pyx_v_data); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L45_bool_binop_done; } __pyx_t_3 = PyObject_IsInstance(__pyx_v_data, __pyx_t_10); __pyx_t_2 = __pyx_t_3; __pyx_L45_bool_binop_done:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_2) { /* … */ }
+1358: errors.append(f"Cannot convert {type(data).__name__} to {arg_type.__name__}")
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __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_10, 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, 1358, __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, 1358, __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_10, 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_10, 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, 1358, __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, 1358, __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_10, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_1); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1358, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1359: continue
goto __pyx_L19_continue;
+1360: try:
{ /*try:*/ { /* … */ } __pyx_L49_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_L51_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_L55_try_continue:; __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_L19_continue; __pyx_L53_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; } }
+1361: return arg_type(data)
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arg_type); __pyx_t_10 = __pyx_v_arg_type; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_10, __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, 1361, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L53_try_return;
+1362: except Exception as exc:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_21) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_10, &__pyx_t_7) < 0) __PYX_ERR(0, 1362, __pyx_L51_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); __pyx_v_exc = __pyx_t_10; /*try:*/ { /* … */ /*finally:*/ { __pyx_L62_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_24, &__pyx_t_23); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26) < 0)) __Pyx_ErrFetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); __Pyx_XGOTREF(__pyx_t_28); __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_t_21 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_29 = __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_24); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23); } __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_ErrRestore(__pyx_t_28, __pyx_t_27, __pyx_t_26); __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_29; goto __pyx_L51_except_error; } __pyx_L59_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L57_except_continue; } } __pyx_L57_except_continue:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L55_try_continue; } goto __pyx_L51_except_error;
+1363: errors.append(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, 1363, __pyx_L62_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_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_type, __pyx_n_s_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1363, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_11, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1363, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 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, 1363, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_18, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1363, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_11); __pyx_t_11 = 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_11 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1363, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_19, 6, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1363, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_11); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1363, __pyx_L62_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+1364: continue
goto __pyx_L59_continue; }
1365: else:
+1366: if is_primitive(arg_type):
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_is_primitive); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1366, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_arg_type}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1366, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1366, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_2) { /* … */ }
+1367: if isinstance(data, arg_type):
__pyx_t_2 = PyObject_IsInstance(__pyx_v_data, __pyx_v_arg_type); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1367, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+1368: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
+1369: continue
goto __pyx_L19_continue;
+1370: elif subtype_origin is list or subtype_origin is tuple:
__pyx_t_3 = (__pyx_v_subtype_origin == ((PyObject *)(&PyList_Type))); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L70_bool_binop_done; } __pyx_t_3 = (__pyx_v_subtype_origin == ((PyObject *)(&PyTuple_Type))); __pyx_t_2 = __pyx_t_3; __pyx_L70_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1371: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1372: try:
{ /*try:*/ { /* … */ } __pyx_L73_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_L75_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_L79_try_continue:; __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_L19_continue; __pyx_L77_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; }
+1373: return _parse_list_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __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_7)) __PYX_ERR(0, 1373, __pyx_L73_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L77_try_return;
+1374: except ValueError as exc:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_10, &__pyx_t_1) < 0) __PYX_ERR(0, 1374, __pyx_L75_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __pyx_v_exc = __pyx_t_10; /*try:*/ { /* … */ /*finally:*/ { __pyx_L86_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_26, &__pyx_t_27, &__pyx_t_28); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); __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_XGOTREF(__pyx_t_28); __pyx_t_15 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_30 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28); } __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25); __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_30; goto __pyx_L75_except_error; } __pyx_L83_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L81_except_continue; } } __pyx_L81_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L79_try_continue; } goto __pyx_L75_except_error;
+1375: errors.append(str(exc))
__pyx_t_11 = __Pyx_PyObject_Unicode(__pyx_v_exc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1375, __pyx_L86_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_11); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1375, __pyx_L86_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+1376: continue
goto __pyx_L83_continue; }
1377: else:
+1378: errors.append(f"Invalid type for {field_name}: Expected a list, got {type(data).__name__}")
/*else*/ { __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1378, __pyx_L1_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_10 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_list_got); __pyx_t_16 += 23; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_list_got); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Expected_a_list_got); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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, 1378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_7); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1378, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+1379: continue
goto __pyx_L19_continue; }
+1380: elif subtype_origin is set:
__pyx_t_2 = (__pyx_v_subtype_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_2) { /* … */ }
+1381: 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_L93_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_3; __pyx_L93_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1382: return set(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
+1383: elif isinstance(data, set):
__pyx_t_2 = PySet_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1384: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
1385: else:
+1386: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L95_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_L97_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_L101_try_continue:; __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_L19_continue; __pyx_L99_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; } }
+1387: return _parse_set_type(field, T, data, encoder, targs, None)
__Pyx_XDECREF(__pyx_r); __pyx_t_31.__pyx_n = 1; __pyx_t_31._parent = Py_None; __pyx_t_7 = __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_7)) __PYX_ERR(0, 1387, __pyx_L95_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L99_try_return;
+1388: except Exception as exc:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_21) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_10) < 0) __PYX_ERR(0, 1388, __pyx_L97_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L108_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_24, &__pyx_t_23); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26) < 0)) __Pyx_ErrFetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); __Pyx_XGOTREF(__pyx_t_28); __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_t_21 = __pyx_lineno; __pyx_t_15 = __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_25); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23); } __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_ErrRestore(__pyx_t_28, __pyx_t_27, __pyx_t_26); __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_32; goto __pyx_L97_except_error; } __pyx_L105_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L103_except_continue; } } __pyx_L103_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L101_try_continue; } goto __pyx_L97_except_error;
+1389: errors.append(f"Invalid type for {field_name}: Expected a set, got {type(data).__name__}")
__pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1389, __pyx_L108_error) __Pyx_GOTREF(__pyx_t_11); __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_11, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_19 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1389, __pyx_L108_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_11, 1, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_set_got); __pyx_t_16 += 22; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_set_got); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_Expected_a_set_got); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1389, __pyx_L108_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, 1389, __pyx_L108_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_11, 3, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_11, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1389, __pyx_L108_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_18); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1389, __pyx_L108_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+1390: continue
goto __pyx_L105_continue; }
+1391: elif subtype_origin is frozenset:
__pyx_t_2 = (__pyx_v_subtype_origin == ((PyObject *)(&PyFrozenSet_Type))); if (__pyx_t_2) { /* … */ }
+1392: 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_L115_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_3; __pyx_L115_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1393: return frozenset(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_10 = __Pyx_PyFrozenSet_New(__pyx_v_data); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
+1394: elif isinstance(data, frozenset):
__pyx_t_2 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_2) { /* … */ }
+1395: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
1396: else:
+1397: errors.append(f"Invalid type for {field_name}: Expected a frozenset, got {type(data).__name__}")
/*else*/ { __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __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_10, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1397, __pyx_L1_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_10, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_frozenset_got); __pyx_t_16 += 28; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_frozenset_got); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_Expected_a_frozenset_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, 1397, __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, 1397, __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_10, 3, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_7); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1397, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+1398: continue
goto __pyx_L19_continue; }
+1399: elif subtype_origin is list and field._inner_is_dc == True and isinstance(data, list):
__pyx_t_3 = (__pyx_v_subtype_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L117_bool_binop_done; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_inner_is_dc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = PyObject_RichCompare(__pyx_t_7, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1399, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1399, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L117_bool_binop_done; } __pyx_t_3 = PyList_Check(__pyx_v_data); __pyx_t_2 = __pyx_t_3; __pyx_L117_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1400: return _handle_list_of_dataclasses(field, field_name, data, T, None)
__Pyx_XDECREF(__pyx_r); __pyx_t_33.__pyx_n = 1; __pyx_t_33.parent = Py_None; __pyx_t_10 = __pyx_f_9datamodel_10converters__handle_list_of_dataclasses(__pyx_v_field, __pyx_v_field_name, __pyx_v_data, __pyx_v_T, &__pyx_t_33); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
+1401: elif subtype_origin is dict:
__pyx_t_2 = (__pyx_v_subtype_origin == ((PyObject *)(&PyDict_Type))); if (__pyx_t_2) { /* … */ }
+1402: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1403: return _parse_dict_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_10 = __pyx_f_9datamodel_10converters__parse_dict_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
1404: else:
+1405: errors.append(
/*else*/ { /* … */ __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_1); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1405, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1406: f"Invalid type for {field_name} Expected a dict, got {type(data).__name__}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __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_10, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1406, __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_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_a_dict_got); __pyx_t_16 += 22; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_dict_got); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_Expected_a_dict_got); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1406, __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, 1406, __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_10, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1407: )
+1408: continue
goto __pyx_L19_continue; }
+1409: elif arg_type is list:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ goto __pyx_L68; }
+1410: if isinstance(data, list):
__pyx_t_2 = PyList_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
goto __pyx_L121;
}
+1411: if arg_type is str:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyUnicode_Type))); if (__pyx_t_2) { /* … */ goto __pyx_L122; }
1412: # Ensure all elements in the list are strings
+1413: 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, 1413, __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, 1413, __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, 1413, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1413, __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, 1413, __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, 1413, __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, 1413, __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, 1413, __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, 1413, __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, 1413, __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, 1413, __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, 1413, __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, 1413, __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_1 = __pyx_pf_9datamodel_10converters_17_parse_union_type_genexpr(NULL, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_2) { /* … */ }
+1414: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
1415: else:
+1416: return _parse_list_type(field, arg_type, data, encoder, targs)
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_10 = __pyx_f_9datamodel_10converters__parse_list_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder, __pyx_v_targs, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0; } __pyx_L122:;
1417: else:
+1418: errors.append(
/*else*/ { /* … */ __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_7); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+1419: f"Invalid type for {field_name}: Expected a list, got {type(data).__name__}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __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_10, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L1_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_10, 1, __pyx_t_1); __pyx_t_1 = 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_10, 2, __pyx_kp_u_Expected_a_list_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, 1419, __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, 1419, __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_10, 3, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_10, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1420: )
+1421: continue
goto __pyx_L19_continue; } __pyx_L121:;
+1422: elif arg_type is dict:
__pyx_t_2 = (__pyx_v_arg_type == ((PyObject *)(&PyDict_Type))); if (__pyx_t_2) { /* … */ }
+1423: if isinstance(data, dict):
__pyx_t_2 = PyDict_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1424: return _parse_dict_type(field, arg_type, data, encoder, targs)
__Pyx_XDECREF(__pyx_r); __pyx_t_7 = __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_7)) __PYX_ERR(0, 1424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
1425: else:
+1426: errors.append(
/*else*/ { /* … */ __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_1); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1426, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1427: f"Invalid type for {field_name} Expected a dict, got {type(data).__name__}"
__pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1427, __pyx_L1_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_10 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_10); __pyx_t_10 = 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_7, 2, __pyx_kp_u_Expected_a_dict_got); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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_7, 3, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_7, 4, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1428: )
+1429: continue
goto __pyx_L19_continue; }
+1430: elif subtype_origin is None:
__pyx_t_2 = (__pyx_v_subtype_origin == Py_None); if (__pyx_t_2) { /* … */ }
+1431: try:
{ /*try:*/ { /* … */ } __pyx_L125_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_L127_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_L131_try_continue:; __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_L19_continue; __pyx_L129_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; }
+1432: 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, 1432, __pyx_L125_error) if (__pyx_t_2) { /* … */ }
+1433: 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, 1433, __pyx_L125_error) __pyx_t_34.__pyx_n = 2; __pyx_t_34.as_objects = Py_False; __pyx_t_34.parent = Py_None; __pyx_t_1 = __pyx_f_9datamodel_10converters__handle_dataclass_type(__pyx_v_field, ((PyObject*)__pyx_v_name), __pyx_v_data, __pyx_v_arg_type, &__pyx_t_34); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1433, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L129_try_return;
+1434: elif arg_type in encoders:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_encoders); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1434, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_arg_type, __pyx_t_1, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1434, __pyx_L125_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+1435: return _parse_builtin_type(field, arg_type, data, encoder)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_9datamodel_10converters__parse_builtin_type(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, __pyx_v_encoder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1435, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L129_try_return;
+1436: 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, 1436, __pyx_L125_error) if (__pyx_t_2) { /* … */ }
+1437: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L129_try_return;
1438: else:
1439: # Not matching => record an error
+1440: errors.append(
/*else*/ { /* … */ __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_7); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1440, __pyx_L125_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+1441: f"Invalid type for {field_name}, Data {data!r} is not an instance of {arg_type}"
__pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1441, __pyx_L125_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_7 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1441, __pyx_L125_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_1, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Data); __pyx_t_16 += 7; __Pyx_GIVEREF(__pyx_kp_u_Data); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Data); __pyx_t_7 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_data), __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1441, __pyx_L125_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_1, 3, __pyx_t_7); __pyx_t_7 = 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_1, 4, __pyx_kp_u_is_not_an_instance_of); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_arg_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1441, __pyx_L125_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_1, 5, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1441, __pyx_L125_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1442: )
+1443: continue
goto __pyx_L131_try_continue; }
+1444: except ValueError as exc:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_10) < 0) __PYX_ERR(0, 1444, __pyx_L127_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L139_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_26, &__pyx_t_27, &__pyx_t_28); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); __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_XGOTREF(__pyx_t_28); __pyx_t_15 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_35 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28); } __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25); __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_35; goto __pyx_L127_except_error; } __pyx_L136_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L134_except_continue; } } __pyx_L134_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L131_try_continue; } goto __pyx_L127_except_error;
+1445: errors.append(f"{field.name}: {exc}")
__pyx_t_18 = PyTuple_New(3); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1445, __pyx_L139_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 127; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1445, __pyx_L139_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_t_11, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1445, __pyx_L139_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 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, 0, __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, 1, __pyx_kp_u__7); __pyx_t_19 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1445, __pyx_L139_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, 2, __pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_18, 3, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1445, __pyx_L139_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_19); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1445, __pyx_L139_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
+1446: continue
goto __pyx_L136_continue; }
1447: else:
+1448: try:
/*else*/ { { /*try:*/ { /* … */ } __pyx_L145_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_L147_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_L151_try_continue:; __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_L19_continue; __pyx_L149_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_L68:; }
1449: # fallback to builtin parse
+1450: 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_10 = __pyx_f_9datamodel_10converters__parse_typing(__pyx_v_field, __pyx_v_arg_type, __pyx_v_data, &__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1450, __pyx_L145_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L149_try_return;
1451: field,
1452: arg_type,
1453: data,
1454: encoder,
1455: False
1456: )
+1457: except ValueError as exc:
__pyx_t_21 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_21) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 1457, __pyx_L147_except_error) __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L158_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_24, &__pyx_t_23); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26) < 0)) __Pyx_ErrFetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); __Pyx_XGOTREF(__pyx_t_28); __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_t_21 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_36 = __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_24); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23); } __Pyx_XGIVEREF(__pyx_t_28); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_ErrRestore(__pyx_t_28, __pyx_t_27, __pyx_t_26); __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_36; goto __pyx_L147_except_error; } __pyx_L155_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L153_except_continue; } } __pyx_L153_except_continue:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L151_try_continue; }
+1458: errors.append(f"{field.name}: {exc}")
__pyx_t_19 = PyTuple_New(3); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1458, __pyx_L158_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_16 = 0; __pyx_t_17 = 127; __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1458, __pyx_L158_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_18, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1458, __pyx_L158_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_kp_u__7); __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1458, __pyx_L158_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_17; __pyx_t_16 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_19, 3, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1458, __pyx_L158_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_11); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1458, __pyx_L158_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+1459: continue
goto __pyx_L155_continue; }
+1460: except Exception as exc:
__pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_15) { __Pyx_AddTraceback("datamodel.converters._parse_union_type", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_10) < 0) __PYX_ERR(0, 1460, __pyx_L147_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_v_exc = __pyx_t_1; /*try:*/ { /* … */ /*finally:*/ { __pyx_L169_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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_26, &__pyx_t_27, &__pyx_t_28); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); __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_XGOTREF(__pyx_t_28); __pyx_t_15 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_37 = __pyx_filename; { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_26); __Pyx_XGIVEREF(__pyx_t_27); __Pyx_XGIVEREF(__pyx_t_28); __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28); } __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25); __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_37; goto __pyx_L147_except_error; } __pyx_L166_continue: { __Pyx_DECREF(__pyx_v_exc); __pyx_v_exc = 0; goto __pyx_L164_except_continue; } } __pyx_L164_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L151_try_continue; } goto __pyx_L147_except_error;
+1461: errors.append(f"Parse Error on {field.name}, {arg_type}: {exc}")
__pyx_t_11 = PyTuple_New(6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1461, __pyx_L169_error) __Pyx_GOTREF(__pyx_t_11); __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_11, 0, __pyx_kp_u_Parse_Error_on); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_name_2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1461, __pyx_L169_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, 1461, __pyx_L169_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_11, 1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__10); __pyx_t_16 += 2; __Pyx_GIVEREF(__pyx_kp_u__10); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u__10); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_arg_type, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1461, __pyx_L169_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_11, 3, __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_11, 4, __pyx_kp_u__7); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1461, __pyx_L169_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_11, 5, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_11, 6, __pyx_t_16, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1461, __pyx_L169_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_errors, __pyx_t_18); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1461, __pyx_L169_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+1462: continue
goto __pyx_L166_continue; }
1463:
1464: # If we get here, all union attempts failed
+1465: if errors:
__pyx_t_2 = (PyList_GET_SIZE(__pyx_v_errors) != 0);
if (unlikely(__pyx_t_2)) {
/* … */
}
+1466: error_msg = f"All Union types failed for {field_name}. Errors: " + "; ".join(errors)
__pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_17 = 127; __Pyx_INCREF(__pyx_kp_u_All_Union_types_failed_for); __pyx_t_5 += 27; __Pyx_GIVEREF(__pyx_kp_u_All_Union_types_failed_for); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_All_Union_types_failed_for); __pyx_t_10 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_kp_u_Errors); __pyx_t_5 += 10; __Pyx_GIVEREF(__pyx_kp_u_Errors); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u_Errors); __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_4, 3, __pyx_t_5, __pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyUnicode_Join(__pyx_kp_u__11, __pyx_v_errors); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_error_msg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1467: raise ValueError(error_msg)
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_error_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1467, __pyx_L1_error)
1468: else:
+1469: raise ValueError(
/*else*/ { /* … */ __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1469, __pyx_L1_error) }
+1470: f"Invalid type for {field_name} with data={data}, no matching type found"
__pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __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_1, 0, __pyx_kp_u_Invalid_type_for_2); __pyx_t_4 = __Pyx_PyUnicode_Unicode(__pyx_v_field_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_with_data); __pyx_t_5 += 11; __Pyx_GIVEREF(__pyx_kp_u_with_data); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_with_data); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_data, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_17) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_17; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_no_matching_type_found); __pyx_t_5 += 24; __Pyx_GIVEREF(__pyx_kp_u_no_matching_type_found); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_no_matching_type_found); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_5, __pyx_t_17); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1471: )
1472:
+1473: 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; };
1474: object field,
1475: object T,
1476: object data,
+1477: object encoder=None,
PyObject *__pyx_v_encoder = ((PyObject *)Py_None);
+1478: 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; } } }
1479: ):
1480: """
1481: Parse a value to a typing type.
1482: """
1483: # local cdef variables:
+1484: cdef object origin = get_origin(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1484, __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, 1484, __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;
+1485: cdef object targs = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1485, __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, 1485, __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;
+1486: 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, 1486, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_name = __pyx_t_1; __pyx_t_1 = 0;
+1487: cdef object sub = None # for subtypes, local cache
__Pyx_INCREF(Py_None);
__pyx_v_sub = Py_None;
+1488: cdef object result = None
__Pyx_INCREF(Py_None);
__pyx_v_result = Py_None;
+1489: 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, 1489, __pyx_L1_error) __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_isdc = __pyx_t_1; __pyx_t_1 = 0;
1490:
+1491: if data is None:
__pyx_t_5 = (__pyx_v_data == Py_None); if (__pyx_t_5) { /* … */ }
+1492: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1493:
+1494: if isdc:
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_isdc); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1494, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+1495: 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, 1495, __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, 1495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1496: # Field type shortcuts
+1497: 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) {
/* … */
}
+1498: 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, 1498, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1499: elif origin is list:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_5) { /* … */ }
+1500: 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, 1500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1501: elif origin is tuple:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyTuple_Type))); if (__pyx_t_5) { /* … */ }
+1502: 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, 1502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1503: elif origin is set:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_5) { /* … */ }
1504: # Handle Sets - convert lists to sets
+1505: 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) { /* … */ }
+1506: 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, 1506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1507: elif isinstance(data, set):
__pyx_t_5 = PySet_Check(__pyx_v_data);
if (__pyx_t_5) {
/* … */
}
+1508: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1509: else:
+1510: 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, 1510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PySet_Add(__pyx_t_2, __pyx_v_data) < 0) __PYX_ERR(0, 1510, __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, 1510, __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; }
+1511: elif origin is frozenset:
__pyx_t_5 = (__pyx_v_origin == ((PyObject *)(&PyFrozenSet_Type))); if (__pyx_t_5) { /* … */ }
1512: # Handle Frozensets - convert lists to frozensets
+1513: 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) { /* … */ }
+1514: 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, 1514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1515: elif isinstance(data, frozenset):
__pyx_t_5 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_5) { /* … */ }
+1516: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1517: else:
+1518: 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, 1518, __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, 1518, __pyx_L1_error); __pyx_t_3 = __Pyx_PyFrozenSet_New(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1518, __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, 1518, __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; }
+1519: elif origin is not None:
__pyx_t_5 = (__pyx_v_origin != Py_None); if (__pyx_t_5) { /* … */ }
+1520: 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, 1520, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1520, __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, 1520, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1520, __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, 1520, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1520, __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, 1520, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1520, __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, 1520, __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, 1520, __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) { /* … */ }
+1521: 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, 1521, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1522: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+1523: elif T is set:
__pyx_t_5 = (__pyx_v_T == ((PyObject *)(&PySet_Type))); if (__pyx_t_5) { /* … */ }
1524: # Handle bare 'set' type
+1525: 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) { /* … */ }
+1526: 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, 1526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1527: elif isinstance(data, set):
__pyx_t_5 = PySet_Check(__pyx_v_data);
if (__pyx_t_5) {
/* … */
}
+1528: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1529: else:
+1530: 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, 1530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_data) < 0) __PYX_ERR(0, 1530, __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, 1530, __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; }
1531: else:
1532: # fallback to builtin parse
+1533: 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, 1533, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_1); __pyx_t_1 = 0;
+1534: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; }
1535:
+1536: 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; };
1537: object field,
1538: object T,
1539: object data,
+1540: object encoder=None,
PyObject *__pyx_v_encoder = ((PyObject *)Py_None);
+1541: object as_objects=False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False);
+1542: 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; } } } }
1543: ):
1544: """
1545: Parse a value to a typing type.
1546: """
1547: # local cdef variables:
1548: cdef object origin, targs
+1549: 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, 1549, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_name = __pyx_t_1; __pyx_t_1 = 0;
+1550: cdef object sub = None # for subtypes, local cache
__Pyx_INCREF(Py_None);
__pyx_v_sub = Py_None;
+1551: cdef object result = None
__Pyx_INCREF(Py_None);
__pyx_v_result = Py_None;
+1552: cdef object inner_type = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_type = Py_None;
+1553: cdef bint inner_is_dc = 0 # field._inner_is_dc or is_dataclass(inner_type)
__pyx_v_inner_is_dc = 0;
1554:
+1555: if data is None:
__pyx_t_2 = (__pyx_v_data == Py_None); if (__pyx_t_2) { /* … */ }
+1556: return None # no data, short-circuiting
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1557:
1558: # Use cached values only if T is exactly the field's declared type.
+1559: 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, 1559, __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, 1559, __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, 1559, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L4; }
+1560: origin = field.origin
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_field, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_origin = __pyx_t_3; __pyx_t_3 = 0;
+1561: 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, 1561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_targs = __pyx_t_3; __pyx_t_3 = 0;
+1562: 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, 1562, __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, 1562, __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, 1562, __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, 1562, __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, 1562, __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; }
+1563: 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, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0;
+1564: 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, 1564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_targs = __pyx_t_1; __pyx_t_1 = 0;
1565: else:
+1566: origin = get_origin(T)
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1566, __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, 1566, __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;
+1567: targs = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1567, __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, 1567, __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:;
1568:
1569: # For generic (typing) fields, reuse cached inner type info if available.
+1570: 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, 1570, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1570, __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, 1570, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1570, __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, 1570, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1570, __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, 1570, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L8_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L7; }
+1571: 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, 1571, __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; }
+1572: 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, 1572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_inner_type, __pyx_t_1); __pyx_t_1 = 0;
+1573: 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, 1573, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_inner_origin = __pyx_t_1; __pyx_t_1 = 0;
1574: # Optionally, also use cached type arguments for the inner type.
1575: else:
+1576: 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, 1576, __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, 1576, __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, 1576, __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;
+1577: inner_origin = get_origin(inner_type)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1577, __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, 1577, __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:;
1578: else:
+1579: inner_type = None
/*else*/ { __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_inner_type, Py_None);
+1580: inner_origin = None
__Pyx_INCREF(Py_None);
__pyx_v_inner_origin = Py_None;
}
__pyx_L7:;
1581:
+1582: 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, 1582, __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, 1582, __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, 1582, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L14_bool_binop_done:; __pyx_v_inner_is_dc = __pyx_t_2;
1583:
1584: # Put more frequently cases first:
+1585: 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, 1585, __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, 1585, __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, 1585, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L17_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1586: 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, 1586, __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, 1586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1587:
1588: # If the field is a Union and data is a list, use _parse_union_type.
+1589: if origin is Union:
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Union); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __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) { /* … */ }
1590: # e.g. Optional[...] or Union[A, B]
+1591: 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, 1591, __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, 1591, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L21_bool_binop_done:; if (__pyx_t_2) { /* … */ }
1592: # Handle Optional[...] that is Union[..., None] cases first:
+1593: 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, 1593, __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, 1593, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
1594: # If Optional but non-None is a primitive
+1595: 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, 1595, __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, 1595, __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;
+1596: 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, 1596, __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, 1596, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
1597: # non-None is a Optional Dataclass:
+1598: 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, 1598, __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, 1598, __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, 1598, __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;
1599: else:
+1600: 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, 1600, __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, 1600, __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, 1600, __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;
1601: # Recursively parse the real_type exactly as if it weren't wrapped in Optional[…].
+1602: 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, 1602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1603: else:
+1604: 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; } }
+1605: 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, 1605, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L28_try_return;
1606: field,
1607: T,
1608: name,
1609: data,
1610: encoder,
1611: origin,
1612: targs
1613: )
+1614: 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, 1614, __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;
+1615: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_18); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1615, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+1616: f"Union parsing error for {field.name}: {e}"
__pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1616, __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, 1616, __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, 1616, __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, 1616, __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, 1616, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+1617: ) from e
__Pyx_Raise(__pyx_t_15, 0, 0, __pyx_v_e); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __PYX_ERR(0, 1615, __pyx_L35_error) }
1618: # Other Field types
+1619: 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, 1619, __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, 1619, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_2) { /* … */ }
1620: # For example, if the origin is list and the inner type is a dataclass,
1621: # use _handle_dataclass_type on each element.
+1622: if origin is list:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ }
+1623: if inner_is_dc:
if (__pyx_v_inner_is_dc) { /* … */ }
+1624: 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, 1624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1625: else:
+1626: 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, 1626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; }
1627: field, T, name, data, encoder, origin, targs, as_objects
1628: )
+1629: elif origin is set:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_2) { /* … */ }
+1630: 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, 1630, __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, 1630, __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, 1630, __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) { /* … */ }
+1631: 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) { /* … */ }
+1632: result = set()
__pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); __pyx_t_3 = 0;
+1633: 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, 1633, __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, 1633, __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, 1633, __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, 1633, __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, 1633, __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, 1633, __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, 1633, __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, 1633, __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, 1633, __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;
+1634: 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, 1634, __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, 1634, __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;
+1635: 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, 1635, __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, 1635, __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;
+1636: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+1637: elif isinstance(data, set):
__pyx_t_2 = PySet_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
1638: # Already a set, just validate/convert the elements
+1639: result = set()
__pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); __pyx_t_3 = 0;
+1640: 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, 1640, __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, 1640, __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, 1640, __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, 1640, __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, 1640, __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, 1640, __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, 1640, __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, 1640, __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, 1640, __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;
+1641: 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, 1641, __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, 1641, __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;
+1642: 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, 1642, __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, 1642, __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;
+1643: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
1644: else:
1645: # Single value, convert and wrap in a set
+1646: 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, 1646, __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, 1646, __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;
+1647: 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, 1647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_converted_item) < 0) __PYX_ERR(0, 1647, __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, 1647, __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; }
1648: else:
1649: # Untyped set, just convert to a set without validating elements
+1650: 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) { /* … */ }
+1651: return set(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
+1652: elif isinstance(data, set):
__pyx_t_2 = PySet_Check(__pyx_v_data);
if (__pyx_t_2) {
/* … */
}
+1653: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1654: else:
+1655: 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, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_data) < 0) __PYX_ERR(0, 1655, __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, 1655, __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; } }
1656: else:
+1657: 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, 1657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; }
1658: field, T, name, data, encoder, origin, targs, as_objects
1659: )
1660: # Handle container types with proper recursive processing
1661: # List types
+1662: elif origin is list:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_2) { /* … */ }
+1663: 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, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1664:
1665: # Set types
+1666: elif origin is set:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PySet_Type))); if (__pyx_t_2) { /* … */ }
+1667: 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, 1667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
1668:
1669: # FrozenSet types - process as set, then convert to frozenset
+1670: elif origin is frozenset:
__pyx_t_2 = (__pyx_v_origin == ((PyObject *)(&PyFrozenSet_Type))); if (__pyx_t_2) { /* … */ }
+1671: 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; }
1672: # Convert to set first if needed
+1673: 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; }
+1674: set_data = set(data)
__pyx_t_5 = PySet_New(__pyx_v_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1674, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_set_data = __pyx_t_5; __pyx_t_5 = 0;
+1675: elif isinstance(data, frozenset):
__pyx_t_2 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_2) { /* … */ goto __pyx_L65; }
+1676: set_data = data
__Pyx_INCREF(__pyx_v_data);
__pyx_v_set_data = __pyx_v_data;
1677: else:
+1678: 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, 1678, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_v_data) < 0) __PYX_ERR(0, 1678, __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, 1678, __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:;
1679:
1680: # Process as a set
+1681: 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, 1681, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_processed_set = __pyx_t_5; __pyx_t_5 = 0;
1682:
1683: # Convert back to frozenset
+1684: 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, 1684, __pyx_L59_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L63_try_return;
+1685: 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, 1685, __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;
1686: # Be resilient to errors
+1687: if isinstance(data, frozenset):
__pyx_t_2 = PyFrozenSet_Check(__pyx_v_data); if (__pyx_t_2) { /* … */ }
+1688: 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;
+1689: 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) { /* … */ }
+1690: return frozenset(data)
__Pyx_XDECREF(__pyx_r); __pyx_t_15 = __Pyx_PyFrozenSet_New(__pyx_v_data); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1690, __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;
1691: else:
+1692: 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, 1692, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_18); if (PySet_Add(__pyx_t_18, __pyx_v_data) < 0) __PYX_ERR(0, 1692, __pyx_L74_error) __pyx_t_17 = __Pyx_PyFrozenSet_New(__pyx_t_18); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1692, __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, 1692, __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; } }
1693: # Dict types
+1694: 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) {
/* … */
}
+1695: 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, 1695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+1696: elif origin is not None:
__pyx_t_2 = (__pyx_v_origin != Py_None); if (__pyx_t_2) { /* … */ }
1697: # other advanced generics
+1698: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
1699: else:
1700: # fallback to builtin parse
+1701: 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, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1702:
+1703: 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; }
1704: object field,
1705: object T,
1706: object data,
1707: object encoder
1708: ):
1709: """
1710: _parse_literal_type parses a typing.Literal[...] annotation.
1711:
1712: :param field: A Field object (or similar) containing metadata
1713: :param T: The full annotated type (e.g. typing.Literal['text/plain', 'text/html']).
1714: :param data: The input value to check.
1715: :param encoder: Optional encoder (not usually used for literal).
1716: :return: Returns 'data' if it matches one of the literal choices, otherwise raises ValueError.
1717: """
1718:
1719: # Each element in `targs` is a valid literal value, e.g. a string, int, etc.
1720: # If data is exactly in that set, it's valid.
+1721: 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, 1721, __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, 1721, __pyx_L1_error) __pyx_v_targs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1722: cdef tuple i
+1723: for arg in targs:
if (unlikely(__pyx_v_targs == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1723, __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, 1723, __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, 1723, __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, 1723, __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;
+1724: 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, 1724, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { /* … */ }
+1725: 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;
1726:
1727: # If we get here, data didn't match any literal value
+1728: raise ValueError(
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1728, __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, 1728, __pyx_L1_error)
+1729: f"Literal parse error for field '{field.name}': "
__pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1729, __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, 1729, __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, 1729, __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, 1729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1730: 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, 1730, __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, 1730, __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;
1731: )
1732:
+1733: 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; };
1734: object field,
1735: str name,
1736: object value,
1737: object _type,
+1738: object as_objects = False,
PyObject *__pyx_v_as_objects = ((PyObject *)Py_False);
+1739: 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);
1740: ):
1741: """
1742: _handle_dataclass_type.
1743:
1744: Process a field that is annotated as SomeDataclass.
1745: If there's a registered converter for the dataclass, call it;
1746: otherwise, build the dataclass using default logic.
1747: """
+1748: cdef tuple key = (_type, name)
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1748, __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, 1748, __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, 1748, __pyx_L1_error); __pyx_v_key = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1749: 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, 1749, __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, 1749, __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, 1749, __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, 1749, __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, 1749, __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;
+1750: 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, 1750, __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, 1750, __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, 1750, __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, 1750, __pyx_L1_error) __pyx_t_3 = __pyx_t_5; } __pyx_v_isdc = __pyx_t_3;
+1751: 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, 1751, __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, 1751, __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, 1751, __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;
+1752: 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, 1752, __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, 1752, __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, 1752, __pyx_L1_error) __pyx_v_alias = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1753:
+1754: 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, 1754, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L6_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1755: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
+1756: 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, 1756, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+1757: 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; }
1758: # If alias exists, adjust the key passed to the dataclass
+1759: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
1760: # if alias exists on type, preserve the alias:
+1761: 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, 1761, __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, 1761, __pyx_L9_error) __pyx_t_3 = __pyx_t_4; __pyx_L17_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+1762: value = value.copy()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1762, __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, 1762, __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;
+1763: 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, 1763, __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, 1763, __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, 1763, __pyx_L9_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1764: # convert the dictionary to the dataclass
+1765: 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, 1765, __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, 1765, __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, 1765, __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, 1765, __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;
+1766: 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, 1766, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_6);
1767: # Ensure keys are strings
+1768: 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, 1768, __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, 1768, __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, 1768, __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, 1768, __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, 1768, __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, 1768, __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;
+1769: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
+1770: value = value.copy()
__pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1770, __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, 1770, __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;
+1771: 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, 1771, __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, 1771, __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, 1771, __pyx_L11_except_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1772: 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, 1772, __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, 1772, __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, 1772, __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, 1772, __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; }
+1773: 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, 1773, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2);
1774: # replace in "value" dictionary the current "name" for "alias"
+1775: if alias:
__pyx_t_3 = (__pyx_v_alias != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_alias) != 0);
if (__pyx_t_3) {
/* … */
}
+1776: value = value.copy()
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_copy); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1776, __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, 1776, __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;
+1777: 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, 1777, __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, 1777, __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, 1777, __pyx_L11_except_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+1778: 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, 1778, __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, 1778, __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, 1778, __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, 1778, __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; }
+1779: 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, 1779, __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;
+1780: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1780, __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, 1780, __pyx_L36_error) }
+1781: f"Invalid value for {name}:{_type} == {value}, error: {exc}"
__pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1781, __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, 1781, __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, 1781, __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__12); __pyx_t_15 += 4; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_kp_u__12); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1781, __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); __pyx_t_15 += 9; __Pyx_GIVEREF(__pyx_kp_u_error); PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_kp_u_error); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1781, __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, 1781, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1782: )
+1783: 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; }
+1784: if PyObject_IsInstance(value, (list, tuple)):
__pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1784, __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, 1784, __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, 1784, __pyx_L42_error); __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_6); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1784, __pyx_L42_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { /* … */ }
+1785: return _type(*value)
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1785, __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, 1785, __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;
1786: else:
1787: # If a converter exists for this type, use it:
+1788: if converter:
/*else*/ { __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1788, __pyx_L42_error) if (__pyx_t_3) { /* … */ }
+1789: 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, 1789, __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;
+1790: if as_objects:
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_as_objects); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1790, __pyx_L42_error) if (__pyx_t_3) { /* … */ }
1791: # If alias exists, adjust the key passed to the dataclass
+1792: 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) {
/* … */
}
+1793: alias = name
__Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_alias, __pyx_v_name);
1794: # convert the list to the dataclass
+1795: return _type(**{alias: value})
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __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, 1795, __pyx_L42_error) } else { if (PyDict_SetItem(__pyx_t_1, __pyx_v_alias, __pyx_v_value) < 0) __PYX_ERR(0, 1795, __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, 1795, __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;
+1796: if PyObject_IsInstance(value, (int, str, UUID)):
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_UUID); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1796, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1796, __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, 1796, __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, 1796, __pyx_L42_error); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_6)) __PYX_ERR(0, 1796, __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, 1796, __pyx_L42_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* … */ }
+1797: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L46_try_return;
+1798: if isdc:
if (__pyx_v_isdc) { /* … */ }
+1799: 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) {
/* … */
}
+1800: alias = name
__Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_alias, __pyx_v_name);
+1801: return _type(**{alias: value})
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1801, __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, 1801, __pyx_L42_error) } else { if (PyDict_SetItem(__pyx_t_1, __pyx_v_alias, __pyx_v_value) < 0) __PYX_ERR(0, 1801, __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, 1801, __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;
1802: else:
+1803: 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, 1803, __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; } }
+1804: 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, 1804, __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;
+1805: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1805, __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, 1805, __pyx_L60_error) }
+1806: f"Invalid value for {name}:{_type} == {value}, error: {exc}"
__pyx_t_12 = PyTuple_New(8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1806, __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, 1806, __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, 1806, __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__12); __pyx_t_15 += 4; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_kp_u__12); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1806, __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); __pyx_t_15 += 9; __Pyx_GIVEREF(__pyx_kp_u_error); PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_kp_u_error); __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_exc, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1806, __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, 1806, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1807: )
1808:
+1809: 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; };
1810: object field,
1811: str name,
1812: object value,
1813: object _type,
+1814: 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; } }
1815: ):
1816: """
1817: _handle_list_of_dataclasses.
1818:
1819: Process a list field that is annotated as List[SomeDataclass].
1820: If there's a registered converter for the sub-dataclass, call it;
1821: otherwise, build the sub-dataclass using default logic.
1822: """
+1823: 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:; }
+1824: 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, 1824, __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, 1824, __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;
+1825: 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, 1825, __pyx_L3_error) if (__pyx_t_6) { /* … */ }
+1826: key = (sub_type, name)
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1826, __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, 1826, __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, 1826, __pyx_L3_error); __pyx_v_key = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1827: 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, 1827, __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, 1827, __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, 1827, __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, 1827, __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, 1827, __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;
+1828: new_list = []
__pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1828, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_new_list = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1829: 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, 1829, __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, 1829, __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, 1829, __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, 1829, __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, 1829, __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, 1829, __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, 1829, __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, 1829, __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, 1829, __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;
+1830: if converter:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1830, __pyx_L3_error) if (__pyx_t_6) { /* … */ goto __pyx_L14; }
+1831: 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, 1831, __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, 1831, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1832: elif isinstance(item, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_item);
if (__pyx_t_6) {
/* … */
goto __pyx_L14;
}
+1833: 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, 1833, __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, 1833, __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, 1833, __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, 1833, __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, 1833, __pyx_L3_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1834: else:
+1835: 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, 1835, __pyx_L3_error) } __pyx_L14:;
+1836: return new_list
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_list); __pyx_r = __pyx_v_new_list; goto __pyx_L7_try_return;
+1837: 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, 1837, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4);
+1838: 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, 1838, __pyx_L5_except_error) }
+1839: 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;
1840: pass
+1841: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1842:
1843: # Helper function to handle sets of dataclasses
+1844: 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; };
1845: object field,
1846: str name,
1847: object value,
1848: object _type,
+1849: 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; } }
1850: ):
1851: """
1852: _handle_set_of_dataclasses.
1853:
1854: Process a set field that is annotated as Set[SomeDataclass].
1855: If there's a registered converter for the sub-dataclass, call it;
1856: otherwise, build the sub-dataclass using default logic.
1857: """
+1858: 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:; }
+1859: 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, 1859, __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, 1859, __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;
+1860: 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, 1860, __pyx_L3_error) if (__pyx_t_6) { /* … */ }
+1861: key = (sub_type, name)
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1861, __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, 1861, __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, 1861, __pyx_L3_error); __pyx_v_key = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1862: 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, 1862, __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, 1862, __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, 1862, __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, 1862, __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, 1862, __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;
+1863: new_set = set()
__pyx_t_5 = PySet_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1863, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_new_set = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+1864: 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, 1864, __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, 1864, __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, 1864, __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, 1864, __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, 1864, __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, 1864, __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, 1864, __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, 1864, __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, 1864, __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;
+1865: if converter:
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_converter); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1865, __pyx_L3_error) if (__pyx_t_6) { /* … */ goto __pyx_L14; }
+1866: 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, 1866, __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, 1866, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1867: elif isinstance(item, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_item);
if (__pyx_t_6) {
/* … */
goto __pyx_L14;
}
+1868: 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, 1868, __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, 1868, __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, 1868, __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, 1868, __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, 1868, __pyx_L3_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
1869: else:
+1870: 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, 1870, __pyx_L3_error) } __pyx_L14:;
+1871: return new_set
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_set); __pyx_r = __pyx_v_new_set; goto __pyx_L7_try_return;
+1872: 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;
1873: pass
+1874: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1875:
+1876: 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; }
1877: object obj,
1878: str name,
1879: object value,
1880: object default_func,
1881: object default_is_callable
1882: ):
1883: """Handle default value of fields."""
1884: # If value is callable, try calling it directly
+1885: if PyCallable_Check(value):
__pyx_t_1 = PyCallable_Check(__pyx_v_value);
if (__pyx_t_1) {
/* … */
}
+1886: 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:; }
+1887: 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, 1887, __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;
+1888: 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, 1888, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7);
+1889: 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;
+1890: 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, 1890, __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;
+1891: 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, 1891, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15);
+1892: 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;
+1893: 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, 1893, __pyx_L1_error)
+1894: return new_val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_val); __pyx_r = __pyx_v_new_val; goto __pyx_L0;
1895:
1896: # If f.default is callable and value is None
+1897: 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, 1897, __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) { /* … */ }
+1898: 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:; }
+1899: 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, 1899, __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;
+1900: 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, 1900, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+1901: 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;
+1902: 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, 1902, __pyx_L1_error)
+1903: return new_val
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_val); __pyx_r = __pyx_v_new_val; goto __pyx_L0;
1904:
1905: # If there's a non-missing default and no value
+1906: 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, 1906, __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, 1906, __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) { /* … */ }
+1907: 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, 1907, __pyx_L1_error)
+1908: return default_func
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default_func); __pyx_r = __pyx_v_default_func; goto __pyx_L0;
1909:
1910: # Otherwise, return value as-is
+1911: return value
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
1912:
+1913: 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; }
1914: """
1915: _build_error.
1916:
1917: Build a tuple containing an error message and the name of the field.
1918: """
+1919: 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, 1919, __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, 1919, __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, 1919, __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, 1919, __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;
+1920: return {name: error_message}
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1920, __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, 1920, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
1921:
+1922: 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, 1922, __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, 1922, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("processing_fields", 1, 2, 2, 1); __PYX_ERR(0, 1922, __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, 1922, __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, 1922, __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, 1922, __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, 1922, __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__47 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_columns); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 1922, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__47); __Pyx_GIVEREF(__pyx_tuple__47); /* … */ __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__48)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1922, __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, 1922, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datamodel_converters_pyx, __pyx_n_s_processing_fields, 1922, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 1922, __pyx_L1_error)
1923: """
1924: Process the fields (columns) of a dataclass object.
1925:
1926: For each field, if a custom parser is attached (i.e. f.parser is not None),
1927: it is used to convert the value. Otherwise, the standard conversion logic
1928: (parse_basic, parse_typing, etc.) is applied.
1929: """
1930: cdef object new_val
+1931: cdef object _encoder = None
__Pyx_INCREF(Py_None);
__pyx_v__encoder = Py_None;
+1932: cdef object _default = None
__Pyx_INCREF(Py_None);
__pyx_v__default = Py_None;
+1933: cdef object _type = None
__Pyx_INCREF(Py_None);
__pyx_v__type = Py_None;
+1934: 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, 1934, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_meta = __pyx_t_1; __pyx_t_1 = 0;
+1935: 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, 1935, __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, 1935, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_as_objects = __pyx_t_2;
+1936: 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, 1936, __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, 1936, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_no_nesting = __pyx_t_2;
+1937: cdef tuple type_args = ()
__Pyx_INCREF(__pyx_empty_tuple);
__pyx_v_type_args = __pyx_empty_tuple;
1938: # Error handling
+1939: cdef dict errors = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_errors = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1940: # Type Information
+1941: cdef dict _typeinfo = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__typeinfo = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1942: # Column information:
1943: cdef tuple c_col
1944: cdef str name
1945: cdef object f
1946: cdef object value
1947: cdef object newval
1948:
+1949: for c_col in columns:
if (unlikely(__pyx_v_columns == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 1949, __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, 1949, __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, 1949, __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, 1949, __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, 1949, __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;
+1950: name = c_col[0]
if (unlikely(__pyx_v_c_col == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1950, __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, 1950, __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, 1950, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_name, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+1951: f = c_col[1]
if (unlikely(__pyx_v_c_col == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1951, __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, 1951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_4); __pyx_t_4 = 0;
+1952: value = getattr(obj, name)
__pyx_t_4 = __Pyx_GetAttr(__pyx_v_obj, __pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0;
1953: # Use the precomputed field type category:
+1954: 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, 1954, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_field_category, __pyx_t_4); __pyx_t_4 = 0;
1955:
+1956: 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, 1956, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
1957: # Handle descriptor-specific logic
+1958: 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:; }
+1959: 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, 1959, __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, 1959, __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;
+1960: 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, 1960, __pyx_L6_error)
+1961: 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, 1961, __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;
+1962: 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, 1962, __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, 1962, __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, 1962, __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, 1962, __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, 1962, __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; }
+1963: continue
goto __pyx_L3_continue;
1964:
1965: # get type and default:
+1966: _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, 1966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v__type, __pyx_t_9); __pyx_t_9 = 0;
+1967: _default = f.default
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_default); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v__default, __pyx_t_9); __pyx_t_9 = 0;
+1968: 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, 1968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_typeinfo, __pyx_t_9); __pyx_t_9 = 0;
+1969: 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, 1969, __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, 1969, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_type_args, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+1970: 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:; }
+1971: metadata = f.metadata
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_metadata); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1971, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_metadata, __pyx_t_9); __pyx_t_9 = 0;
+1972: 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, 1972, __pyx_L27_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4);
+1973: 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, 1973, __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;
1974:
1975: # _default_callable = typeinfo.get('default_callable', False)
1976: # Check if object is empty
+1977: 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, 1977, __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, 1977, __pyx_L1_error) __pyx_t_25 = (!__pyx_t_24); __pyx_t_2 = __pyx_t_25; __pyx_L36_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+1978: 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, 1978, __pyx_L1_error) __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 1978, __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) { /* … */ }
+1979: 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, 1979, __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, 1979, __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, 1979, __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;
1980: # PyObject_SetAttr(obj, name, value)
+1981: 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, 1981, __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, 1981, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1982: if _default is not None:
__pyx_t_2 = (__pyx_v__default != Py_None); if (__pyx_t_2) { /* … */ }
+1983: 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, 1983, __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, 1983, __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;
+1984: 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:; }
+1985: _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, 1985, __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, 1985, __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;
+1986: newval = value
__Pyx_INCREF(__pyx_v_value); __Pyx_XDECREF_SET(__pyx_v_newval, __pyx_v_value);
1987:
+1988: 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, 1988, __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; }
1989: # If a custom parser is attached to Field, use it
+1990: 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:; }
+1991: 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, 1991, __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, 1991, __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;
+1992: 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, 1992, __pyx_L51_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1992, __pyx_L51_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
+1993: 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, 1993, __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, 1993, __pyx_L51_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1994: 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, 1994, __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;
+1995: 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, 1995, __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; }
+1996: _build_error(name, f"Error parsing *{name}* = *{value}*", ex)
__pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1996, __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, 1996, __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__13); __pyx_t_13 += 5; __Pyx_GIVEREF(__pyx_kp_u__13); PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_kp_u__13); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1996, __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__14); __pyx_t_13 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_kp_u__14); __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_15, 5, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1996, __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, 1996, __pyx_L65_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
1997: )
+1998: 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, 1998, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+1999: 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:; }
+2000: 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, 2000, __pyx_L71_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+2001: 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, 2001, __pyx_L71_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2001, __pyx_L71_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { /* … */ }
+2002: 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, 2002, __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, 2002, __pyx_L71_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2003: 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, 2003, __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;
+2004: 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, 2004, __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; }
+2005: _build_error(name, f"Error parsing {name}: ", ex)
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2005, __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, 2005, __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, 2005, __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, 2005, __pyx_L85_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
2006: )
+2007: 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, 2007, __pyx_L42_error) if (__pyx_t_2) { goto __pyx_L50; }
2008: # TODO: support multiple types
2009: pass
+2010: 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, 2010, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+2011: 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:; }
+2012: if no_nesting is False:
__pyx_t_2 = (__pyx_v_no_nesting == 0); if (__pyx_t_2) { /* … */ }
+2013: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L100; }
+2014: 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, 2014, __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;
+2015: 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, 2015, __pyx_L91_error) __Pyx_GOTREF(__pyx_t_8);
2016: )
2017: else:
+2018: 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, 2018, __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:;
+2019: 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, 2019, __pyx_L91_error) __Pyx_GOTREF(__pyx_t_4);
2020: )
+2021: 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, 2021, __pyx_L91_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2021, __pyx_L91_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ }
2022: # PyObject_SetAttr(obj, name, newval)
+2023: 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, 2023, __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, 2023, __pyx_L91_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2024: 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, 2024, __pyx_L93_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2025: 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, 2025, __pyx_L93_except_error) }
+2026: 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, 2026, __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;
+2027: 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, 2027, __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;
+2028: _build_error(name, f"Error parsing Dataclass: {name}: ", ex)
__pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2028, __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, 2028, __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, 2028, __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, 2028, __pyx_L109_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2029: )
+2030: continue
goto __pyx_L106_continue; }
+2031: elif f.origin in (list, 'list') and f._inner_is_dc:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2031, __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, 2031, __pyx_L42_error) __pyx_t_24 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 2031, __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, 2031, __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, 2031, __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, 2031, __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; }
+2032: 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:; }
+2033: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L127; }
+2034: 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, 2034, __pyx_L119_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
2035: else:
+2036: 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, 2036, __pyx_L119_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L127:;
+2037: 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, 2037, __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, 2037, __pyx_L119_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2038: 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, 2038, __pyx_L121_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2039: 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, 2039, __pyx_L121_except_error) }
+2040: 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, 2040, __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;
+2041: 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, 2041, __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;
+2042: _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, 2042, __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, 2042, __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, 2042, __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, 2042, __pyx_L135_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
2043: )
+2044: continue
goto __pyx_L132_continue; }
2045: # Handle set of dataclasses
+2046: 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_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2046, __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, 2046, __pyx_L42_error) __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 2046, __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, 2046, __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, 2046, __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, 2046, __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; }
+2047: 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:; }
+2048: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L153; }
+2049: 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, 2049, __pyx_L145_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
2050: else:
+2051: 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, 2051, __pyx_L145_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L153:;
+2052: 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, 2052, __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, 2052, __pyx_L145_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2053: 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, 2053, __pyx_L147_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2054: 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, 2054, __pyx_L147_except_error) }
+2055: 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, 2055, __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;
+2056: 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, 2056, __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;
+2057: _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, 2057, __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, 2057, __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, 2057, __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, 2057, __pyx_L161_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2058: )
+2059: continue
goto __pyx_L158_continue; }
+2060: 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, 2060, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+2061: 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, 2061, __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, 2061, __pyx_L42_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L167; }
+2062: 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:; }
2063: # means that is_dataclass(T)
+2064: 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, 2064, __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, 2064, __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;
+2065: 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, 2065, __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, 2065, __pyx_L168_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2066: 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, 2066, __pyx_L170_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+2067: 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, 2067, __pyx_L170_except_error) }
+2068: 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, 2068, __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;
+2069: 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, 2069, __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, 2069, __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, 2069, __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, 2069, __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, 2069, __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;
+2070: continue
goto __pyx_L180_continue; }
+2071: elif f.origin is Literal:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2071, __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, 2071, __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; }
+2072: 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:; }
2073: # e.g. Literal[...]
+2074: 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, 2074, __pyx_L189_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0;
+2075: 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, 2075, __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, 2075, __pyx_L189_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2076: 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, 2076, __pyx_L191_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2077: 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, 2077, __pyx_L191_except_error) }
+2078: 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, 2078, __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;
+2079: 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, 2079, __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, 2079, __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, 2079, __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, 2079, __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, 2079, __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;
+2080: continue
goto __pyx_L201_continue; }
+2081: elif f.origin is list:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2081, __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; }
+2082: 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:; }
2083: # Other typical case is when is a List of primitives.
+2084: 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, 2084, __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, 2084, __pyx_L210_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L218; }
+2085: 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, 2085, __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;
2086: f,
2087: _type,
2088: value,
2089: _encoder,
+2090: f.args,
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2090, __pyx_L210_error) __Pyx_GOTREF(__pyx_t_8);
2091: obj
2092: )
2093: else:
+2094: 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:;
+2095: 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, 2095, __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;
2096: f,
2097: _type,
2098: value,
2099: _encoder,
+2100: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2100, __pyx_L219_error) __Pyx_GOTREF(__pyx_t_4);
2101: obj
2102: )
+2103: 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, 2103, __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;
+2104: raise ValueError(
__pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2104, __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, 2104, __pyx_L232_error) }
+2105: f"Error parsing List: {name}: {e}"
__pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2105, __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, 2105, __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, 2105, __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, 2105, __pyx_L232_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2106: )
+2107: 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, 2107, __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, 2107, __pyx_L210_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2108: 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, 2108, __pyx_L212_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8);
+2109: 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, 2109, __pyx_L212_except_error) }
+2110: 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, 2110, __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;
+2111: 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, 2111, __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;
+2112: _build_error(name, f"Error parsing List {name}: ", ex)
__pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2112, __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, 2112, __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, 2112, __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, 2112, __pyx_L245_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
2113: )
+2114: continue
goto __pyx_L242_continue; }
+2115: elif f.origin is set:
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2115, __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; }
+2116: 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:; }
+2117: if isinstance(value, list):
__pyx_t_2 = PyList_Check(__pyx_v_value);
if (__pyx_t_2) {
/* … */
goto __pyx_L259;
}
+2118: newval = set(value) # Simple conversion for bare set
__pyx_t_9 = PySet_New(__pyx_v_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2118, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
+2119: 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, 2119, __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; }
2120: # is a primitive typing Set.
+2121: 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, 2121, __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;
2122: f,
2123: _type,
2124: value,
2125: _encoder,
+2126: f.args,
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2126, __pyx_L251_error) __Pyx_GOTREF(__pyx_t_9);
2127: obj
2128: )
2129: else:
+2130: 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:;
+2131: 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, 2131, __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;
2132: f,
2133: _type,
2134: value,
2135: _encoder,
+2136: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2136, __pyx_L260_error) __Pyx_GOTREF(__pyx_t_4);
2137: obj
2138: )
+2139: 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, 2139, __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;
+2140: raise ValueError(
__pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2140, __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, 2140, __pyx_L273_error) }
+2141: f"Error parsing Set: {name}: {e}"
__pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2141, __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, 2141, __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, 2141, __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, 2141, __pyx_L273_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
2142: )
+2143: 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, 2143, __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, 2143, __pyx_L251_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2144: 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, 2144, __pyx_L253_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2145: 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, 2145, __pyx_L253_except_error) }
+2146: 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, 2146, __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;
+2147: 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, 2147, __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, 2147, __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;
+2148: continue
goto __pyx_L283_continue; }
2149: # FrozenSet type
+2150: elif f.origin is frozenset:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2150, __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; }
+2151: 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:; }
+2152: if value is not None:
__pyx_t_2 = (__pyx_v_value != Py_None); if (__pyx_t_2) { /* … */ goto __pyx_L300; }
2153: # Convert to set first if needed
+2154: 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, 2154, __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, 2154, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_9); if (PySet_Add(__pyx_t_9, __pyx_v_value) < 0) __PYX_ERR(0, 2154, __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;
+2155: 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, 2155, __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, 2155, __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;
2156: f,
2157: _type,
2158: set_value,
2159: _encoder,
+2160: f.args,
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_args_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2160, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_8);
2161: obj
2162: ))
2163: else:
+2164: newval = frozenset()
/*else*/ { __pyx_t_8 = __Pyx_PyFrozenSet_New(((PyObject *)NULL)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2164, __pyx_L292_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L300:;
+2165: 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, 2165, __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, 2165, __pyx_L292_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2166: 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, 2166, __pyx_L294_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9);
+2167: 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, 2167, __pyx_L294_except_error) }
+2168: 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, 2168, __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;
+2169: 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, 2169, __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, 2169, __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, 2169, __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, 2169, __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, 2169, __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;
+2170: continue
goto __pyx_L309_continue; }
+2171: elif f.origin is tuple:
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2171, __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; }
+2172: 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:; }
+2173: 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, 2173, __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, 2173, __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;
+2174: 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, 2174, __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, 2174, __pyx_L318_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2175: 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, 2175, __pyx_L320_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+2176: 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, 2176, __pyx_L320_except_error) }
+2177: 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, 2177, __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;
+2178: 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, 2178, __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, 2178, __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, 2178, __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, 2178, __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, 2178, __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;
+2179: continue
goto __pyx_L330_continue; }
2180: # If the field is a Union and data is a list, use _parse_union_type.
+2181: elif f.origin is Union:
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_origin_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2181, __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, 2181, __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; }
+2182: 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:; }
+2183: 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, 2183, __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, 2183, __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, 2183, __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, 2183, __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; }
2184: # e.g. Optional[...] or Union[A, B]
+2185: if value is None:
__pyx_t_2 = (__pyx_v_value == Py_None); if (__pyx_t_2) { /* … */ goto __pyx_L350; }
+2186: newval = None
__Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_newval, Py_None);
+2187: 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, 2187, __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, 2187, __pyx_L339_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L350; }
2188: # If Optional but non-None is a primitive
+2189: 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, 2189, __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, 2189, __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;
+2190: 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, 2190, __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, 2190, __pyx_L339_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L350; }
2191: # non-None is a Optional Dataclass Optional[dataclass]
+2192: 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, 2192, __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;
+2193: 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, 2193, __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, 2193, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_8);
2194: )
+2195: 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, 2195, __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; }
+2196: 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, 2196, __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, 2196, __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, 2196, __pyx_L339_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L351; }
+2197: 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, 2197, __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;
2198: f,
+2199: 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, 2199, __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, 2199, __pyx_L339_error)
2200: value,
2201: _encoder,
+2202: 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, 2202, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9);
+2203: 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, 2203, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4);
2204: obj
2205: )
2206: else:
+2207: 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, 2207, __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:;
2208: f,
+2209: 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, 2209, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_12);
2210: value,
2211: _encoder,
+2212: 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, 2212, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_4);
2213: obj
2214: )
+2215: 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, 2215, __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; }
+2216: 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, 2216, __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, 2216, __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, 2216, __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;
2217: else:
+2218: 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:;
+2219: 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, 2219, __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, 2219, __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, 2219, __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;
+2220: 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, 2220, __pyx_L357_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_12);
+2221: 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, 2221, __pyx_L357_except_error) }
+2222: 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, 2222, __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;
+2223: raise ValueError(
__pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2223, __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, 2223, __pyx_L370_error) }
+2224: f"Error parsing Optional: {name}: {e}"
__pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2224, __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, 2224, __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, 2224, __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, 2224, __pyx_L370_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2225: )
2226: else:
+2227: 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, 2227, __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:;
2228: f,
2229: _type,
2230: value,
2231: _encoder,
+2232: as_objects,
__pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2232, __pyx_L339_error) __Pyx_GOTREF(__pyx_t_9);
2233: obj
2234: )
+2235: 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, 2235, __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, 2235, __pyx_L339_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2236: 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, 2236, __pyx_L341_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12);
+2237: 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, 2237, __pyx_L341_except_error) }
+2238: 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, 2238, __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;
+2239: 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, 2239, __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, 2239, __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, 2239, __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, 2239, __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, 2239, __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;
+2240: continue
goto __pyx_L380_continue; }
2241: else:
+2242: 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:;
+2243: 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, 2243, __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;
2244: f,
2245: _type,
2246: value,
2247: _encoder,
+2248: as_objects,
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2248, __pyx_L389_error) __Pyx_GOTREF(__pyx_t_4);
2249: obj
2250: )
+2251: 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, 2251, __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, 2251, __pyx_L389_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2252: 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, 2252, __pyx_L391_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_12);
+2253: 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, 2253, __pyx_L391_except_error) }
+2254: 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, 2254, __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;
+2255: 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, 2255, __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, 2255, __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;
+2256: continue
goto __pyx_L401_continue; }
+2257: 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; }
+2258: if as_objects is True:
__pyx_t_2 = (__pyx_v_as_objects == 1); if (__pyx_t_2) { /* … */ goto __pyx_L412; }
+2259: 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, 2259, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
2260: else:
+2261: 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, 2261, __pyx_L42_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0; } __pyx_L412:;
+2262: 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, 2262, __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, 2262, __pyx_L42_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2263: 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, 2263, __pyx_L42_error) if (__pyx_t_2) { /* … */ goto __pyx_L50; }
+2264: 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:; }
+2265: 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, 2265, __pyx_L413_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_newval, __pyx_t_9); __pyx_t_9 = 0;
2266: f,
2267: _type,
2268: value,
2269: _encoder,
2270: type_args,
2271: obj
2272: )
+2273: 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, 2273, __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, 2273, __pyx_L413_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2274: 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, 2274, __pyx_L415_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_12);
+2275: 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, 2275, __pyx_L415_except_error) }
+2276: 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, 2276, __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;
+2277: 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, 2277, __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, 2277, __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;
+2278: continue
goto __pyx_L425_continue; }
2279: else:
2280: # fallback to builtin parse
+2281: 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:;
+2282: 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, 2282, __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;
2283: f,
2284: _type,
2285: value,
2286: _encoder,
+2287: as_objects,
__pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_as_objects); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2287, __pyx_L434_error) __Pyx_GOTREF(__pyx_t_9);
2288: obj
2289: )
+2290: 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, 2290, __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, 2290, __pyx_L434_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2291: 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, 2291, __pyx_L436_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12);
+2292: 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, 2292, __pyx_L436_except_error) }
+2293: 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, 2293, __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;
+2294: 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, 2294, __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, 2294, __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;
+2295: continue
goto __pyx_L446_continue; }
2296: # then, call the validation process:
+2297: 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, 2297, __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, 2297, __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, 2297, __pyx_L42_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ }
+2298: errors[name] = error
if (unlikely((PyDict_SetItem(__pyx_v_errors, __pyx_v_name, __pyx_v_error) < 0))) __PYX_ERR(0, 2298, __pyx_L42_error)
+2299: 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, 2299, __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; }
+2300: _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, 2300, __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, 2300, __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;
+2301: 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, 2301, __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)) { /* … */ }
+2302: 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, 2302, __pyx_L461_error)
2303: else:
+2304: 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, 2304, __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, 2304, __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, 2304, __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, 2304, __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, 2304, __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, 2304, __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, 2304, __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, 2304, __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, 2304, __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;
+2305: continue
goto __pyx_L458_continue; } }
+2306: 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, 2306, __pyx_L44_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4);
+2307: 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, 2307, __pyx_L44_except_error) }
+2308: 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, 2308, __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;
+2309: 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, 2309, __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, 2309, __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, 2309, __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, 2309, __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, 2309, __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, 2309, __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, 2309, __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, 2309, __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;
+2310: continue
goto __pyx_L472_continue; }
2311: # Return Errors (if any)
+2312: return errors
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_errors); __pyx_r = __pyx_v_errors; goto __pyx_L0;
2313:
+2314: 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; };
2315: str name,
2316: object value,
2317: object f,
2318: object _type,
2319: object meta,
2320: str field_category,
+2321: 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; } }
2322: ):
2323: """
2324: _validation_.
2325: TODO: cover validations as length, not_null, required, max, min, etc
2326: """
+2327: cdef object val_type = type(value)
__Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_value)));
__pyx_v_val_type = ((PyObject *)Py_TYPE(__pyx_v_value));
+2328: cdef str error = None
__Pyx_INCREF(Py_None);
__pyx_v_error = ((PyObject*)Py_None);
2329: cdef dict err = {
+2330: "field": name,
__pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2330, __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, 2330, __pyx_L1_error)
+2331: "value": value,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_value_2, __pyx_v_value) < 0) __PYX_ERR(0, 2330, __pyx_L1_error)
+2332: "error": None
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_error_2, Py_None) < 0) __PYX_ERR(0, 2330, __pyx_L1_error) __pyx_v_err = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
2333: }
2334:
+2335: 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, 2335, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2335, __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, 2335, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2335, __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, 2335, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+2336: 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; }
+2337: _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, 2337, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2338: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L11_try_return;
+2339: 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, 2339, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9);
+2340: 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, 2340, __pyx_L9_except_error) } goto __pyx_L9_except_error;
2341:
+2342: if isinstance(value, set):
__pyx_t_2 = PySet_Check(__pyx_v_value);
if (__pyx_t_2) {
/* … */
}
2343: # Just validate that all elements match the expected type if specified
+2344: 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, 2344, __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, 2344, __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, 2344, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_3); __pyx_t_2 = __pyx_t_10; __pyx_L17_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+2345: 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, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_inner_type = __pyx_t_9; __pyx_t_9 = 0;
2346: # For primitive types, we can use isinstance
+2347: 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, 2347, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2347, __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, 2347, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2347, __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, 2347, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2347, __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, 2347, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2347, __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) { /* … */ }
+2348: 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, 2348, __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, 2348, __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, 2348, __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, 2348, __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, 2348, __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, 2348, __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, 2348, __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, 2348, __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, 2348, __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;
+2349: 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, 2349, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_10); if (__pyx_t_2) { /* … */ }
+2350: 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, 2350, __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, 2350, __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, 2350, __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, 2350, __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, 2350, __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_2, __pyx_t_15) < 0))) __PYX_ERR(0, 2350, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+2351: 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;
+2352: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2353:
2354: # If the field has a cached validator, use it.
+2355: 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, 2355, __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) { /* … */ }
+2356: 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; }
+2357: 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, 2357, __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, 2357, __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, 2357, __pyx_L30_error) __Pyx_DECREF_SET(__pyx_v_error, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+2358: if error:
__pyx_t_2 = (__pyx_v_error != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_error) != 0);
if (__pyx_t_2) {
/* … */
}
+2359: err["error"] = error
if (unlikely((PyDict_SetItem(__pyx_v_err, __pyx_n_u_error_2, __pyx_v_error) < 0))) __PYX_ERR(0, 2359, __pyx_L30_error)
+2360: return err
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_err); __pyx_r = __pyx_v_err; goto __pyx_L34_try_return;
2361: else:
2362: # calling validation_constraints:
+2363: 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, 2363, __pyx_L30_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2363, __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, 2363, __pyx_L30_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2363, __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, 2363, __pyx_L30_error) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2363, __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) { /* … */ } }
+2364: 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, 2364, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_9); __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L34_try_return;
+2365: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L34_try_return;
+2366: 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, 2366, __pyx_L32_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_8);
+2367: 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, 2367, __pyx_L32_except_error) } goto __pyx_L32_except_error;
2368: else:
2369: # capturing other errors from validator:
+2370: 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, 2370, __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, 2370, __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, 2370, __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; }
2371:
+2372: 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; }
2373: # Validate Primary Key
+2374: 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, 2374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_metadata = __pyx_t_1; __pyx_t_1 = 0;
+2375: 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:; }
+2376: 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, 2376, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2376, __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__15 = PyTuple_Pack(2, __pyx_n_u_primary, Py_False); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 2376, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15);
+2377: 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, 2377, __pyx_L3_error) if (likely(__pyx_t_6)) { goto __pyx_L10; }
2378: pass
2379: else:
+2380: raise ValueError(
/*else*/ { /* … */ __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2380, __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, 2380, __pyx_L3_error) } __pyx_L10:;
+2381: f":: Missing Primary Key *{name}*"
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2381, __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, 2381, __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__14); __pyx_t_7 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u__14); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2381, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2382: )
+2383: 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;
2384: pass
2385: # Validate Required
+2386: 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:; }
+2387: 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, 2387, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2387, __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, 2387, __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__16 = PyTuple_Pack(2, __pyx_n_u_required, Py_False); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 2387, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16);
+2388: 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, 2388, __pyx_L11_error) if (__pyx_t_6) { /* … */ }
+2389: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L15_try_return;
+2390: if value is not None:
__pyx_t_6 = (__pyx_v_value != Py_None); if (__pyx_t_6) { /* … */ }
+2391: 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;
+2392: raise ValueError(
__pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2392, __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, 2392, __pyx_L11_error)
+2393: f":: Missing Required Field *{name}*"
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2393, __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, 2393, __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__14); __pyx_t_7 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2393, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2394: )
+2395: 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, 2395, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_11);
+2396: 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, 2396, __pyx_L13_except_error) }
+2397: 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, 2397, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1);
+2398: 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;
2399: # Nullable:
+2400: 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:; }
+2401: 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, 2401, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2401, __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, 2401, __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__17 = PyTuple_Pack(2, __pyx_n_u_nullable, Py_True); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 2401, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17);
+2402: raise ValueError(
__pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2402, __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, 2402, __pyx_L26_error)
+2403: f":: *{name}* Cannot be null."
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2403, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u__18); __pyx_t_7 += 4; __Pyx_GIVEREF(__pyx_kp_u__18); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u__18); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_v_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2403, __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, 2403, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2404: )
+2405: 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, 2405, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_11);
+2406: 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, 2406, __pyx_L28_except_error) }
+2407: 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, 2407, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5);
+2408: 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;
+2409: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2410:
2411:
+2412: 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, 2412, __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, 2412, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, 1); __PYX_ERR(0, 2412, __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, 2412, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("parse_type", 0, 3, 4, 2); __PYX_ERR(0, 2412, __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, 2412, __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, 2412, __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, 2412, __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, 2412, __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__49 = PyTuple_Pack(4, __pyx_n_s_field, __pyx_n_s_T, __pyx_n_s_data, __pyx_n_s_encoder); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 2412, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__49); __Pyx_GIVEREF(__pyx_tuple__49); /* … */ __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__50)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_tuple__46); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_type, __pyx_t_3) < 0) __PYX_ERR(0, 2412, __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; };
+2413: cdef object origin = get_origin(T)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_origin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2413, __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, 2413, __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;
+2414: cdef tuple args = None
__Pyx_INCREF(Py_None);
__pyx_v_args = ((PyObject*)Py_None);
+2415: 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, 2415, __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, 2415, __pyx_L1_error) __pyx_v_type_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2416: 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, 2416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_type_args = __pyx_t_1; __pyx_t_1 = 0;
+2417: 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, 2417, __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, 2417, __pyx_L1_error) __pyx_v_typeinfo = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
2418:
+2419: if isinstance(T, NewType):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_NewType); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2419, __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, 2419, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
2420: # change type if is a NewType object.
+2421: T = T.__supertype__
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_T, __pyx_n_s_supertype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_T, __pyx_t_1); __pyx_t_1 = 0;
2422:
2423: # Check if the data is already of the correct type
+2424: 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, 2424, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+2425: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2426:
+2427: 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, 2427, __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, 2427, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ goto __pyx_L5; }
+2428: args = type_args or ()
__pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_type_args); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2428, __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, 2428, __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;
+2429: 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, 2429, __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; }
+2430: if args:
__pyx_t_5 = (__pyx_v_args != Py_None)&&(PyTuple_GET_SIZE(__pyx_v_args) != 0);
if (__pyx_t_5) {
/* … */
}
+2431: 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, 2431, __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, 2431, __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, 2431, __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, 2431, __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, 2431, __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, 2431, __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, 2431, __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;
2432:
+2433: 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, 2433, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+2434: 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) { /* … */ }
+2435: data = [data]
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2435, __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, 2435, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+2436: arg_type = args[0]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 2436, __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, 2436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_arg_type = __pyx_t_1; __pyx_t_1 = 0;
+2437: 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, 2437, __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, 2437, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+2438: 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; }
+2439: 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, 2439, __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, 2439, __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;
+2440: 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, 2440, __pyx_L22_error) if (__pyx_t_6) { /* … */ }
+2441: result = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2441, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_result = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+2442: 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, 2442, __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, 2442, __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, 2442, __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, 2442, __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, 2442, __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, 2442, __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, 2442, __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, 2442, __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, 2442, __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;
+2443: if isinstance(x, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_x);
if (__pyx_t_6) {
/* … */
goto __pyx_L31;
}
+2444: 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, 2444, __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, 2444, __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, 2444, __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, 2444, __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, 2444, __pyx_L22_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2445: 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; }
+2446: result.append(t(*x))
__pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2446, __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, 2446, __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, 2446, __pyx_L22_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2447: else:
+2448: 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, 2448, __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, 2448, __pyx_L22_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L31:;
+2449: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L26_try_return;
2450: else:
+2451: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L26_try_return; }
+2452: 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, 2452, __pyx_L24_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3);
+2453: 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;
+2454: 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, 2454, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+2455: if isinstance(data, list):
__pyx_t_6 = PyList_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
}
+2456: result = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2457: 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, 2457, __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, 2457, __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, 2457, __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, 2457, __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, 2457, __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, 2457, __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, 2457, __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, 2457, __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, 2457, __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;
2458: # is already a dataclass:
+2459: 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, 2459, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L40; }
+2460: 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, 2460, __pyx_L1_error)
+2461: elif isinstance(d, list):
__pyx_t_6 = PyList_Check(__pyx_v_d);
if (__pyx_t_6) {
/* … */
goto __pyx_L40;
}
+2462: result.append(arg_type(*d))
__pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2462, __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, 2462, __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, 2462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2463: elif isinstance(d, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_d);
if (__pyx_t_6) {
/* … */
goto __pyx_L40;
}
+2464: 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, 2464, __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, 2464, __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, 2464, __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, 2464, __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, 2464, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2465: else:
+2466: 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, 2466, __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, 2466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L40:;
+2467: return result
__Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_result)) { __Pyx_RaiseUnboundLocalError("result"); __PYX_ERR(0, 2467, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
2468: else:
+2469: result = []
/*else*/ { __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2470: if is_iterable(data):
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2470, __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, 2470, __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, 2470, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ }
+2471: 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, 2471, __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, 2471, __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, 2471, __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, 2471, __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, 2471, __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, 2471, __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, 2471, __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, 2471, __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, 2471, __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;
2472: # escalar value:
+2473: 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, 2473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_converted_item, __pyx_t_1); __pyx_t_1 = 0;
+2474: 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, 2474, __pyx_L1_error)
+2475: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0;
+2476: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0; }
+2477: 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, 2477, __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, 2477, __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:;
+2478: args = get_args(T)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_get_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2478, __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, 2478, __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, 2478, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_args, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
2479: # Handling Optional types
+2480: 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, 2480, __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, 2480, __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, 2480, __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, 2480, __pyx_L1_error) __pyx_t_6 = __pyx_t_19; __pyx_L51_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+2481: if data is None:
__pyx_t_6 = (__pyx_v_data == Py_None); if (__pyx_t_6) { /* … */ }
+2482: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2483: # Determine the non-None type.
+2484: 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, 2484, __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, 2484, __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, 2484, __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, 2484, __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, 2484, __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, 2484, __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;
+2485: 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, 2485, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2485, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+2486: field.args = args
if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_v_args) < 0) __PYX_ERR(0, 2486, __pyx_L1_error)
+2487: 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, 2487, __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, 2487, __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_2, __pyx_t_1) < 0) __PYX_ERR(0, 2487, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2488: 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)) { /* … */ }
+2489: 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, 2489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2490: else:
+2491: 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, 2491, __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, 2491, __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, 2491, __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, 2491, __pyx_L1_error) }
2492: # If the non-None type is exactly dict, return the dict as is.
+2493: if non_none_arg is dict:
__pyx_t_6 = (__pyx_v_non_none_arg == ((PyObject *)(&PyDict_Type))); if (__pyx_t_6) { /* … */ }
+2494: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2495: # Otherwise, recursively parse using the non-None type.
+2496: field.args = args
if (__Pyx_PyObject_SetAttrStr(__pyx_v_field, __pyx_n_s_args_2, __pyx_v_args) < 0) __PYX_ERR(0, 2496, __pyx_L1_error)
+2497: 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, 2497, __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, 2497, __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_2, __pyx_t_1) < 0) __PYX_ERR(0, 2497, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2498: 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, 2498, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2499: 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); }
+2500: t = args[0]
if (unlikely(__pyx_v_args == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 2500, __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, 2500, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_t = __pyx_t_1; __pyx_t_1 = 0;
+2501: 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, 2501, __pyx_L60_error) if (__pyx_t_6) { /* … */ goto __pyx_L66; }
+2502: if isinstance(data, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_data);
if (__pyx_t_6) {
/* … */
goto __pyx_L67;
}
+2503: 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, 2503, __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, 2503, __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, 2503, __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, 2503, __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;
+2504: 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; }
+2505: data = t(*data)
__pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2505, __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, 2505, __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;
2506: else:
2507: ## is already a dataclass, returning
+2508: return data
/*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return; } __pyx_L67:;
+2509: elif callable(t):
__pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_t); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 2509, __pyx_L60_error) if (__pyx_t_6) { /* … */ } __pyx_L66:;
+2510: 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, 2510, __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, 2510, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
2511: # there is also a nested typing:
+2512: 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, 2512, __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, 2512, __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) { /* … */ }
+2513: 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, 2513, __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, 2513, __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;
+2514: 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, 2514, __pyx_L60_error) if (__pyx_t_6) { /* … */ }
+2515: result = []
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2515, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_result = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2516: 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, 2516, __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, 2516, __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, 2516, __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, 2516, __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, 2516, __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, 2516, __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, 2516, __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, 2516, __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, 2516, __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;
+2517: if isinstance(x, dict):
__pyx_t_6 = PyDict_Check(__pyx_v_x);
if (__pyx_t_6) {
/* … */
goto __pyx_L77;
}
+2518: 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, 2518, __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, 2518, __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, 2518, __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, 2518, __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, 2518, __pyx_L60_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2519: else:
+2520: result.append(arg(*x))
/*else*/ { __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_v_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2520, __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, 2520, __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, 2520, __pyx_L60_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L77:;
+2521: return result
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L64_try_return;
+2522: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return;
2523: else:
+2524: 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:; } }
+2525: 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, 2525, __pyx_L79_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2525, __pyx_L79_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ }
+2526: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L83_try_return;
+2527: fn = encoders[t]
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_encoders); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2527, __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, 2527, __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;
+2528: 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:; }
+2529: if data is not None:
__pyx_t_6 = (__pyx_v_data != Py_None); if (__pyx_t_6) { /* … */ }
+2530: 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, 2530, __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;
+2531: 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, 2531, __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; }
2532: pass
+2533: 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, 2533, __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;
+2534: raise ValueError(
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_27); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2534, __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, 2534, __pyx_L105_error) }
+2535: f"Model: Error parsing {T}, {exc}"
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2535, __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, 2535, __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, 2535, __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, 2535, __pyx_L105_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2536: )
+2537: 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;
2538: pass
+2539: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L64_try_return;
+2540: 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;
2541: pass
+2542: 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) {
/* … */
}
+2543: 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, 2543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2544: elif origin is list:
__pyx_t_6 = (__pyx_v_origin == ((PyObject *)(&PyList_Type))); if (__pyx_t_6) { /* … */ }
+2545: 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, 2545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2546: elif origin is not None:
__pyx_t_6 = (__pyx_v_origin != Py_None); if (__pyx_t_6) { /* … */ }
2547: # Other typing constructs can be handled here
+2548: return data
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2549: else:
+2550: 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, 2550, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; } __pyx_L5:;