beeware / batavia

A JavaScript implementation of the Python virtual machine.
http://pybee.org/batavia
Other
1.39k stars 424 forks source link

Wrong error type returned by pow function #735

Closed djmgit closed 5 years ago

djmgit commented 6 years ago

Expected Behavior

Pow function should return ValueError when there are 3 arguments and the second argument is negative.

Current Behavior

Batavia is returning TypeError for the above mentioned case. This is also causing the tests in tests/builts/test_pow to fail.

Steps to reproduce

  1. Execite the following code snippet using Batavia
    print(pow(1, -1, 1)

    Batavia returns TypeError:

    Traceback (most recent call last):
    File "/home/deep/batavia/test3.py", line 1, in <module>
    TypeError: pow() 2nd argument cannot be negative when 3rd argument specified

    however python returns ValueError

    Traceback (most recent call last):
    File "../test3.py", line 1, in <module>
    print(pow(2, -4, 1))
    ValueError: pow() 2nd argument cannot be negative when 3rd argument specified

    Your Environment

djmgit commented 6 years ago

I am working on this.

martica commented 5 years ago

This was fixed by #784.