[pypy-commit] pypy default: cleanup
bdkearns
noreply at buildbot.pypy.org
Tue Nov 24 19:23:12 EST 2015
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r80922:3aa83b0f7f8c
Date: 2015-11-24 19:23 -0500
http://bitbucket.org/pypy/pypy/changeset/3aa83b0f7f8c/
Log: cleanup
diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -429,6 +429,10 @@
self.hour, self.minute, self.second = hour, minute, second
self.microsecond = microsecond
+ def _check_error(self):
+ if not MINYEAR <= self.year <= MAXYEAR:
+ raise OverflowError("date value out of range")
+
def _accum(tag, sofar, num, factor, leftover):
if isinstance(num, (int, long)):
prod = num * factor
@@ -925,20 +929,14 @@
# Computations
- def _checkOverflow(self, year):
- if not MINYEAR <= year <= MAXYEAR:
- raise OverflowError("date +/-: result year %d not in %d..%d" %
- (year, MINYEAR, MAXYEAR))
-
def __add__(self, other):
"Add a date to a timedelta."
if isinstance(other, timedelta):
t = _tmxxx(self._year,
- self._month,
- self._day + other.days)
- self._checkOverflow(t.year)
- result = date(t.year, t.month, t.day)
- return result
+ self._month,
+ self._day + other.days)
+ t._check_error()
+ return date(t.year, t.month, t.day)
return NotImplemented
__radd__ = __add__
@@ -1825,7 +1823,7 @@
self._minute,
self._second + other.seconds * factor,
self._microsecond + other.microseconds * factor)
- self._checkOverflow(t.year)
+ t._check_error()
return datetime(t.year, t.month, t.day,
t.hour, t.minute, t.second,
t.microsecond, tzinfo=self._tzinfo)
More information about the pypy-commit
mailing list