comparison roundup/anypy/strings.py @ 6531:82f870433b18

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.
author John Rouillard <rouilj@ieee.org>
date Sun, 14 Nov 2021 22:22:18 -0500
parents 81990ac0b013
children 8e118eb20d86
comparison
equal deleted inserted replaced
6530:6bf22b7b23fe 6531:82f870433b18
140 140
141 141
142 def eval_import(s): 142 def eval_import(s):
143 """Evaluate a Python-2-style value imported from a CSV file.""" 143 """Evaluate a Python-2-style value imported from a CSV file."""
144 if _py3: 144 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
146 if isinstance(v, str): 154 if isinstance(v, str):
147 return v.encode('iso-8859-1').decode('utf-8') 155 return v.encode('iso-8859-1').decode('utf-8')
148 elif isinstance(v, dict): 156 elif isinstance(v, dict):
149 v_mod = {} 157 v_mod = {}
150 for key, value in v.items(): 158 for key, value in v.items():

Roundup Issue Tracker: http://roundup-tracker.org/