@@ -1788,8 +1788,8 @@ cdef _quote_data(data, charset='utf8'):
1788
1788
1789
1789
raise ValueError (' expected a simple type, a tuple or a dictionary.' )
1790
1790
1791
- _re_pos_param = re.compile(r ' ( %( [sd ])) ' )
1792
- _re_name_param = re.compile(r ' ( %\( ( [^ \) ]+ ) \) (?: [sd ]) ) ' )
1791
+ _re_pos_param = re.compile(br ' (%([sd]))' )
1792
+ _re_name_param = re.compile(br ' (%\(([^\)]+)\)(?:[sd]))' )
1793
1793
cdef _substitute_params(toformat, params, charset):
1794
1794
if params is None :
1795
1795
return toformat
@@ -1814,8 +1814,8 @@ cdef _substitute_params(toformat, params, charset):
1814
1814
if isinstance (params, dict ):
1815
1815
""" assume name based substitutions """
1816
1816
offset = 0
1817
- for match in _re_name_param.finditer(toformat.decode(charset) ):
1818
- param_key = match.group(2 )
1817
+ for match in _re_name_param.finditer(toformat):
1818
+ param_key = match.group(2 ).decode(charset)
1819
1819
1820
1820
if not param_key in params:
1821
1821
raise ValueError (' params dictionary did not contain value for placeholder: %s ' % param_key)
@@ -1842,7 +1842,7 @@ cdef _substitute_params(toformat, params, charset):
1842
1842
else :
1843
1843
""" assume position based substitutions """
1844
1844
offset = 0
1845
- for count, match in enumerate (_re_pos_param.finditer(toformat.decode(charset) )):
1845
+ for count, match in enumerate (_re_pos_param.finditer(toformat)):
1846
1846
# calculate string positions so we can keep track of the offset to
1847
1847
# be used in future substitutions on this string. This is
1848
1848
# necessary b/c the match start() and end() are based on the
0 commit comments