From e425545c10cb146674ecf38ceab2e020a9cb8374 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 8 Mar 2015 02:32:33 +0100 Subject: [PATCH] datetime does not like the year 10.000, fixes issue #139 --- attic/archiver.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/attic/archiver.py b/attic/archiver.py index 47650c2d4..40d032155 100644 --- a/attic/archiver.py +++ b/attic/archiver.py @@ -281,7 +281,11 @@ Type "Yes I am sure" if you understand this and want to continue.\n""") size = sum(size for _, size, _ in item[b'chunks']) except KeyError: pass - mtime = format_time(datetime.fromtimestamp(bigint_to_int(item[b'mtime']) / 1e9)) + try: + mtime = datetime.fromtimestamp(bigint_to_int(item[b'mtime']) / 1e9) + except ValueError: + # likely a broken mtime and datetime did not want to go beyond year 9999 + mtime = datetime(9999, 12, 31, 23, 59, 59) if b'source' in item: if type == 'l': extra = ' -> %s' % item[b'source'] @@ -291,7 +295,7 @@ Type "Yes I am sure" if you understand this and want to continue.\n""") else: extra = '' print('%s%s %-6s %-6s %8d %s %s%s' % (type, mode, item[b'user'] or item[b'uid'], - item[b'group'] or item[b'gid'], size, mtime, + item[b'group'] or item[b'gid'], size, format_time(mtime), remove_surrogates(item[b'path']), extra)) else: for archive in sorted(Archive.list_archives(repository, key, manifest), key=attrgetter('ts')):