Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix wildcard search for updated namespaces #1081

Merged
merged 2 commits into from

2 participants

Thomas Kluyver Fernando Perez
Thomas Kluyver
Owner

Closes #1076.

Fernando Perez
Owner

Looks good, thanks! Merging now.

Fernando Perez fperez merged commit c309789 into from
Fernando Perez fperez referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  IPython/core/interactiveshell.py
View
@@ -923,7 +923,7 @@ def init_create_namespaces(self, user_module=None, user_ns=None):
# A table holding all the namespaces IPython deals with, so that
# introspection facilities can search easily.
self.ns_table = {'user_global':self.user_module.__dict__,
- 'user_local':user_ns,
+ 'user_local':self.user_ns,
'builtin':builtin_mod.__dict__
}
2  IPython/core/magic.py
View
@@ -693,7 +693,7 @@ def magic_psearch(self, parameter_s=''):
return
# default namespaces to be searched
- def_search = ['user','builtin']
+ def_search = ['user_local', 'user_global', 'builtin']
# Process options/args
opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
18 IPython/core/oinspect.py
View
@@ -762,13 +762,15 @@ def psearch(self,pattern,ns_table,ns_search=[],
(name,ns_table.keys()))
#print 'type_pattern:',type_pattern # dbg
- search_result = []
+ search_result, namespaces_seen = set(), set()
for ns_name in ns_search:
ns = ns_table[ns_name]
- tmp_res = list(list_namespace(ns,type_pattern,filter,
- ignore_case=ignore_case,
- show_all=show_all))
- search_result.extend(tmp_res)
- search_result.sort()
-
- page.page('\n'.join(search_result))
+ # Normally, locals and globals are the same, so we just check one.
+ if id(ns) in namespaces_seen:
+ continue
+ namespaces_seen.add(id(ns))
+ tmp_res = list_namespace(ns, type_pattern, filter,
+ ignore_case=ignore_case, show_all=show_all)
+ search_result.update(tmp_res)
+
+ page.page('\n'.join(sorted(search_result)))
4 IPython/core/tests/test_magic.py
View
@@ -340,3 +340,7 @@ def doctest_precision():
Out[5]: {u}'3.141593e+00'
"""
+def test_psearch():
+ with tt.AssertPrints("dict.fromkeys"):
+ _ip.run_cell("dict.fr*?")
+
Something went wrong with that request. Please try again.