| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -710,7 +710,7 @@ internal static bool ToPrimitive(BorrowedReference value, Type obType, out objec | |||
| 710 | 710 | { | |
| 711 | 711 | if (Runtime.Is32Bit) | |
| 712 | 712 | { | |
| 713 | - if (!Runtime.PyLong_Check(value)) | ||
| 713 | + if (!Runtime.PyInt_Check(value)) | ||
| 714 | 714 | { | |
| 715 | 715 | goto type_error; | |
| 716 | 716 | } | |
@@ -777,6 +777,10 @@ internal static bool ToPrimitive(BorrowedReference value, Type obType, out objec | |||
| 777 | 777 | ||
| 778 | 778 | case TypeCode.Single: | |
| 779 | 779 | { | |
| 780 | + if (!Runtime.PyFloat_Check(value) && !Runtime.PyInt_Check(value)) | ||
| 781 | + { | ||
| 782 | + goto type_error; | ||
| 783 | + } | ||
| 780 | 784 | double num = Runtime.PyFloat_AsDouble(value); | |
| 781 | 785 | if (Exceptions.ErrorOccurred()) | |
| 782 | 786 | { | |
@@ -795,6 +799,10 @@ internal static bool ToPrimitive(BorrowedReference value, Type obType, out objec | |||
| 795 | 799 | ||
| 796 | 800 | case TypeCode.Double: | |
| 797 | 801 | { | |
| 802 | + if (!Runtime.PyFloat_Check(value) && !Runtime.PyInt_Check(value)) | ||
| 803 | + { | ||
| 804 | + goto type_error; | ||
| 805 | + } | ||
| 798 | 806 | double num = Runtime.PyFloat_AsDouble(value); | |
| 799 | 807 | if (Exceptions.ErrorOccurred()) | |
| 800 | 808 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1101,11 +1101,6 @@ internal static bool PyBool_Check(BorrowedReference ob) | |||
| 1101 | 1101 | ||
| 1102 | 1102 | internal static NewReference PyInt_FromInt64(long value) => PyLong_FromLongLong(value); | |
| 1103 | 1103 | ||
| 1104 | - internal static bool PyLong_Check(BorrowedReference ob) | ||
| 1105 | - { | ||
| 1106 | - return PyObject_TYPE(ob) == PyLongType; | ||
| 1107 | - } | ||
| 1108 | - | ||
| 1109 | 1104 | internal static NewReference PyLong_FromLongLong(long value) => Delegates.PyLong_FromLongLong(value); | |
| 1110 | 1105 | ||
| 1111 | 1106 | ||
@@ -1145,9 +1140,7 @@ internal static NewReference PyLong_FromString(string value, int radix) | |||
| 1145 | 1140 | } | |
| 1146 | 1141 | ||
| 1147 | 1142 | internal static bool PyFloat_Check(BorrowedReference ob) | |
| 1148 | - { | ||
| 1149 | - return PyObject_TYPE(ob) == PyFloatType; | ||
| 1150 | - } | ||
| 1143 | + => PyObject_TypeCheck(ob, PyFloatType); | ||
| 1151 | 1144 | ||
| 1152 | 1145 | /// <summary> | |
| 1153 | 1146 | /// Return value: New reference. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments