Show More
@@ -52,7 +52,7 b' TIMEOUT_STORAGE = 2' | |||
|
52 | 52 | TIMEOUT_GIVEUP = 20 |
|
53 | 53 | |
|
54 | 54 | # Regular expression for the python import statement |
|
55 |
import_re = re.compile(r'(?P<name>[ |
|
|
55 | import_re = re.compile(r'(?P<name>[^\W\d]\w*?)' | |
|
56 | 56 | r'(?P<package>[/\\]__init__)?' |
|
57 | 57 | r'(?P<suffix>%s)$' % |
|
58 | 58 | r'|'.join(re.escape(s) for s in _suffixes)) |
@@ -278,8 +278,8 b' def escaped_commands(line):' | |||
|
278 | 278 | _initial_space_re = re.compile(r'\s*') |
|
279 | 279 | |
|
280 | 280 | _help_end_re = re.compile(r"""(%{0,2} |
|
281 |
|
|
|
282 |
(\. |
|
|
281 | (?!\d)[\w*]+ # Variable name | |
|
282 | (\.(?!\d)[\w*]+)* # .etc.etc | |
|
283 | 283 | ) |
|
284 | 284 | (\?\??)$ # ? or ?? |
|
285 | 285 | """, |
@@ -405,8 +405,8 b' class EscapedCommand(TokenTransformBase):' | |||
|
405 | 405 | return lines_before + [new_line] + lines_after |
|
406 | 406 | |
|
407 | 407 | _help_end_re = re.compile(r"""(%{0,2} |
|
408 |
|
|
|
409 |
(\. |
|
|
408 | (?!\d)[\w*]+ # Variable name | |
|
409 | (\.(?!\d)[\w*]+)* # .etc.etc | |
|
410 | 410 | ) |
|
411 | 411 | (\?\??)$ # ? or ?? |
|
412 | 412 | """, |
@@ -208,12 +208,6 b' class NamespaceMagics(Magics):' | |||
|
208 | 208 | |
|
209 | 209 | %psearch -l list all available object types |
|
210 | 210 | """ |
|
211 | try: | |
|
212 | parameter_s.encode('ascii') | |
|
213 | except UnicodeEncodeError: | |
|
214 | print('Python identifiers can only contain ascii characters.') | |
|
215 | return | |
|
216 | ||
|
217 | 211 | # default namespaces to be searched |
|
218 | 212 | def_search = ['user_local', 'user_global', 'builtin'] |
|
219 | 213 |
@@ -37,7 +37,7 b' class PrefilterError(Exception):' | |||
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | # RegExp to identify potential function names |
|
40 |
re_fun_name = re.compile(r'[ |
|
|
40 | re_fun_name = re.compile(r'[^\W\d]([\w.]*) *$') | |
|
41 | 41 | |
|
42 | 42 | # RegExp to exclude strings with this start from autocalling. In |
|
43 | 43 | # particular, all binary operators should be excluded, so that if foo is |
@@ -113,6 +113,7 b' syntax = \\' | |||
|
113 | 113 | (u'%hist2??', "get_ipython().run_line_magic('pinfo2', '%hist2')"), |
|
114 | 114 | (u'%%hist3?', "get_ipython().run_line_magic('pinfo', '%%hist3')"), |
|
115 | 115 | (u'%%hist4??', "get_ipython().run_line_magic('pinfo2', '%%hist4')"), |
|
116 | (u'π.foo?', "get_ipython().run_line_magic('pinfo', 'π.foo')"), | |
|
116 | 117 | (u'f*?', "get_ipython().run_line_magic('psearch', 'f*')"), |
|
117 | 118 | (u'ax.*aspe*?', "get_ipython().run_line_magic('psearch', 'ax.*aspe*')"), |
|
118 | 119 | (u'a = abc?', "get_ipython().set_next_input('a = abc');" |
@@ -119,6 +119,11 b' b) = zip?' | |||
|
119 | 119 | [r"get_ipython().set_next_input('(a,\nb) = zip');get_ipython().run_line_magic('pinfo', 'zip')" + "\n"] |
|
120 | 120 | ) |
|
121 | 121 | |
|
122 | HELP_UNICODE = ( | |
|
123 | ["π.foo?\n"], (1, 0), | |
|
124 | ["get_ipython().run_line_magic('pinfo', 'π.foo')\n"] | |
|
125 | ) | |
|
126 | ||
|
122 | 127 | |
|
123 | 128 | def null_cleanup_transformer(lines): |
|
124 | 129 | """ |
@@ -223,6 +228,9 b' def test_transform_help():' | |||
|
223 | 228 | tf = ipt2.HelpEnd((1, 0), (2, 8)) |
|
224 | 229 | nt.assert_equal(tf.transform(HELP_MULTILINE[0]), HELP_MULTILINE[2]) |
|
225 | 230 | |
|
231 | tf = ipt2.HelpEnd((1, 0), (1, 0)) | |
|
232 | nt.assert_equal(tf.transform(HELP_UNICODE[0]), HELP_UNICODE[2]) | |
|
233 | ||
|
226 | 234 | def test_find_assign_op_dedent(): |
|
227 | 235 | """ |
|
228 | 236 | be careful that empty token like dedent are not counted as parens |
@@ -625,6 +625,8 b' def doctest_precision():' | |||
|
625 | 625 | def test_psearch(): |
|
626 | 626 | with tt.AssertPrints("dict.fromkeys"): |
|
627 | 627 | _ip.run_cell("dict.fr*?") |
|
628 | with tt.AssertPrints("π.is_integer"): | |
|
629 | _ip.run_cell("π = 3.14;\nπ.is_integ*?") | |
|
628 | 630 | |
|
629 | 631 | def test_timeit_shlex(): |
|
630 | 632 | """test shlex issues with timeit (#1109)""" |
@@ -115,3 +115,13 b' def test_prefilter_attribute_errors():' | |||
|
115 | 115 | finally: |
|
116 | 116 | del ip.user_ns['x'] |
|
117 | 117 | ip.magic('autocall 0') |
|
118 | ||
|
119 | ||
|
120 | def test_autocall_should_support_unicode(): | |
|
121 | ip.magic('autocall 2') | |
|
122 | ip.user_ns['π'] = lambda x: x | |
|
123 | try: | |
|
124 | nt.assert_equal(ip.prefilter('π 3'),'π(3)') | |
|
125 | finally: | |
|
126 | ip.magic('autocall 0') | |
|
127 | del ip.user_ns['π'] |
General Comments 0
You need to be logged in to leave comments.
Login now