#14644: Unable to coerce (<type 'unicode'>) to Rational
-------------------------------------+-------------------------------------
       Reporter:  pdehaye            |        Owner:  robertwb
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-7.3
      Component:  coercion           |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/unable_to_coerce___type__unicode____to_rational|  
174738257ff2e6b21fb100cfa25824a1666943a4
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 There is no possible way to make Python2 and 3 compatible code here:

 ||               ||= Python2          =||= Python3  =||
 ||= common base =||  `basestring`      || ?          ||
 ||= bytes       =||  `str` or `bytes`  ||  `unicode` ||
 ||= unicode     =||  `bytes`           ||  `str`     ||

 A 2/3 compatible way is to add (do not know if it applies to Cython)
 {{{
 from past.builtins import basestring
 }}}
 Or alternatively use the `str` available in `builtins`
 {{{
 sage: from builtins import str
 sage: isinstance('toto', str)
 False
 sage: isinstance(u'toto', str)
 True
 }}}
 see http://python-future.org/compatible_idioms.html

--
Ticket URL: <https://trac.sagemath.org/ticket/14644#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to