diff --git a/doc/v2/faq.html b/doc/v2/faq.html index cc1df0b9..c21007ab 100644 --- a/doc/v2/faq.html +++ b/doc/v2/faq.html @@ -39,6 +39,8 @@ structure overflow
How do I debug my Python extensions?
+ +
Why doesn't my *= operator work?
@@ -296,11 +298,39 @@ setting up PYTHONPATH and other important environment variables such as LD_LIBRARY_PATH which may be needed by your debugger in order to get things to work right. +

Why doesn't my *= operator work?

+ +
+Q: I have exported my class to python, with many overloaded operators. it +works fine for me except the *= operator. It always tells +me "can't multiply sequence with non int type". If I use +p1.__imul__(p2) instead of p1 *= +p2, it successfully executes my code. What's wrong with +me? + +

A: There's nothing wrong with you. This is a bug in Python +2.2. You can see the same effect in Pure Python (you can learn a lot +about what's happening in Boost.Python by playing with new-style +classes in Pure Python). + +

+>>> class X(object):
+...     def __imul__(self, x):
+...         print 'imul'
+...
+>>> x = X()
+>>> x *= 1
+
+ +To cure this problem, all you need to do is upgrade your Python to +version 2.2.1 or later. + +

Revised - 23 November, 2002 + 24 November, 2002