[pypy-commit] pypy default: fix datetime error messages properly

bdkearns noreply at buildbot.pypy.org
Mon Sep 22 18:23:57 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r73648:302f635e170f
Date: 2014-09-22 12:23 -0400
http://bitbucket.org/pypy/pypy/changeset/302f635e170f/

Log:	fix datetime error messages properly

diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -1242,7 +1242,7 @@
                         (other._hour, other._minute, other._second,
                          other._microsecond))
         if myoff is None or otoff is None:
-            raise TypeError("can't compare offset-naive and offset-aware datetimes")
+            raise TypeError("can't compare offset-naive and offset-aware times")
         myhhmm = self._hour * 60 + self._minute - myoff
         othhmm = other._hour * 60 + other._minute - otoff
         return _cmp((myhhmm, self._second, self._microsecond),
@@ -1885,7 +1885,7 @@
         if myoff == otoff:
             return base
         if myoff is None or otoff is None:
-            raise TypeError("can't compare offset-naive and offset-aware datetimes")
+            raise TypeError("can't subtract offset-naive and offset-aware datetimes")
         return base + timedelta(minutes = otoff-myoff)
 
     def __hash__(self):
diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py
--- a/pypy/module/test_lib_pypy/test_datetime.py
+++ b/pypy/module/test_lib_pypy/test_datetime.py
@@ -203,9 +203,9 @@
     assert str(e.value) == "can't compare offset-naive and offset-aware datetimes"
     with py.test.raises(TypeError) as e:
         naive - aware
-    assert str(e.value) == "can't compare offset-naive and offset-aware datetimes"
+    assert str(e.value) == "can't subtract offset-naive and offset-aware datetimes"
     naive = datetime.time(7, 32, 12)
     aware = datetime.time(7, 32, 12, tzinfo=Foo())
     with py.test.raises(TypeError) as e:
         naive == aware
-    assert str(e.value) == "can't compare offset-naive and offset-aware datetimes"
+    assert str(e.value) == "can't compare offset-naive and offset-aware times"


More information about the pypy-commit mailing list