Skip to content

Commit dda1c60

Browse files
committed
issue2551107 - Handle long int in history params
Early versions of roundup represented the id in a params tuple of the journal/history using a Long int. The repr 2345L is not valid under python3. So eval()'ing the params tuple throws a SyntaxError. Trap the error, modify the parms string stripping the L and re-eval.
1 parent 0545bc4 commit dda1c60

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ Fixed:
4141
- REST replace hard coded list of child endpoints for /rest/ with list
4242
pulled from registered endpoints. So newly added endpoints are
4343
shown. (John Rouillard)
44+
- issue2551107 - Handle representation of long int in history params
45+
for python3. Causes SyntaxError crash when showing history due to
46+
long int e.g. 2345L. This is not a problem for roundup trackers
47+
created using 1.2.0 or newer. The fix may have predated the 1.2.0
48+
release but where the fix actually landed (representing id as a
49+
string and not as an int) is unknown.
4450

4551
Features:
4652

roundup/anypy/strings.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,15 @@ def repr_export(v):
142142
def eval_import(s):
143143
"""Evaluate a Python-2-style value imported from a CSV file."""
144144
if _py3:
145-
v = eval(s)
145+
try:
146+
v = eval(s)
147+
except SyntaxError:
148+
# handle case where link operation reports id a long int
149+
# ('issue', 5002L, "status") rather than as a string.
150+
# This was a bug that existed and was fixed before or with v1.2.0
151+
import re
152+
v = eval(re.sub(r', ([0-9]+)L,',r', \1,', s))
153+
146154
if isinstance(v, str):
147155
return v.encode('iso-8859-1').decode('utf-8')
148156
elif isinstance(v, dict):

0 commit comments

Comments
 (0)