Merge lp:~jelmer/brz/time-t-max into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7124
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/time-t-max
Merge into: lp:brz
Diff against target: 18 lines (+8/-0)
1 file modified
breezy/tests/test_timestamp.py (+8/-0)
To merge this branch: bzr merge lp:~jelmer/brz/time-t-max
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+355509@code.launchpad.net

Description of the change

Guard against time_t overflowing in test_timestamp.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Hm, this test isn't great but sure, the change to limit its stupidity seems fine.

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/tests/test_timestamp.py'
2--- breezy/tests/test_timestamp.py 2017-06-04 18:09:30 +0000
3+++ breezy/tests/test_timestamp.py 2018-09-21 19:45:50 +0000
4@@ -125,6 +125,14 @@
5 o = -12*3600
6 for count in range(500):
7 t += random.random()*24*3600*30
8+ try:
9+ time.gmtime(t)
10+ except OverflowError:
11+ # We've reached the maximum for time_t on this platform
12+ break
13+ if time.localtime(t).tm_year > 9998:
14+ # strptime doesn't always understand years with more than 4 digits.
15+ break
16 o = ((o/3600 + 13) % 25 - 12)*3600 # Add 1 wrap around from [-12, 12]
17 date = timestamp.format_highres_date(t, o)
18 t2, o2 = timestamp.unpack_highres_date(date)

Subscribers

People subscribed via source and target branches