Skip to content

Commit

Permalink
Reorder zoneinfo processing to ensure all transitions are handled.
Browse files Browse the repository at this point in the history
This reorders the transition index lookup to ensure that all timestamps
are referenced, or an error is thrown, rather than silently erroring at
some later point.

Refs #11093
  • Loading branch information
wagnerrp committed Sep 17, 2012
1 parent 657b888 commit a403c19
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mythtv/bindings/python/MythTV/utility/dt.py
Expand Up @@ -121,16 +121,22 @@ def _process(self, fd, version=1, skip=False):
# read in transition type indexes
types = [None]*counts.transitions
for i in range(counts.transitions):
types[i] = unpack('!b', fd.read(1))[0]
types[i] = t = unpack('!b', fd.read(1))[0]
if t >= counts.types:
raise RuntimeError(("Transition has out-of-bounds definition "
"index (given: {0}, max: {0}")\
.format(t,counts.types-1))

# read in type definitions
typedefs = []
for i in range(counts.types):
offset, isdst, _ = unpack('!lbB', fd.read(6))
for j in range(counts.transitions):
if types[j] == i:
transitions[j][2] = time.gmtime(transitions[j][0]+offset)
transitions[j][3] = offset
transitions[j][5] = isdst
typedefs.append([offset, isdst])
for i in range(counts.transitions):
offset,isdst = typedefs[types[i]]
transitions[i][2] = time.gmtime(transitions[i][0] + offset)
transitions[i][3] = offset
transitions[i][5] = isdst

# read in type names
for i, name in enumerate(fd.read(counts.abbrevs)[:-1].split('\0')):
Expand Down

0 comments on commit a403c19

Please sign in to comment.