Skip to content

Commit 01640c2

Browse files
Fix token_split() so its one error throws ValueError w/out extra arg.
In Python 3, raise has to throw a single object value without extra arguments. This commit also checked the function's callsites. One needed armoring, didn't have it, and got it. There didn't seem to be anything to do about the other than add a warning comment. All tests pass.
1 parent f7feda6 commit 01640c2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

roundup/admin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,10 @@ def interactive(self):
15551555
print _('exit...')
15561556
break
15571557
if not command: continue
1558-
args = token.token_split(command)
1558+
try:
1559+
args = token.token_split(command)
1560+
except ValueError:
1561+
continue # Ignore invalid quoted token
15591562
if not args: continue
15601563
if args[0] in ('quit', 'exit'): break
15611564
self.run_command(args)

roundup/cgi/actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ def fakeFilterVars(self):
402402
continue
403403
if isinstance(prop, hyperdb.String):
404404
v = self.form[key].value
405+
# If this ever has unbalanced quotes, hilarity will ensue
405406
l = token.token_split(v)
406407
if len(l) != 1 or l[0] != v:
407408
self.form.value.remove(self.form[key])

roundup/token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def token_split(s, whitespace=' \r\n\t', quotes='\'"',
5454
while 1:
5555
# end of string, finish off the current token
5656
if pos == length:
57-
if state == QUOTE: raise ValueError, "unmatched quote"
57+
if state == QUOTE: raise ValueError
5858
elif state == TOKEN: l.append(token)
5959
break
6060
c = s[pos]

0 commit comments

Comments
 (0)