From 28b34f64095d19fbc537e9ff7aef57c1bbadf83e Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Sat, 30 Jan 2016 10:22:10 -0500 Subject: [PATCH] BUG: Handle OverflowError by comparing False instead of raising --- tests/test_assets.py | 2 ++ zipline/assets/_assets.pyx | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_assets.py b/tests/test_assets.py index a9bbcf72..0a90664e 100644 --- a/tests/test_assets.py +++ b/tests/test_assets.py @@ -232,6 +232,8 @@ class AssetTestCase(TestCase): self.assertNotEqual(s_23, 23.5) self.assertNotEqual(s_23, []) self.assertNotEqual(s_23, None) + # Compare to a value that doesn't fit into a platform int: + self.assertNotEqual(s_23, sys.maxsize + 1) self.assertLess(s_23, s_24) self.assertLess(s_23, 24) diff --git a/zipline/assets/_assets.pyx b/zipline/assets/_assets.pyx index 608b5252..371253f8 100644 --- a/zipline/assets/_assets.pyx +++ b/zipline/assets/_assets.pyx @@ -92,12 +92,12 @@ cdef class Asset: try: x_as_int = PyNumber_Index(x) - except TypeError: + except (TypeError, OverflowError): return NotImplemented try: y_as_int = PyNumber_Index(y) - except TypeError: + except (TypeError, OverflowError): return NotImplemented compared = x_as_int - y_as_int