On Wed, Sep 6, 2017 at 3:35 PM, Frédéric Chapoton <fchapot...@gmail.com> wrote:
> This [b'1', b'1'] is the next problem, once the hash issue is corrected. I
> only have a branch with the added hash on my own computer at home, so I can
> not push it to trac immediatly.

This error (and many others like it) comes from the fact that we're
compiling Cython sources with "language level 2" (i.e. closer to
Python 2 semantics, the default), where "str" means "bytes".  So there
are many methods that return "bytes" objects that really should be
returning "str" on Python 3, causing much confusion in interfaces that
consume those methods.  This can be worked around of course, but the
question becomes:  For SAGE_PYTHON3 do we want to compile Cython
sources with "language level 3"?

I would suggest yes, we do, as it makes the semantics of Python
2/3-straddling code more similar in Python and Cython code.  Otherwise
we're stuck with this terribly confusing situation where Cython code
needs to still be written in a way that is compatible with Python 3
pure Python code, but types like "str" still keep the Python 2
semantics, but only sort of...

I'm going to experiment with setting Cython to -3 and see how far I get...

> Le mercredi 6 septembre 2017 15:29:01 UTC+2, Erik Bray a écrit :
>>
>> On Mon, Aug 28, 2017 at 8:45 PM, Frédéric Chapoton <fchap...@gmail.com>
>> wrote:
>> > Indeed, adding __hash__ to the CDF class seems to fix this specific
>> > issue. I
>> > wonder how many hash we are going to be forced to add..
>>
>> I've finally gotten my python3 build to a point where I'm able to
>> reproduce this problem.  Have you committed any changes related to
>> this yet, or is this the latest updated on this issue?  What exactly
>> does the __hash__ you added look like?
>>
>> > The next problem is very strange. During the initialisation of the damn
>> > I
>> > symbol (that seems to be responsible for a non-negligible part of our
>> > startup time), the following code
>> >
>> > R = QQ['x']
>> > f = R([-D,0,1])
>> >
>> > and the replacement code that I tried
>> >
>> >     919     x = polygen(QQ, 'x')
>> >     920     f = x * x - D
>> >
>> > both return a polynomial with coefficients [b'1', b'1'], which of course
>> > does not make any sense..
>>
>> I'm a little confused--this doesn't have anything to do with the
>> __hash__ problem does it?  Why does the existing code here need to be
>> replaced with anything at all?
>>
>>
>>
>> > Le lundi 28 août 2017 14:30:20 UTC+2, Jeroen Demeyer a écrit :
>> >>
>> >> I'm guessing it might be this from
>> >> https://docs.python.org/3.6/reference/datamodel.html#object.__hash__
>> >>
>> >> A class that overrides __eq__() and does not define __hash__() will
>> >> have
>> >> its __hash__() implicitly set to None.
>> >>
>> >>
>> >> Python2:
>> >>
>> >>  >>> class X(tuple):
>> >> ...     def __eq__(self, other): return False
>> >>  >>> hash(X())
>> >> 3527539
>> >>
>> >> Python 3:
>> >>
>> >>  >>> class X(tuple):
>> >> ...     def __eq__(self, other): return False
>> >>  >>> hash(X())
>> >> Traceback (most recent call last):
>> >>    File "<stdin>", line 1, in <module>
>> >> TypeError: unhashable type: 'X'
>> >>
>> >>
>> >> Interestingly, Python 2 also acts like this for *extension types* (such
>> >> as Cython cdef classes) but not for ordinary Python classes.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "sage-devel" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to sage-devel+...@googlegroups.com.
>> > To post to this group, send email to sage-...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/sage-devel.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

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

Reply via email to