[Python-porting] bugs in 2to3 tools when porting sympy

Ondrej Certik ondrej at certik.cz
Mon Jul 6 11:14:40 CEST 2009


On Mon, Jul 6, 2009 at 2:01 AM, Amaury Forgeot d'Arc<amauryfa at gmail.com> wrote:
> Hello,
>
> 2009/7/6 Ondrej Certik <ondrej at certik.cz>:
>> On Sun, Jul 5, 2009 at 6:54 PM, Ondrej Certik<ondrej at certik.cz> wrote:
>> [...]
>>> I have a serious problem that the __hash__
>>> method is defined in the Basic() class, but in it's subclasses (Number
>>> and Symbol):
>>>
>>> Number.__hash__
>>>
>>> returns None, but
>>>
>>> Symbol.__hash__
>>>
>>> correctly points to the Basic.hash method.
>
> Number certainly defines a __eq__ method, which blocks the inheritance
> of __hash__.
> See the last paragraph of
> http://docs.python.org/dev/py3k/reference/datamodel.html#object.__hash__

That was it! Many thanks for the hint, without it I would spend a lot
more hours on this.
So Python3.0 seems to be more strict than python2.6, since that code
is in sympy for a long time and it always worked in python2.4 up to
2.6. The fix is trivial, I just assign the __hash__ method from a
parent and things start working.

There are other unrelated failures, but those I will tackle myself.

Thanks again for the help,
Ondrej


More information about the Python-porting mailing list