Skip to content

Commit

Permalink
split_tokens(): old string formatting when raising ValueError to be c…
Browse files Browse the repository at this point in the history
…ompatible with older Python versions
  • Loading branch information
stroeder committed Feb 22, 2017
1 parent adb6b47 commit 5f769f7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Lib/ldap/schema/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
\$Id: tokenizer.py,v 1.15 2017/02/20 10:25:47 stroeder Exp $
\$Id: tokenizer.py,v 1.16 2017/02/22 20:25:21 stroeder Exp $
"""

import re
Expand All @@ -24,8 +24,7 @@

def split_tokens(s):
"""
Returns list of syntax elements with quotes and spaces
stripped.
Returns list of syntax elements with quotes and spaces stripped.
"""
parts = []
parens = 0
Expand All @@ -42,14 +41,13 @@ def split_tokens(s):
parts.append(cpar)
elif residue == '$':
if not parens:
raise ValueError("'$' outside parenthesis")
raise ValueError("'$' outside parenthesis in %r" % (s))
else:
raise ValueError(residue, s)
if parens:
raise ValueError('Unbalanced parenthesis in %r' % s)
raise ValueError("Unbalanced parenthesis in %r" % (s))
return parts


def extract_tokens(l,known_tokens):
"""
Returns dictionary of known tokens with all values
Expand Down

0 comments on commit 5f769f7

Please sign in to comment.