From cddb22636f7d1969aa3356ffcfb2c0e2adf84a37 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 21 Aug 2011 23:44:36 -0400 Subject: [PATCH] wikitools fix in User when said user is really old and the API doesn't give a registration date --- bot/wiki/user.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bot/wiki/user.py b/bot/wiki/user.py index b1cca38..da14255 100644 --- a/bot/wiki/user.py +++ b/bot/wiki/user.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from time import strptime +from time import gmtime, strptime from wiki.constants import * from wiki.exceptions import UserNotFoundError @@ -101,7 +101,12 @@ class User(object): self._editcount = res["editcount"] reg = res["registration"] - self._registration = strptime(reg, "%Y-%m-%dT%H:%M:%SZ") + try: + self._registration = strptime(reg, "%Y-%m-%dT%H:%M:%SZ") + except TypeError: + # Sometimes the API doesn't give a date; the user's probably really + # old. There's nothing else we can do! + self._registration = gmtime(0) try: res["emailable"]