Show More
@@ -14,13 +14,9 b' def parsestring(s, quoted=True):' | |||
|
14 | 14 | '''parse a string using simple c-like syntax. |
|
15 | 15 | string must be in quotes if quoted is True.''' |
|
16 | 16 | if quoted: |
|
17 | first = s[0] | |
|
18 |
|
|
|
19 | if first not in "'\"": raise SyntaxError(_('invalid quote')) | |
|
20 | if s[-1] != first: raise SyntaxError(_('unmatched quotes')) | |
|
21 | s = s[1:-1].decode('string_escape') | |
|
22 | if first in s: raise SyntaxError(_('string ends early')) | |
|
23 | return s | |
|
17 | if len(s) < 2 or s[0] != s[-1]: | |
|
18 | raise SyntaxError(_('unmatched quotes')) | |
|
19 | return s[1:-1].decode('string_escape') | |
|
24 | 20 | |
|
25 | 21 | return s.decode('string_escape') |
|
26 | 22 |
General Comments 0
You need to be logged in to leave comments.
Login now