mnba / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

__neg__, __add__ work only inside module #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

% shedskin -e Vector4.py
% make
% python
Python 2.5.2 (r252:60911, Jan 20 2010, 23:16:55) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Vector4 import Vector4
>>> a = Vector4(1, 2, 3, 0)
>>> -a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: 'Vector4.Vector4'
>>> a.neg()
<Vector4.Vector4 object at 0xb74ab320>
>>> a - a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'Vector4.Vector4' and 
'Vector4.Vector4'
>>> a.sub(a)
<Vector4.Vector4 object at 0xb74ab340>

What is the expected output? What do you see instead?

Operator overrides work fine inside the module.
If you don't use '-e' and build Vector4 as a standalone executable, it works 
fine, and the output is:

% ./Vector4
<Vector4 instance>
<Vector4 instance>

However, if you build it as a module and import it, suddenly the operators 
don't work.  You can work around this by adding in non-operator functions, but 
if you're porting a larger project that does a lot of math [as I was trying to 
do], it's a big pain.

What version of the product are you using? On what operating system?

This is shedskin 0.5 on Ubuntu 9.

Please provide any additional information below.

Original issue reported on code.google.com by uran...@gmail.com on 16 Aug 2010 at 12:21

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for the issues! I will try to have a look at supporting overloading in 
extension modules later this week.

Original comment by mark.duf...@gmail.com on 16 Aug 2010 at 5:34

GoogleCodeExporter commented 9 years ago
also fixed in GIT. please let me know if you run into anything else. thanks 
again for reporting! I guess this is a useful addition :P

Original comment by mark.duf...@gmail.com on 18 Aug 2010 at 11:28