| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,7 +67,7 @@ public virtual IntPtr type_subscript(IntPtr idx) | |||
| 67 | 67 | //==================================================================== | |
| 68 | 68 | // Standard comparison implementation for instances of reflected types. | |
| 69 | 69 | //==================================================================== | |
| 70 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | ||
| 70 | + | ||
| 71 | 71 | public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) { | |
| 72 | 72 | CLRObject co1; | |
| 73 | 73 | CLRObject co2; | |
@@ -169,27 +169,6 @@ public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) { | |||
| 169 | 169 | return Runtime.PyNotImplemented; | |
| 170 | 170 | } | |
| 171 | 171 | } | |
| 172 | - #else | ||
| 173 | - public static int tp_compare(IntPtr ob, IntPtr other) | ||
| 174 | - { | ||
| 175 | - if (ob == other) | ||
| 176 | - { | ||
| 177 | - return 0; | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - CLRObject co1 = GetManagedObject(ob) as CLRObject; | ||
| 181 | - CLRObject co2 = GetManagedObject(other) as CLRObject; | ||
| 182 | - Object o1 = co1.inst; | ||
| 183 | - Object o2 = co2.inst; | ||
| 184 | - | ||
| 185 | - if (Object.Equals(o1, o2)) | ||
| 186 | - { | ||
| 187 | - return 0; | ||
| 188 | - } | ||
| 189 | - return -1; | ||
| 190 | - } | ||
| 191 | - #endif | ||
| 192 | - | ||
| 193 | 172 | ||
| 194 | 173 | //==================================================================== | |
| 195 | 174 | // Standard iteration support for instances of reflected types. This | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -232,13 +232,13 @@ internal static void Initialize() | |||
| 232 | 232 | } | |
| 233 | 233 | ||
| 234 | 234 | #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | |
| 235 | - IntPtr op = Runtime.PyImport_ImportModule("builtins"); | ||
| 236 | - IntPtr dict = Runtime.PyObject_GetAttrString(op, "__dict__"); | ||
| 237 | - PyNotImplemented = Runtime.PyObject_GetAttrString(op, "NotImplemented"); | ||
| 235 | + IntPtr op = Runtime.PyImport_ImportModule("builtins"); | ||
| 236 | + IntPtr dict = Runtime.PyObject_GetAttrString(op, "__dict__"); | ||
| 238 | 237 | #else | |
| 239 | 238 | IntPtr dict = Runtime.PyImport_GetModuleDict(); | |
| 240 | 239 | IntPtr op = Runtime.PyDict_GetItemString(dict, "__builtin__"); | |
| 241 | 240 | #endif | |
| 241 | + PyNotImplemented = Runtime.PyObject_GetAttrString(op, "NotImplemented"); | ||
| 242 | 242 | PyBaseObjectType = Runtime.PyObject_GetAttrString(op, "object"); | |
| 243 | 243 | ||
| 244 | 244 | PyModuleType = Runtime.PyObject_Type(op); | |
@@ -255,8 +255,8 @@ internal static void Initialize() | |||
| 255 | 255 | Runtime.XDecref(op); | |
| 256 | 256 | ||
| 257 | 257 | #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | |
| 258 | - Runtime.XDecref(dict); | ||
| 259 | - Runtime.XDecref(op); | ||
| 258 | + Runtime.XDecref(dict); | ||
| 259 | + Runtime.XDecref(op); | ||
| 260 | 260 | #endif | |
| 261 | 261 | ||
| 262 | 262 | op = Runtime.PyString_FromString("string"); | |
@@ -268,9 +268,9 @@ internal static void Initialize() | |||
| 268 | 268 | Runtime.XDecref(op); | |
| 269 | 269 | ||
| 270 | 270 | #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | |
| 271 | - op = Runtime.PyBytes_FromString("bytes"); | ||
| 272 | - PyBytesType = Runtime.PyObject_Type(op); | ||
| 273 | - Runtime.XDecref(op); | ||
| 271 | + op = Runtime.PyBytes_FromString("bytes"); | ||
| 272 | + PyBytesType = Runtime.PyObject_Type(op); | ||
| 273 | + Runtime.XDecref(op); | ||
| 274 | 274 | #endif | |
| 275 | 275 | ||
| 276 | 276 | op = Runtime.PyTuple_New(0); | |
@@ -389,17 +389,18 @@ internal static int AtExit() | |||
| 389 | 389 | internal static IntPtr PyTypeType; | |
| 390 | 390 | ||
| 391 | 391 | #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | |
| 392 | - internal static IntPtr PyBytesType; | ||
| 393 | - internal static IntPtr PyNotImplemented; | ||
| 394 | - internal const int Py_LT = 0; | ||
| 395 | - internal const int Py_LE = 1; | ||
| 396 | - internal const int Py_EQ = 2; | ||
| 397 | - internal const int Py_NE = 3; | ||
| 398 | - internal const int Py_GT = 4; | ||
| 399 | - internal const int Py_GE = 5; | ||
| 400 | - internal static IntPtr _PyObject_NextNotImplemented; | ||
| 392 | + internal static IntPtr PyBytesType; | ||
| 393 | + internal static IntPtr _PyObject_NextNotImplemented; | ||
| 401 | 394 | #endif | |
| 402 | 395 | ||
| 396 | + internal static IntPtr PyNotImplemented; | ||
| 397 | + internal const int Py_LT = 0; | ||
| 398 | + internal const int Py_LE = 1; | ||
| 399 | + internal const int Py_EQ = 2; | ||
| 400 | + internal const int Py_NE = 3; | ||
| 401 | + internal const int Py_GT = 4; | ||
| 402 | + internal const int Py_GE = 5; | ||
| 403 | + | ||
| 403 | 404 | internal static IntPtr PyTrue; | |
| 404 | 405 | internal static IntPtr PyFalse; | |
| 405 | 406 | internal static IntPtr PyNone; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -210,39 +210,34 @@ def testComparisons(self): | |||
| 210 | 210 | self.assertEqual(d1 == d2, False) | |
| 211 | 211 | self.assertEqual(d1 != d2, True) | |
| 212 | 212 | ||
| 213 | - if six.PY3: | ||
| 214 | - self.assertEqual(d1 < d2, True) | ||
| 215 | - self.assertEqual(d1 <= d2, True) | ||
| 216 | - self.assertEqual(d1 >= d2, False) | ||
| 217 | - self.assertEqual(d1 > d2, False) | ||
| 213 | + self.assertEqual(d1 < d2, True) | ||
| 214 | + self.assertEqual(d1 <= d2, True) | ||
| 215 | + self.assertEqual(d1 >= d2, False) | ||
| 216 | + self.assertEqual(d1 > d2, False) | ||
| 218 | 217 | ||
| 219 | 218 | self.assertEqual(d1 == d1, True) | |
| 220 | 219 | self.assertEqual(d1 != d1, False) | |
| 221 | 220 | ||
| 222 | - if six.PY3: | ||
| 223 | - self.assertEqual(d1 < d1, False) | ||
| 224 | - self.assertEqual(d1 <= d1, True) | ||
| 225 | - self.assertEqual(d1 >= d1, True) | ||
| 226 | - self.assertEqual(d1 > d1, False) | ||
| 221 | + self.assertEqual(d1 < d1, False) | ||
| 222 | + self.assertEqual(d1 <= d1, True) | ||
| 223 | + self.assertEqual(d1 >= d1, True) | ||
| 224 | + self.assertEqual(d1 > d1, False) | ||
| 227 | 225 | ||
| 228 | 226 | self.assertEqual(d2 == d1, False) | |
| 229 | 227 | self.assertEqual(d2 != d1, True) | |
| 230 | 228 | ||
| 231 | - if six.PY3: | ||
| 232 | - self.assertEqual(d2 < d1, False) | ||
| 233 | - self.assertEqual(d2 <= d1, False) | ||
| 234 | - self.assertEqual(d2 >= d1, True) | ||
| 235 | - self.assertEqual(d2 > d1, True) | ||
| 236 | - | ||
| 237 | - if six.PY3: | ||
| 238 | - self.assertRaises(TypeError, lambda: d1 < None) | ||
| 239 | - self.assertRaises(TypeError, lambda: d1 < System.Guid()) | ||
| 240 | - | ||
| 241 | - if six.PY3: | ||
| 242 | - # ClassTest does not implement IComparable | ||
| 243 | - c1 = ClassTest() | ||
| 244 | - c2 = ClassTest() | ||
| 245 | - self.assertRaises(TypeError, lambda: c1 < c2) | ||
| 229 | + self.assertEqual(d2 < d1, False) | ||
| 230 | + self.assertEqual(d2 <= d1, False) | ||
| 231 | + self.assertEqual(d2 >= d1, True) | ||
| 232 | + self.assertEqual(d2 > d1, True) | ||
| 233 | + | ||
| 234 | + self.assertRaises(TypeError, lambda: d1 < None) | ||
| 235 | + self.assertRaises(TypeError, lambda: d1 < System.Guid()) | ||
| 236 | + | ||
| 237 | + # ClassTest does not implement IComparable | ||
| 238 | + c1 = ClassTest() | ||
| 239 | + c2 = ClassTest() | ||
| 240 | + self.assertRaises(TypeError, lambda: c1 < c2) | ||
| 246 | 241 | ||
| 247 | 242 | ||
| 248 | 243 | class ClassicClass: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments