gdanezis / petlib

A python library that implements a number of Privacy Enhancing Technolgies
BSD 2-Clause "Simplified" License
130 stars 33 forks source link

Bn's constructor does not check its parameter is a number #2

Closed Sidnioulz closed 9 years ago

Sidnioulz commented 9 years ago

Which results in Bn.__init__ serving arbitrary objects to abs(). According to the doc, the following types are acceptable:

"The argument may be a plain or long integer or a floating point number. If the argument is a complex number, its magnitude is returned."

You could either make Bn be an int or float, make its constructor explicitely reject wrong input types, or build a copy constructor (is that even a thing in Python!?).

Sidnioulz commented 9 years ago

https://gist.github.com/Sidnioulz/68df16e3c59ad0714614

gdanezis commented 9 years ago

Dealt with this in a pythonic way.