Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix wildcard search for updated namespaces #1081

Merged
merged 2 commits into from

2 participants

@takluyver
Owner

Closes #1076.

@fperez
Owner

Looks good, thanks! Merging now.

@fperez fperez merged commit c309789 into ipython:master
@fperez 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.
View
2  IPython/core/interactiveshell.py
@@ -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__
}
View
2  IPython/core/magic.py
@@ -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)
View
18 IPython/core/oinspect.py
@@ -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)))
View
4 IPython/core/tests/test_magic.py
@@ -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.