Dear PyPy developers,<br><br>I have found two bugs while trying to run mpmath on pypy-1.2. This is with the Windows binary:<br><br>Python 2.5.2 (72130, Mar 12 2010, 12:25:40)<br>[PyPy 1.2.0] on win32<br><br>My system is an HP 530, Intel Celeron M 520 @ 1.60 GHz, 1024 MB RAM running Windows XP.<br>
<br>The first bug is an incompatibility with CPython. In CPython, builtin float functions accept arbitrary objects as long as they have a __float__ method. Consider the following code:<br><br>class x(object):<br>    def __float__(self): return 1.0<br>
<br>class y(object):<br>    def __complex__(self): return 1.0j<br><br>round(x())<br>import math; math.log(x())<br>import cmath; cmath.log(x())<br>import cmath; cmath.log(y())<br><br><br>CPython 2.6 gives:<br>1.0<br>0.0<br>
0j<br>1.5707963267948966j<br><br>CPython 2.5 gives:<br>1.0<br>0.0<br>0j<br>TypeError: a float is required<br><br>PyPy gives:<br>TypeError: expected float, got x object<br>TypeError: expected float, got x object<br>0j<br>1.5707963267948966j<br>
<br>Presumably PyPy should do the same thing as 2.6 here.<br><br><br>Secondly, there is an error somewhere in the long multiplication code:<br><br>C:\pypy12&gt;pypy<br>Python 2.5.2 (72130, Mar 12 2010, 12:25:40)<br>[PyPy 1.2.0] on win32<br>
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>And now for something completely different: ``no random bugs in random, after<br>all&#39;&#39;<br>&gt;&gt;&gt;&gt; import mpmath<br>
&gt;&gt;&gt;&gt; mpmath.runtests()<br>mpmath imported from C:\pypy12\lib-python\2.5.2\mpmath<br>mpmath backend: python<br>mpmath mp class: &lt;mpmath.ctx_mp.MPContext object at 0x0000001a&gt;<br>mpmath version: 0.15-svn<br>
Python version: 2.5.2 (72130, Mar 12 2010, 12:25:40)<br>[PyPy 1.2.0]<br><br>[...]<br><br>test_functions2<br>    agm                       ok        0.0446171 s<br>    airy                      ok        0.1957078 s<br>    appellf1                  ok        1.1814778 s<br>
    bessel                    ok        0.6132425 s<br>    coulomb                   ok        0.4926749 s<br>    e1                        ok        0.0109151 s<br>    ei                        ok        0.0346402 s<br>    elliptic_integrals        ok        0.2575911 s<br>
    erf                       ok        0.3858091 s<br>    exp_integrals             ok        0.0715859 s<br>    RPython traceback:<br>  File &quot;implement_4.c&quot;, line 35008, in opcode_impl_for_mul__AccessDirect_star_2<br>
  File &quot;implement_9.c&quot;, line 47885, in __mm_mul_W_LongObject_W_LongObject<br>  File &quot;implement_13.c&quot;, line 3727, in _k_lopsided_mul<br>  File &quot;implement_9.c&quot;, line 38027, in _k_mul<br>Fatal RPython error: AssertionError<br>
<br><br>The test that triggers the failure is &quot;from mpmath import expint; expint(&#39;1.01&#39;, &#39;1e-1000&#39;)&quot;.<br><br>For your convenience, I have tracked down the precise numbers. Since they have several hundred digits, I put them in an attachment.<br>
<br>Thank you for your hard work!<br><br>Fredrik<br>