Export to GitHub

pyeuclid - issue #5

cocos.euclid.Vector2.__rsub__ bug


Posted on Apr 18, 2009 by Happy Rhino

What steps will reproduce the problem? 1. in the python interpreter do 2. import euclid 3. a = euclid.Vector2(1,1) 4. (0,0) - a

What is the expected output? What do you see instead? (-1.0, -1.0) is expected, you get Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> (0,0)-a File "D:\tmp\euclid.py", line 202, in rsub return Vector2(other.x - self[0], AttributeError: 'tuple' object has no attribute 'x'

What version of the product are you using? On what operating system? euclid 0.31, python 2.6.1 , windows XP

Please provide any additional information below. I think is a typo, with trivial fix (attached a svn diff against r31)

Attachments

Comment #1

Posted on Apr 24, 2009 by Happy Rhino

PD: the subject refers to cocos.euclid.Vector2 ( thats where I originally found the problem) but I checked out this project ( pyeuclid ) and verified it manifest the same problem. The traceback and svn diff are against pyeuclid r31.

Comment #2

Posted on May 12, 2009 by Happy Monkey

Fix seems pretty straightforward, attached is a patch

import euclid a = euclid.Vector2(1,1) (0,0) - a Vector2(-1.00, -1.00)

Explanation: The bug assessed correctly that the other object is not a euclid.VectorX, but then still tries to access members .x and .y. Simple copy and paste mistake.

Attachments

Comment #3

Posted on May 12, 2009 by Happy Monkey

Argg, sorry ccanepacc, didn't see you already attached a fix ;) It is already late. Anyway, the patch I added also fixes the same problem for Vector3.rsub

Status: New

Labels:
Type-Defect Priority-Medium