Cython 3.2.6__py3-none-any.whl → 3.3.0a2.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Cython might be problematic. Click here for more details.
- Cython/Build/BuildExecutable.py +1 -14
- Cython/Build/Dependencies.py +6 -44
- Cython/Build/Inline.py +7 -3
- Cython/Build/IpythonMagic.py +0 -1
- Cython/Build/SharedModule.py +1 -2
- Cython/Build/Tests/TestCythonizeArgsParser.py +6 -6
- Cython/Build/Tests/TestDependencies.py +3 -3
- Cython/Build/Tests/TestInline.py +3 -3
- Cython/Build/Tests/TestIpythonMagic.py +35 -19
- Cython/Build/Tests/TestStripLiterals.py +2 -2
- Cython/Compiler/Buffer.py +5 -5
- Cython/Compiler/Builtin.py +57 -46
- Cython/Compiler/Code.pxd +12 -9
- Cython/Compiler/Code.py +220 -94
- Cython/Compiler/Dataclass.py +78 -52
- Cython/Compiler/Errors.py +21 -8
- Cython/Compiler/ExprNodes.py +871 -459
- Cython/Compiler/FlowControl.pxd +8 -6
- Cython/Compiler/FlowControl.py +111 -8
- Cython/Compiler/FusedNode.py +17 -12
- Cython/Compiler/Lexicon.py +123 -122
- Cython/Compiler/Main.py +3 -4
- Cython/Compiler/MatchCaseNodes.py +1948 -10
- Cython/Compiler/MemoryView.py +62 -33
- Cython/Compiler/ModuleNode.py +559 -283
- Cython/Compiler/Naming.py +4 -0
- Cython/Compiler/Nodes.py +333 -197
- Cython/Compiler/Optimize.py +268 -112
- Cython/Compiler/Options.py +0 -5
- Cython/Compiler/ParseTreeTransforms.pxd +2 -1
- Cython/Compiler/ParseTreeTransforms.py +180 -76
- Cython/Compiler/Parsing.py +55 -38
- Cython/Compiler/PyrexTypes.py +364 -128
- Cython/Compiler/Scanning.pxd +27 -5
- Cython/Compiler/Scanning.py +24 -14
- Cython/Compiler/StringEncoding.py +1 -2
- Cython/Compiler/Symtab.py +27 -19
- Cython/Compiler/Tests/TestBuiltin.py +41 -6
- Cython/Compiler/Tests/TestCmdLine.py +3 -2
- Cython/Compiler/Tests/TestCode.py +4 -3
- Cython/Compiler/Tests/TestFlowControl.py +2 -2
- Cython/Compiler/Tests/TestParseTreeTransforms.py +2 -2
- Cython/Compiler/Tests/TestScanning.py +2 -4
- Cython/Compiler/Tests/TestSignatureMatching.py +3 -3
- Cython/Compiler/Tests/TestStringEncoding.py +2 -3
- Cython/Compiler/Tests/TestTypes.py +46 -3
- Cython/Compiler/Tests/TestUtilityLoad.py +4 -4
- Cython/Compiler/TypeInference.py +20 -0
- Cython/Compiler/TypeSlots.py +171 -16
- Cython/Compiler/UtilNodes.py +24 -0
- Cython/Compiler/UtilityCode.py +1 -0
- Cython/Compiler/Visitor.pxd +1 -1
- Cython/Compiler/Visitor.py +3 -2
- Cython/Debugger/Tests/TestLibCython.py +7 -2
- Cython/Debugger/Tests/test_libcython_in_gdb.py +4 -2
- Cython/Debugger/Tests/test_libpython_in_gdb.py +1 -1
- Cython/Includes/cpython/array.pxd +5 -5
- Cython/Includes/cpython/dict.pxd +1 -6
- Cython/Includes/cpython/float.pxd +19 -10
- Cython/Includes/cpython/frozendict.pxd +37 -0
- Cython/Includes/cpython/long.pxd +31 -0
- Cython/Includes/cpython/object.pxd +9 -12
- Cython/Includes/cpython/sentinel.pxd +17 -0
- Cython/Includes/cpython/type.pxd +93 -0
- Cython/Includes/libcpp/exception.pxd +90 -0
- Cython/LZSS.py +170 -0
- Cython/Shadow.py +550 -73
- Cython/StringIOTree.py +1 -2
- Cython/Tempita/_tempita.py +45 -46
- Cython/TestUtils.py +50 -8
- Cython/Tests/TestCythonUtils.py +2 -2
- Cython/Tests/TestJediTyper.py +1 -1
- Cython/Tests/TestShadow.py +7 -5
- Cython/Tests/TestStringIOTree.py +4 -3
- Cython/Tests/TestTestUtils.py +2 -3
- Cython/Utility/AsyncGen.c +59 -19
- Cython/Utility/Buffer.c +4 -3
- Cython/Utility/Builtins.c +139 -17
- Cython/Utility/CConvert.pyx +27 -12
- Cython/Utility/CommonStructures.c +55 -37
- Cython/Utility/Coroutine.c +112 -68
- Cython/Utility/CythonFunction.c +607 -330
- Cython/Utility/Embed.c +8 -0
- Cython/Utility/Exceptions.c +20 -3
- Cython/Utility/ExtensionTypes.c +414 -224
- Cython/Utility/FunctionArguments.c +83 -81
- Cython/Utility/ImportExport.c +72 -61
- Cython/Utility/MatchCase.c +979 -0
- Cython/Utility/MatchCase_Cy.pyx +12 -0
- Cython/Utility/MemoryView.pxd +9 -88
- Cython/Utility/MemoryView.pyx +173 -61
- Cython/Utility/MemoryView_C.c +3 -3
- Cython/Utility/ModuleSetupCode.c +306 -157
- Cython/Utility/ObjectHandling.c +483 -404
- Cython/Utility/Optimize.c +1117 -164
- Cython/Utility/Overflow.c +3 -9
- Cython/Utility/Profile.c +4 -0
- Cython/Utility/StringTools.c +187 -149
- Cython/Utility/Synchronization.c +39 -0
- Cython/Utility/TString.c +24 -13
- Cython/Utility/TypeConversion.c +405 -250
- Cython/Utility/arrayarray.h +24 -22
- Cython/Utils.py +11 -23
- Cython/__init__.py +3 -1
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/METADATA +14 -33
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/RECORD +109 -107
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/WHEEL +1 -1
- Cython/Shadow.pyi +0 -521
- Cython/Utility/Printing.c +0 -86
- Cython/__init__.pyi +0 -7
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/entry_points.txt +0 -0
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/top_level.txt +0 -0
Cython/Utility/Buffer.c
CHANGED
|
@@ -652,8 +652,9 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
|
|
|
652
652
|
size_t struct_alignment = ctx->struct_alignment;
|
|
653
653
|
ctx->new_count = 1;
|
|
654
654
|
++ts;
|
|
655
|
-
if (*ts != '
|
|
656
|
-
|
|
655
|
+
if (*ts != '\x7B') {
|
|
656
|
+
// opening brace
|
|
657
|
+
PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '\x7B' after 'T'");
|
|
657
658
|
return NULL;
|
|
658
659
|
}
|
|
659
660
|
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
|
|
@@ -670,7 +671,7 @@ static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const cha
|
|
|
670
671
|
if (struct_alignment) ctx->struct_alignment = struct_alignment;
|
|
671
672
|
}
|
|
672
673
|
break;
|
|
673
|
-
case '
|
|
674
|
+
case '\x7D': /* closing brace, end of substruct; either repeat or move on */
|
|
674
675
|
{
|
|
675
676
|
size_t alignment = ctx->struct_alignment;
|
|
676
677
|
++ts;
|
Cython/Utility/Builtins.c
CHANGED
|
@@ -39,6 +39,7 @@ static PyObject* __Pyx_PyExec3(PyObject*, PyObject*, PyObject*);
|
|
|
39
39
|
static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject*, PyObject*);
|
|
40
40
|
|
|
41
41
|
//////////////////// PyExec ////////////////////
|
|
42
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType
|
|
42
43
|
|
|
43
44
|
static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject* o, PyObject* globals) {
|
|
44
45
|
return __Pyx_PyExec3(o, globals, NULL);
|
|
@@ -57,12 +58,8 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals)
|
|
|
57
58
|
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
58
59
|
// In Limited API we just use exec builtin which already has this
|
|
59
60
|
else if (unlikely(!PyDict_Check(globals))) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
PyErr_Format(PyExc_TypeError,
|
|
63
|
-
"exec() arg 2 must be a dict, not " __Pyx_FMT_TYPENAME,
|
|
64
|
-
globals_type_name);
|
|
65
|
-
__Pyx_DECREF_TypeName(globals_type_name);
|
|
61
|
+
__Pyx_RaiseTypeErrorWithObjectType(
|
|
62
|
+
"exec() arg 2 must be a dict, not " __Pyx_FMT_TYPENAME, globals);
|
|
66
63
|
goto bad;
|
|
67
64
|
}
|
|
68
65
|
#endif
|
|
@@ -97,11 +94,8 @@ static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals)
|
|
|
97
94
|
if (unlikely(!s)) goto bad;
|
|
98
95
|
o = s;
|
|
99
96
|
} else if (unlikely(!PyBytes_Check(o))) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"exec: arg 1 must be string, bytes or code object, got " __Pyx_FMT_TYPENAME,
|
|
103
|
-
o_type_name);
|
|
104
|
-
__Pyx_DECREF_TypeName(o_type_name);
|
|
97
|
+
__Pyx_RaiseTypeErrorWithObjectType(
|
|
98
|
+
"exec: arg 1 must be string, bytes or code object, got " __Pyx_FMT_TYPENAME, o);
|
|
105
99
|
goto bad;
|
|
106
100
|
}
|
|
107
101
|
code = PyBytes_AS_STRING(o);
|
|
@@ -285,7 +279,7 @@ static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) {
|
|
|
285
279
|
((PyLongObject*)copy)->long_value.lv_tag ^= ((PyLongObject*)copy)->long_value.lv_tag & _PyLong_SIGN_MASK;
|
|
286
280
|
#else
|
|
287
281
|
// negate the size to swap the sign
|
|
288
|
-
|
|
282
|
+
Py_SET_SIZE(copy, -Py_SIZE(copy));
|
|
289
283
|
#endif
|
|
290
284
|
}
|
|
291
285
|
return copy;
|
|
@@ -487,6 +481,7 @@ static double __Pyx_double_from_UCS4(Py_UCS4 uchar) {
|
|
|
487
481
|
static long __Pyx__PyObject_Ord(PyObject* c); /*proto*/
|
|
488
482
|
|
|
489
483
|
//////////////////// object_ord ////////////////////
|
|
484
|
+
//@requires: ObjectHandling.c::RaiseErrorWithObjectType
|
|
490
485
|
|
|
491
486
|
static long __Pyx__PyObject_Ord(PyObject* c) {
|
|
492
487
|
Py_ssize_t size;
|
|
@@ -520,11 +515,8 @@ static long __Pyx__PyObject_Ord(PyObject* c) {
|
|
|
520
515
|
#endif
|
|
521
516
|
} else {
|
|
522
517
|
// FIXME: support character buffers - but CPython doesn't support them either
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
"ord() expected string of length 1, but " __Pyx_FMT_TYPENAME " found",
|
|
526
|
-
c_type_name);
|
|
527
|
-
__Pyx_DECREF_TypeName(c_type_name);
|
|
518
|
+
__Pyx_RaiseTypeErrorWithObjectType(
|
|
519
|
+
"ord() expected string of length 1, but " __Pyx_FMT_TYPENAME " found", c);
|
|
528
520
|
return (long)(Py_UCS4)-1;
|
|
529
521
|
}
|
|
530
522
|
PyErr_Format(PyExc_TypeError,
|
|
@@ -543,6 +535,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) {
|
|
|
543
535
|
return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d);
|
|
544
536
|
}
|
|
545
537
|
|
|
538
|
+
//////////////////// py_frozendict_keys.proto ////////////////////
|
|
539
|
+
|
|
540
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_Keys(PyObject* d); /*proto*/
|
|
541
|
+
|
|
542
|
+
//////////////////// py_frozendict_keys ////////////////////
|
|
543
|
+
|
|
544
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_Keys(PyObject* d) {
|
|
545
|
+
return CALL_UNBOUND_METHOD_TYPEPTR(__Pyx_PyFrozenDict_TypePtr, "keys", d);
|
|
546
|
+
}
|
|
547
|
+
|
|
546
548
|
//////////////////// py_dict_values.proto ////////////////////
|
|
547
549
|
|
|
548
550
|
static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /*proto*/
|
|
@@ -553,6 +555,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
|
|
|
553
555
|
return CALL_UNBOUND_METHOD(PyDict_Type, "values", d);
|
|
554
556
|
}
|
|
555
557
|
|
|
558
|
+
//////////////////// py_frozendict_values.proto ////////////////////
|
|
559
|
+
|
|
560
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_Values(PyObject* d); /*proto*/
|
|
561
|
+
|
|
562
|
+
//////////////////// py_frozendict_values ////////////////////
|
|
563
|
+
|
|
564
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_Values(PyObject* d) {
|
|
565
|
+
return CALL_UNBOUND_METHOD_TYPEPTR(__Pyx_PyFrozenDict_TypePtr, "values", d);
|
|
566
|
+
}
|
|
567
|
+
|
|
556
568
|
//////////////////// py_dict_items.proto ////////////////////
|
|
557
569
|
|
|
558
570
|
static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /*proto*/
|
|
@@ -563,6 +575,16 @@ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
|
|
|
563
575
|
return CALL_UNBOUND_METHOD(PyDict_Type, "items", d);
|
|
564
576
|
}
|
|
565
577
|
|
|
578
|
+
//////////////////// py_frozendict_items.proto ////////////////////
|
|
579
|
+
|
|
580
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_Items(PyObject* d); /*proto*/
|
|
581
|
+
|
|
582
|
+
//////////////////// py_frozendict_items ////////////////////
|
|
583
|
+
|
|
584
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_Items(PyObject* d) {
|
|
585
|
+
return CALL_UNBOUND_METHOD_TYPEPTR(__Pyx_PyFrozenDict_TypePtr, "items", d);
|
|
586
|
+
}
|
|
587
|
+
|
|
566
588
|
//////////////////// py_dict_iterkeys.proto ////////////////////
|
|
567
589
|
|
|
568
590
|
static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d); /*proto*/
|
|
@@ -809,3 +831,103 @@ static {{out_type}} __Pyx_PyMemoryView_Get_{{name}}(PyObject *obj) {
|
|
|
809
831
|
#define __Pyx_PySlice_Stop(o) __Pyx_NewRef(((PySliceObject*)o)->stop)
|
|
810
832
|
#define __Pyx_PySlice_Step(o) __Pyx_NewRef(((PySliceObject*)o)->step)
|
|
811
833
|
#endif
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
////////////// PyFrozenDict.proto /////////////////////////
|
|
837
|
+
|
|
838
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
839
|
+
// PyFrozenDict is not currently in the Limited API.
|
|
840
|
+
|
|
841
|
+
#define __Pyx_PyFrozenDict_TypePtr ((PyTypeObject*) CGLOBAL(__Pyx_PyFrozenDictType))
|
|
842
|
+
|
|
843
|
+
#define __Pyx_PyFrozenDict_New(it) __Pyx__PyFrozenDict_New(CGLOBAL(__Pyx_PyFrozenDictType), it)
|
|
844
|
+
static CYTHON_INLINE PyObject* __Pyx__PyFrozenDict_New(PyObject* frozendict_type, PyObject* it); /*proto*/
|
|
845
|
+
|
|
846
|
+
#define __Pyx_PyFrozenDict_NewEmpty() __Pyx_PyFrozenDict_New(NULL)
|
|
847
|
+
#define __Pyx_PyFrozenDict_Check(obj) PyObject_TypeCheck((obj), __Pyx_PyFrozenDict_TypePtr)
|
|
848
|
+
#define __Pyx_PyFrozenDict_CheckExact(obj) Py_IS_TYPE((obj), __Pyx_PyFrozenDict_TypePtr)
|
|
849
|
+
|
|
850
|
+
#define __Pyx_PyAnyDict_Check(obj) __Pyx__PyAnyDict_Check(obj, __Pyx_PyFrozenDict_TypePtr)
|
|
851
|
+
static CYTHON_INLINE int __Pyx__PyAnyDict_Check(PyObject *obj, PyTypeObject* frozendict_type) {
|
|
852
|
+
return PyObject_TypeCheck(obj, &PyDict_Type) || PyObject_TypeCheck(obj, frozendict_type);
|
|
853
|
+
}
|
|
854
|
+
#define __Pyx_PyAnyDict_CheckExact(obj) __Pyx__PyAnyDict_CheckExact(obj, __Pyx_PyFrozenDict_TypePtr)
|
|
855
|
+
static CYTHON_INLINE int __Pyx__PyAnyDict_CheckExact(PyObject *obj, PyTypeObject* frozendict_type) {
|
|
856
|
+
return Py_IS_TYPE(obj, &PyDict_Type) || Py_IS_TYPE(obj, frozendict_type);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
#elif PY_VERSION_HEX >= 0x030f00a6 || \
|
|
860
|
+
(defined(PyFrozenDict_Check) && defined(PyAnyDict_Check) && defined(PyFrozenDict_New))
|
|
861
|
+
#define __Pyx_PyFrozenDict_TypePtr (&PyFrozenDict_Type)
|
|
862
|
+
#define __Pyx_PyFrozenDict_New(it) PyFrozenDict_New(it)
|
|
863
|
+
#define __Pyx_PyFrozenDict_NewEmpty() PyFrozenDict_New(NULL)
|
|
864
|
+
#define __Pyx_PyFrozenDict_Check(obj) PyFrozenDict_Check(obj)
|
|
865
|
+
#define __Pyx_PyFrozenDict_CheckExact(obj) PyFrozenDict_CheckExact(obj)
|
|
866
|
+
#define __Pyx_PyAnyDict_Check(obj) PyAnyDict_Check(obj)
|
|
867
|
+
#define __Pyx_PyAnyDict_CheckExact(obj) PyAnyDict_CheckExact(obj)
|
|
868
|
+
|
|
869
|
+
#else
|
|
870
|
+
// Replacing PyFrozenDict with PyDict for older Python versions seems reasonable and helpful.
|
|
871
|
+
#define __Pyx_PyFrozenDict_TypePtr (&PyDict_Type)
|
|
872
|
+
|
|
873
|
+
static CYTHON_INLINE PyObject* __Pyx_PyFrozenDict_New(PyObject* it) {
|
|
874
|
+
if (!it) {
|
|
875
|
+
return PyDict_New();
|
|
876
|
+
} else if (PyDict_Check(it)) {
|
|
877
|
+
return PyDict_Copy(it);
|
|
878
|
+
} else {
|
|
879
|
+
PyObject *dict = PyDict_New();
|
|
880
|
+
if (!dict) return NULL;
|
|
881
|
+
// PyDict_Merge() and friends do not handle arbitrary iterables. '|' does.
|
|
882
|
+
PyObject *result = PyNumber_InPlaceOr(dict, it);
|
|
883
|
+
Py_DECREF(dict);
|
|
884
|
+
return result;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
#define __Pyx_PyFrozenDict_NewEmpty() PyDict_New()
|
|
888
|
+
#define __Pyx_PyFrozenDict_Check(obj) PyDict_Check(obj)
|
|
889
|
+
#define __Pyx_PyFrozenDict_CheckExact(obj) PyDict_CheckExact(obj)
|
|
890
|
+
#define __Pyx_PyAnyDict_Check(obj) PyDict_Check(obj)
|
|
891
|
+
#define __Pyx_PyAnyDict_CheckExact(obj) PyDict_CheckExact(obj)
|
|
892
|
+
#endif
|
|
893
|
+
|
|
894
|
+
/////////////////// PyFrozenDict.module_state_decls //////////
|
|
895
|
+
|
|
896
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
897
|
+
PyObject *__Pyx_PyFrozenDictType;
|
|
898
|
+
#endif
|
|
899
|
+
|
|
900
|
+
////////////// PyFrozenDict /////////////////////////
|
|
901
|
+
|
|
902
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
903
|
+
static CYTHON_INLINE PyObject* __Pyx__PyFrozenDict_New(PyObject* frozendict_type, PyObject* it) {
|
|
904
|
+
return PyObject_CallFunctionObjArgs(frozendict_type, it, NULL);
|
|
905
|
+
}
|
|
906
|
+
#endif
|
|
907
|
+
|
|
908
|
+
////////////////// PyFrozenDict.init ////////////////
|
|
909
|
+
|
|
910
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
911
|
+
{
|
|
912
|
+
PyObject *builtins = PyEval_GetBuiltins(); // borrowed
|
|
913
|
+
if (likely(builtins)) {
|
|
914
|
+
PyObject *type_name = PyUnicode_FromStringAndSize("frozendict", sizeof("frozendict")-1);
|
|
915
|
+
if (likely(type_name)) {
|
|
916
|
+
PyObject *frozendict_type = PyObject_GetItem(builtins, type_name);
|
|
917
|
+
Py_DECREF(type_name);
|
|
918
|
+
if (!frozendict_type && PyErr_ExceptionMatches(PyExc_KeyError)) {
|
|
919
|
+
PyErr_Clear();
|
|
920
|
+
frozendict_type = (PyObject*) &PyDict_Type;
|
|
921
|
+
Py_INCREF(frozendict_type);
|
|
922
|
+
}
|
|
923
|
+
CGLOBAL(__Pyx_PyFrozenDictType) = frozendict_type;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
} // error handling follows
|
|
927
|
+
#endif
|
|
928
|
+
|
|
929
|
+
/////////////// PyFrozenDict.cleanup ////////////////
|
|
930
|
+
|
|
931
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
932
|
+
Py_CLEAR(CGLOBAL(__Pyx_PyFrozenDictType));
|
|
933
|
+
#endif
|
Cython/Utility/CConvert.pyx
CHANGED
|
@@ -14,13 +14,23 @@ cdef {{struct_type}} {{funcname}}(obj) except *:
|
|
|
14
14
|
if not PyMapping_Check(obj):
|
|
15
15
|
__Pyx_RaiseUnexpectedTypeError(b"a mapping", obj)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
lookup_failed = False
|
|
18
|
+
key = ''
|
|
18
19
|
try:
|
|
19
|
-
|
|
20
|
+
{{for member in var_entries:}}
|
|
21
|
+
key = '{{member.name}}'
|
|
22
|
+
value_{{member.name}} = obj[key]
|
|
23
|
+
{{endfor}}
|
|
20
24
|
except KeyError:
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
lookup_failed = True
|
|
26
|
+
|
|
27
|
+
if lookup_failed:
|
|
28
|
+
raise ValueError(f"No value specified for struct attribute {repr(key)}")
|
|
29
|
+
|
|
30
|
+
{{for member in var_entries:}}
|
|
31
|
+
result.{{member.name}} = value_{{member.name}}
|
|
23
32
|
{{endfor}}
|
|
33
|
+
|
|
24
34
|
return result
|
|
25
35
|
|
|
26
36
|
|
|
@@ -42,21 +52,26 @@ cdef {{struct_type}} {{funcname}}(obj) except *:
|
|
|
42
52
|
__Pyx_RaiseUnexpectedTypeError(b"a mapping", obj)
|
|
43
53
|
|
|
44
54
|
last_found = None
|
|
55
|
+
repeated_key = None
|
|
45
56
|
length = len(obj)
|
|
57
|
+
{{for member in var_entries:}}
|
|
46
58
|
if length:
|
|
47
|
-
{{for member in var_entries:}}
|
|
48
59
|
if '{{member.name}}' in obj:
|
|
49
60
|
if last_found is not None:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
repeated_key = '{{member.name}}'
|
|
62
|
+
length = 0
|
|
63
|
+
else:
|
|
64
|
+
result.{{member.cname}} = obj['{{member.name}}']
|
|
65
|
+
length -= 1
|
|
66
|
+
if not length:
|
|
67
|
+
return result
|
|
68
|
+
last_found = '{{member.name}}'
|
|
69
|
+
{{endfor}}
|
|
57
70
|
if last_found is None:
|
|
58
71
|
raise ValueError("No value specified for any of the union attributes (%s)" %
|
|
59
72
|
'{{", ".join(member.name for member in var_entries)}}')
|
|
73
|
+
else:
|
|
74
|
+
raise ValueError(f"More than one union attribute passed: {repr(last_found)} and {repr(repeated_key)}")
|
|
60
75
|
return result
|
|
61
76
|
|
|
62
77
|
|
|
@@ -9,34 +9,17 @@ static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
|
|
|
9
9
|
return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
///////////////
|
|
12
|
+
/////////////// VerifyCachedType.proto //////////////
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// Note - not a candidate for shared utility module.
|
|
15
|
+
// It's desirable that the check happens with the LIMITED_API/CACHED_OBJECTS
|
|
16
|
+
// settings of the current module.
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//@requires:StringTools.c::IncludeStringH
|
|
20
|
-
//@requires:Builtins.c::dict_setdefault
|
|
18
|
+
static int __Pyx_VerifyCachedType(PyObject *cached_type,
|
|
19
|
+
const char *name,
|
|
20
|
+
Py_ssize_t expected_basicsize); /* proto */
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
|
|
24
|
-
PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
|
|
25
|
-
if (result && metaclass) {
|
|
26
|
-
PyObject *old_tp = (PyObject*)Py_TYPE(result);
|
|
27
|
-
Py_INCREF((PyObject*)metaclass);
|
|
28
|
-
#if __PYX_LIMITED_VERSION_HEX >= 0x03090000
|
|
29
|
-
Py_SET_TYPE(result, metaclass);
|
|
30
|
-
#else
|
|
31
|
-
result->ob_type = metaclass;
|
|
32
|
-
#endif
|
|
33
|
-
Py_DECREF(old_tp);
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
#else
|
|
38
|
-
#define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
|
|
39
|
-
#endif
|
|
22
|
+
/////////////// VerifyCachedType ///////////////////
|
|
40
23
|
|
|
41
24
|
static int __Pyx_VerifyCachedType(PyObject *cached_type,
|
|
42
25
|
const char *name,
|
|
@@ -53,19 +36,29 @@ static int __Pyx_VerifyCachedType(PyObject *cached_type,
|
|
|
53
36
|
return 0; // size is inherited, nothing useful to check
|
|
54
37
|
}
|
|
55
38
|
|
|
56
|
-
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
basicsize = PyLong_AsSsize_t(py_basicsize);
|
|
61
|
-
Py_DECREF(py_basicsize);
|
|
62
|
-
py_basicsize = NULL;
|
|
63
|
-
if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
|
|
64
|
-
#else
|
|
65
|
-
basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
|
|
39
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_OPAQUE_OBJECTS
|
|
40
|
+
if (expected_basicsize < 0) {
|
|
41
|
+
basicsize = PyType_GetTypeDataSize((PyTypeObject*)cached_type);
|
|
42
|
+
} else
|
|
66
43
|
#endif
|
|
44
|
+
{
|
|
45
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
46
|
+
PyObject *py_basicsize;
|
|
47
|
+
py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
|
|
48
|
+
if (unlikely(!py_basicsize)) return -1;
|
|
49
|
+
basicsize = PyLong_AsSsize_t(py_basicsize);
|
|
50
|
+
Py_DECREF(py_basicsize);
|
|
51
|
+
py_basicsize = NULL;
|
|
52
|
+
if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
|
|
53
|
+
#else
|
|
54
|
+
basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
|
|
55
|
+
#endif
|
|
56
|
+
}
|
|
67
57
|
|
|
68
|
-
if (
|
|
58
|
+
if ((expected_basicsize >= 0) ?
|
|
59
|
+
(basicsize != expected_basicsize) :
|
|
60
|
+
// For types allocated with an opaque base, Python may overallocate
|
|
61
|
+
(basicsize < -expected_basicsize)) {
|
|
69
62
|
PyErr_Format(PyExc_TypeError,
|
|
70
63
|
"Shared Cython type %.200s has the wrong size, try recompiling",
|
|
71
64
|
name);
|
|
@@ -74,6 +67,32 @@ static int __Pyx_VerifyCachedType(PyObject *cached_type,
|
|
|
74
67
|
return 0;
|
|
75
68
|
}
|
|
76
69
|
|
|
70
|
+
/////////////// FetchCommonType.proto ///////////////
|
|
71
|
+
|
|
72
|
+
static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases);
|
|
73
|
+
|
|
74
|
+
/////////////// FetchCommonType ///////////////
|
|
75
|
+
//@requires: FetchSharedCythonModule
|
|
76
|
+
//@requires: VerifyCachedType
|
|
77
|
+
//@requires:StringTools.c::IncludeStringH
|
|
78
|
+
//@requires:Builtins.c::dict_setdefault
|
|
79
|
+
|
|
80
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
|
|
81
|
+
static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
|
|
82
|
+
PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
|
|
83
|
+
if (result && metaclass) {
|
|
84
|
+
PyObject *old_tp = (PyObject*)Py_TYPE(result);
|
|
85
|
+
Py_INCREF((PyObject*)metaclass);
|
|
86
|
+
Py_SET_TYPE(result, metaclass);
|
|
87
|
+
Py_DECREF(old_tp);
|
|
88
|
+
PyType_Modified((PyTypeObject*)result);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
#else
|
|
93
|
+
#define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
|
|
94
|
+
#endif
|
|
95
|
+
|
|
77
96
|
static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
|
|
78
97
|
PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name;
|
|
79
98
|
int get_item_ref_result;
|
|
@@ -110,7 +129,6 @@ static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyOb
|
|
|
110
129
|
CYTHON_USE_MODULE_STATE ? module : abi_module,
|
|
111
130
|
spec, bases);
|
|
112
131
|
if (unlikely(!cached_type)) goto bad;
|
|
113
|
-
if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
|
|
114
132
|
|
|
115
133
|
new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type);
|
|
116
134
|
if (unlikely(new_cached_type != cached_type)) {
|