Mercurial > hg
changeset 15157:c208dcd0f709 stable
util: fix crash converting an invalid future date to string
Post-2038 timestamps cannot be handled on 32-bit architectures. Clamp
such dates to the maximum 32-bit timestamp.
author | Kevin Gessner <kevin@fogcreek.com> |
---|---|
date | Fri, 23 Sep 2011 09:02:27 -0700 |
parents | 94b200a11cf7 |
children | 7ce7177e029a |
files | mercurial/util.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Wed Sep 21 22:52:00 2011 +0200 +++ b/mercurial/util.py Fri Sep 23 09:02:27 2011 -0700 @@ -891,7 +891,12 @@ minutes = abs(tz) // 60 format = format.replace("%1", "%c%02d" % (sign, minutes // 60)) format = format.replace("%2", "%02d" % (minutes % 60)) - s = time.strftime(format, time.gmtime(float(t) - tz)) + try: + t = time.gmtime(float(t) - tz) + except ValueError: + # time was out of range + t = time.gmtime(sys.maxint) + s = time.strftime(format, t) return s def shortdate(date=None):