Show More
@@ -212,6 +212,8 b' class InteractiveShellTestCase(unittest.TestCase):' | |||
|
212 | 212 | self.assertEqual(ip.var_expand(u'echo {f[:-1]}'), u'echo Ca\xf1') |
|
213 | 213 | self.assertEqual(ip.var_expand(u'echo {1*2}'), u'echo 2') |
|
214 | 214 | |
|
215 | self.assertEqual(ip.var_expand(u"grep x | awk '{print $1}'"), u"grep x | awk '{print $1}'") | |
|
216 | ||
|
215 | 217 | ip.user_ns['f'] = b'Ca\xc3\xb1o' |
|
216 | 218 | # This should not raise any exception: |
|
217 | 219 | ip.var_expand(u'echo $f') |
@@ -592,7 +592,7 b' class DollarFormatter(FullEvalFormatter):' | |||
|
592 | 592 | In [4]: f.format('$a or {b}', a=1, b=2) |
|
593 | 593 | Out[4]: '1 or 2' |
|
594 | 594 | """ |
|
595 | _dollar_pattern = re.compile("(.*?)\$(\$?[\w\.]+)") | |
|
595 | _dollar_pattern_ignore_single_quote = re.compile("(.*?)\$(\$?[\w\.]+)(?=([^']*'[^']*')*[^']*$)") | |
|
596 | 596 | def parse(self, fmt_string): |
|
597 | 597 | for literal_txt, field_name, format_spec, conversion \ |
|
598 | 598 | in Formatter.parse(self, fmt_string): |
@@ -600,7 +600,7 b' class DollarFormatter(FullEvalFormatter):' | |||
|
600 | 600 | # Find $foo patterns in the literal text. |
|
601 | 601 | continue_from = 0 |
|
602 | 602 | txt = "" |
|
603 | for m in self._dollar_pattern.finditer(literal_txt): | |
|
603 | for m in self._dollar_pattern_ignore_single_quote.finditer(literal_txt): | |
|
604 | 604 | new_txt, new_field = m.group(1,2) |
|
605 | 605 | # $$foo --> $foo |
|
606 | 606 | if new_field.startswith("$"): |
General Comments 0
You need to be logged in to leave comments.
Login now