From 9f6b8e908edcf5e6377c0f4b0b1dd8607c4bfc3e Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Mon, 7 Dec 2020 11:21:33 +0100 Subject: [PATCH] Python release 1.2.1 (#20) - add float() support for Python 3.7 - Travis-CI -- fix Windows SSL error on new image -- update Python to 3.8.6 --- .travis.yml | 4 +++- bindings/python/python-bindings.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee41d66..540a84d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,11 @@ jobs: - os: windows language: shell before_install: - - choco install python --version 3.8.0 + - choco install python --version 3.8.6 - export PATH="/c/Python38:/c/Python38/Scripts:$PATH" - ln -s /c/Python38/python.exe /c/Python38/python3.exe + # Update root certificates to fix SSL error + - powershell "md C:\temp\certs; CertUtil -generateSSTFromWU C:\temp\certs\RootStore.sst; Get-ChildItem -Path C:\\temp\certs\Rootstore.sst | Import-Certificate -CertStoreLocation Cert:\\LocalMachine\\Root\\ | out-null" env: global: diff --git a/bindings/python/python-bindings.cpp b/bindings/python/python-bindings.cpp index 83613ed..a3ce3c3 100644 --- a/bindings/python/python-bindings.cpp +++ b/bindings/python/python-bindings.cpp @@ -67,7 +67,7 @@ py::int_ to_py_int(const BigInteger& value, bool is_signed = true, bool is_bigen return py::reinterpret_steal(obj); } -static constexpr auto VERSION_BINDINGS = "1.2"; +static constexpr auto VERSION_BINDINGS = "1.2.1"; PYBIND11_MODULE(pybiginteger, m) { m.doc() = "A C++ port of the C# BigInteger class"; @@ -306,7 +306,8 @@ PYBIND11_MODULE(pybiginteger, m) { https://docs.microsoft.com/en-us/dotnet/api/system.numerics.biginteger.tobytearray?view=netcore-3.1#System_Numerics_BigInteger_ToByteArray_System_Boolean_System_Boolean_)", py::arg("is_unsigned") = false, py::arg("is_bigendian") = false) - .def("__int__", [](BigInteger& self) { return to_py_int(self); }) // support int() + .def("__int__", [](BigInteger& self) { return to_py_int(self); }) // support int() + .def("__float__", [](BigInteger& self) { return py::float_(to_py_int(self)); }) // support float() for Python < 3.8 .def("__index__", [](BigInteger& self) { return to_py_int(self); }) // support range() .def("__str__", &BigInteger::to_string) .def_static("zero", &BigInteger::zero)