@@ -420,20 +420,20 @@ PyArray_CanCastSafely(int fromtype, int totype)
420
420
#if NPY_USE_NEW_CASTINGIMPL
421
421
PyArray_DTypeMeta * from = PyArray_DTypeFromTypeNum (fromtype );
422
422
if (from == NULL ) {
423
- PyErr_WriteUnraisable (Py_None );
423
+ PyErr_WriteUnraisable (NULL );
424
424
return 0 ;
425
425
}
426
426
PyArray_DTypeMeta * to = PyArray_DTypeFromTypeNum (totype );
427
427
if (to == NULL ) {
428
- PyErr_WriteUnraisable (Py_None );
428
+ PyErr_WriteUnraisable (NULL );
429
429
return 0 ;
430
430
}
431
431
PyObject * castingimpl = PyArray_GetCastingImpl (from , to );
432
432
Py_DECREF (from );
433
433
Py_DECREF (to );
434
434
435
435
if (castingimpl == NULL ) {
436
- PyErr_WriteUnraisable (Py_None );
436
+ PyErr_WriteUnraisable (NULL );
437
437
return 0 ;
438
438
}
439
439
else if (castingimpl == Py_None ) {
@@ -2489,9 +2489,9 @@ structured_to_nonstructured_resolve_descriptors(
2489
2489
if (given_descrs [1 ] == NULL ) {
2490
2490
loop_descrs [1 ] = dtypes [1 ]-> default_descr (dtypes [1 ]);
2491
2491
/*
2492
- * Special case strings here, this is probably unnecessary and
2493
- * should be useless (i.e. it is necessary to use empty arrays to
2494
- * trigger this path.) .
2492
+ * Special case strings here, it should be useless ( and only actually
2493
+ * work for empty arrays). Possibly this should simply raise for
2494
+ * all parametric DTypes .
2495
2495
*/
2496
2496
if (dtypes [1 ]-> type_num == NPY_STRING ) {
2497
2497
loop_descrs [1 ]-> elsize = given_descrs [0 ]-> elsize ;
@@ -2744,7 +2744,7 @@ object_to_any_resolve_descriptors(
2744
2744
* here is that e.g. "M8" input is considered to be the DType class,
2745
2745
* and by allowing it here, we go back to the "M8" instance.
2746
2746
*/
2747
- if (dtypes [1 ]-> parametric && ! dtypes [ 1 ] -> legacy ) {
2747
+ if (dtypes [1 ]-> parametric ) {
2748
2748
PyErr_Format (PyExc_TypeError ,
2749
2749
"casting from object to the parametric DType %S requires "
2750
2750
"the specified output dtype instance. "
@@ -2756,11 +2756,6 @@ object_to_any_resolve_descriptors(
2756
2756
if (loop_descrs [1 ] == NULL ) {
2757
2757
return -1 ;
2758
2758
}
2759
- if (dtypes [1 ]-> type_num == NPY_VOID ) {
2760
- /* NOTE: This appears to be behaviour as of 1.19 (void is not
2761
- * adjusted) */
2762
- loop_descrs [1 ]-> elsize = sizeof (PyObject * );
2763
- }
2764
2759
}
2765
2760
else {
2766
2761
Py_INCREF (given_descrs [1 ]);
@@ -2791,6 +2786,8 @@ PyArray_GetObjectToGenericCastingImpl()
2791
2786
return PyErr_NoMemory ();
2792
2787
}
2793
2788
2789
+ method -> nin = 1 ;
2790
+ method -> nout = 1 ;
2794
2791
method -> name = "object_to_any_cast" ;
2795
2792
method -> flags = NPY_METH_SUPPORTS_UNALIGNED | NPY_METH_REQUIRES_PYAPI ;
2796
2793
method -> casting = NPY_UNSAFE_CASTING ;
@@ -2845,6 +2842,8 @@ PyArray_GetGenericToObjectCastingImpl()
2845
2842
return PyErr_NoMemory ();
2846
2843
}
2847
2844
2845
+ method -> nin = 1 ;
2846
+ method -> nout = 1 ;
2848
2847
method -> name = "any_to_object_cast" ;
2849
2848
method -> flags = NPY_METH_SUPPORTS_UNALIGNED | NPY_METH_REQUIRES_PYAPI ;
2850
2849
method -> casting = NPY_SAFE_CASTING ;
0 commit comments