Ticket #7377: trac_7377-unicode_to_ecl.patch

File trac_7377-unicode_to_ecl.patch, 1.1 KB (added by jpflori, 8 years ago)

Convert unicode objects to str objects to build ecl objects.

  • sage/libs/ecl.pyx

    # HG changeset patch
    # User Jean-Pierre Flori <flori@enst.fr>
    # Date 1299059470 -3600
    # Node ID dd98bcda168acccd36422b1ad82d640f5c8e9cf4
    # Parent  4b00ac036cceb470c88130bd777746789dcb308e
    Convert unicode to str before conversion to ecl_object
    
    diff -r 4b00ac036cce -r dd98bcda168a sage/libs/ecl.pyx
    a b  
    284284            return string_to_object(s)
    285285    elif isinstance(pyobj,float):
    286286        return ecl_make_doublefloat(pyobj)
     287    elif isinstance(pyobj,unicode):
     288        s=<bytes>(str(pyobj))
     289        return ecl_safe_read_string(s)       
    287290    elif isinstance(pyobj,bytes):
    288291        s=<bytes>pyobj
    289292        return ecl_safe_read_string(s)
     
    328331            cl_rplacd(ptr,python_to_ecl(pyobj[-1]))
    329332            return L
    330333    else:
    331         raise TypeError,"Unimplemented type for python_to_ecl"
     334        raise TypeError,"Unimplemented type %s for python_to_ecl"%type(pyobj)
    332335
    333336cdef ecl_to_python(cl_object o):
    334337    # conversions from an ecl object to a python object.