@@ -361,28 +361,44 @@ internal static bool ToManagedValue(BorrowedReference value, Type obType,
361
361
// conversions (Python string -> managed string).
362
362
if ( obType == objectType )
363
363
{
364
- if ( Runtime . PyString_Check ( value ) )
364
+ if ( Runtime . PyString_CheckExact ( value ) )
365
365
{
366
366
return ToPrimitive ( value , stringType , out result , setError ) ;
367
367
}
368
368
369
- if ( Runtime . PyBool_Check ( value ) )
369
+ if ( Runtime . PyBool_CheckExact ( value ) )
370
370
{
371
371
return ToPrimitive ( value , boolType , out result , setError ) ;
372
372
}
373
373
374
- if ( Runtime . PyFloat_Check ( value ) )
374
+ if ( Runtime . PyFloat_CheckExact ( value ) )
375
375
{
376
376
return ToPrimitive ( value , doubleType , out result , setError ) ;
377
377
}
378
378
379
- // give custom codecs a chance to take over conversion of ints and sequences
379
+ // give custom codecs a chance to take over conversion
380
+ // of ints, sequences, and types derived from primitives
380
381
BorrowedReference pyType = Runtime . PyObject_TYPE ( value ) ;
381
382
if ( PyObjectConversions . TryDecode ( value , pyType , obType , out result ) )
382
383
{
383
384
return true ;
384
385
}
385
386
387
+ if ( Runtime . PyString_Check ( value ) )
388
+ {
389
+ return ToPrimitive ( value , stringType , out result , setError ) ;
390
+ }
391
+
392
+ if ( Runtime . PyBool_Check ( value ) )
393
+ {
394
+ return ToPrimitive ( value , boolType , out result , setError ) ;
395
+ }
396
+
397
+ if ( Runtime . PyFloat_Check ( value ) )
398
+ {
399
+ return ToPrimitive ( value , doubleType , out result , setError ) ;
400
+ }
401
+
386
402
if ( Runtime . PyInt_Check ( value ) )
387
403
{
388
404
result = new PyInt ( value ) ;
0 commit comments