[Python-modules-team] Bug#565351: ipython: %psearch causes TypeError: expected string or buffer
Yaroslav Halchenko
debian at onerussian.com
Fri Jan 15 00:13:03 UTC 2010
Package: ipython
Version: 0.10-1
Severity: normal
I've ran into this issue many times and finally decided to report ;)
In [1]: import numpy
In [2]: %psearch numpy.*.*s
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/usr/lib/pymodules/python2.5/IPython/OInspect.pyc in psearch(self, pattern, ns_table, ns_search, ignore_case, show_all)
601 tmp_res = list(list_namespace(ns,type_pattern,filter,
602 ignore_case=ignore_case,
--> 603 show_all=show_all))
604 search_result.extend(tmp_res)
605 search_result.sort()
/usr/lib/pymodules/python2.5/IPython/wildcard.pyc in list_namespace(namespace, type_pattern, filter, ignore_case, show_all)
144 for name,obj in nsdict.iteritems():
145 ns=list_namespace(obj,type_pattern,".".join(pattern_list[1:]),
--> 146 ignore_case=ignore_case,show_all=show_all)
147 for inner_name,inner_obj in ns.iteritems():
148 res["%s.%s"%(name,inner_name)]=inner_obj
/usr/lib/pymodules/python2.5/IPython/wildcard.pyc in list_namespace(namespace, type_pattern, filter, ignore_case, show_all)
144 for name,obj in nsdict.iteritems():
145 ns=list_namespace(obj,type_pattern,".".join(pattern_list[1:]),
--> 146 ignore_case=ignore_case,show_all=show_all)
147 for inner_name,inner_obj in ns.iteritems():
148 res["%s.%s"%(name,inner_name)]=inner_obj
/usr/lib/pymodules/python2.5/IPython/wildcard.pyc in list_namespace(namespace, type_pattern, filter, ignore_case, show_all)
133 ns=NameSpace(namespace,name_pattern=pattern_list[0],type_pattern=type_pattern,
134 ignore_case=ignore_case,show_all=show_all)
--> 135 return ns.ns
136 else:
137 # This is where we can change if all objects should be searched or
/usr/lib/pymodules/python2.5/IPython/wildcard.pyc in get_ns(self)
95 def get_ns(self):
96 """Return name space dictionary with objects matching type and name patterns."""
---> 97 return self.filter(self.name_pattern,self.type_pattern)
98 ns=property(get_ns)
99
/usr/lib/pymodules/python2.5/IPython/wildcard.pyc in filter(self, name_pattern, type_pattern)
118 #Filter namespace by the name_pattern
119 all=[(x,ns[x]) for x in glob_filter(ns.keys(),name_pattern,
--> 120 self.show_all,self.ignore_case)]
121 #Filter namespace by type_pattern
122 all=[(key,obj) for key,obj in all if is_type(obj,type_pattern)]
/usr/lib/pymodules/python2.5/IPython/wildcard.pyc in glob_filter(lista, name_pattern, hidehidden, ignore_case)
113 else:
114 reg=re.compile(pattern+"$")
--> 115 result=[x for x in lista if reg.match(x) and show_hidden(x,hidehidden)]
116 return result
117 ns=self._ns
TypeError: expected string or buffer
happens with
ipdb> p lista
[<type 'numpy.void'>, <type 'numpy.float128'>, 'f4', <type 'numpy.int8'>, 'f8', <type 'numpy.float64'>, 'Complex128', <type 'numpy.int32'>, <type 'numpy.int16'>, 'Bool', 'b1', <type 'numpy.string_'>, 'String0', 'q', <type 'numpy.complex64'>, 'Complex64', 'G', 'u4', <type 'numpy.int64'>, 'Unicode0', 'u1', <type 'numpy.complex128'>, 'u2', 'i1', 'UInt16', 'Float32', <type 'numpy.int64'>, 'Int64', <type 'numpy.complex256'>, 'c16', '?', 'Void0', <type 'numpy.bool_'>, 'i8', <type 'numpy.uint8'>, 'B', 'D', <type 'numpy.object_'>, 'F', 'I', 'H', 'i2', <type 'numpy.uint16'>, 'L', 'O', 'i4', 'Q', 'S', 'c8', 'U', 'Int8', 'Complex32', 'V', <type 'numpy.uint32'>, <type 'numpy.unicode_'>, 'u8', 'UInt64', 'Float64', 'b', 'd', 'g', 'f', 'i', 'h', 'UInt8', 'l', 'UInt32', 'Object0', <type 'numpy.uint64'>, 'Float128', <type 'numpy.uint64'>, 'c32', 'f16', 'Int16', <type 'numpy.float32'>, 'Int32']
ipdb> reg.match(lista[0])
*** TypeError: expected string or buffer
I guess safest way would be to check first if x is a string at all ;)
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (901, 'unstable'), (900, 'testing'), (300, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.31-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages ipython depends on:
ii python 2.5.4-5 An interactive high-level object-o
ii python-pexpect 2.3-1 Python module for automating inter
ii python-support 1.0.3 automated rebuilding support for P
Versions of packages ipython recommends:
ii global 5.7.1-1 Source code search and browse tool
ii python [python-ctypes] 2.5.4-5 An interactive high-level object-o
ii python-ctypes 1.0.2-6 Python package to create and manip
ii python-foolscap 0.4.2+dfsg-1 object-capability-based RPC system
ii python-openssl 0.9-1 Python wrapper around the OpenSSL
ii python-twisted-core 8.2.0-3 Event-based framework for internet
ii python-wxgtk2.8 2.8.7.1-2+b1 wxWidgets Cross-platform C++ GUI t
pn python-zope.interface <none> (no description available)
Versions of packages ipython suggests:
ii libjs-jquery 1.3.3-2 JavaScript library for dynamic web
ii python-gobject 2.16.1-1 Python bindings for the GObject li
ii python-gtk2 2.16.0-1 Python bindings for the GTK+ widge
ii python-matplotlib 0.99.0-1 Python based plotting system in a
ii python-numpy 1:1.3.0-3 Numerical Python adds a fast array
ii python-profiler 2.5.2-1 deterministic profiling of any Pyt
ii python-qt4 4.6-1 Python bindings for Qt4
-- debconf-show failed
More information about the Python-modules-team
mailing list