Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contains() only supports bytes, not general unicode strings #142

Closed
FrancescAlted opened this issue Apr 7, 2014 · 1 comment
Closed

Comments

@FrancescAlted
Copy link
Contributor

This shows the problem:

In [3]: ne.evaluate("contains('abc', 'bc')")
Out[3]: array(True, dtype=bool)

In [4]: ne.evaluate("contains(u'abc', u'bc')")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-59a7eb2860bb> in <module>()
----> 1 ne.evaluate("contains(u'abc', u'bc')")

/home/faltet/software/numexpr/numexpr/necompiler.pyc in evaluate(ex, local_dict, global_dict, out, order, casting, **kwargs)
    710     expr_key = (ex, tuple(sorted(context.items())))
    711     if expr_key not in _names_cache:
--> 712         _names_cache[expr_key] = getExprNames(ex, context)
    713     names, ex_uses_vml = _names_cache[expr_key]
    714     # Get the arguments based on the names.

/home/faltet/software/numexpr/numexpr/necompiler.pyc in getExprNames(text, context)
    631 
    632 def getExprNames(text, context):
--> 633     ex = stringToExpression(text, {}, context)
    634     ast = expressionToAST(ex)
    635     input_order = getInputOrder(ast, None)

/home/faltet/software/numexpr/numexpr/necompiler.pyc in stringToExpression(s, types, context)
    243         names.update(expressions.functions)
    244         # now build the expression
--> 245         ex = eval(c, names)
    246         if expressions.isConstant(ex):
    247             ex = expressions.ConstantNode(ex, expressions.getKind(ex))

<expr> in <module>()

/home/faltet/software/numexpr/numexpr/expressions.pyc in func(*args)
     86                 args[i] = x = ConstantNode(x)
     87             if not isinstance(x, ExpressionNode):
---> 88                 raise TypeError("unsupported object type: %s" % type(x))
     89         return f(*args)
     90     func.__name__ = f.__name__

TypeError: unsupported object type: <type 'unicode'>
@robbmcleod
Copy link
Member

Please redirect any discussion regarding unicode support to #263.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants