On 8/31/17, Terry Reedy <tjre...@udel.edu> wrote: > On 8/30/2017 1:35 PM, Terry Reedy wrote: >> https://stackoverflow.com/questions/45965545/math-sqrt-domain-error-when-square-rooting-a-positive-number >> >> >> >> reports the following: >> ----- >> Microsoft Windows [Version 10.0.16251.1002] >> (c) 2017 Microsoft Corporation. All rights reserved. >> >> C:\Users\Adam>python >> Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit >> (Intel)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import math >> >>> math.sqrt(1.3) >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> ValueError: math domain error >> >>> >> >> I upgraded from version 3.6.1 to 3.6.2 to try to resolve the issue and >> restarted my computer but it is still occurring. Some numbers are >> working (1.2, 1.4) and some others are also not working (1.128). >> ---- >> >> Neither installed 64 bit 3.6.2 nor my repository 3.6 32-bit debug build >> reproduce this. If anyone has the python.org 32bit 3.6.1/2 releases >> installed on Windows, please test and report. > > Three people have reported that math.sqrt(1.3) works in 32 bit Python on > 64-bit Windows and no one otherwise. I reported back on SO that the > problem is likely local. Thanks for the responses.
Problem is reported on win10 and I see just 2 tests on win7 (third is maybe Terry's but on SO I don't see win version). If I am not wrong (with analyze source code) sqrt is calling function from "libm" which is some kind of msvcrt.dll on windows... (see https://github.com/python/cpython/blob/a0ce375e10b50f7606cb86b072fed7d8cd574fe7/Modules/mathmodule.c#L1183 and https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/ctypes/util.py#L34 ) And with "MSC v. 1900 ..." it seems that "alternative approaches" (see here https://bugs.python.org/issue23606 ) are used. So I would be cautious. PS. BTW on my ubuntu I got this: from ctypes import cdll print(cdll.LoadLibrary("libcrypt.so")) <CDLL 'libcrypt.so', handle 21d0860 at 0x7fcce2f22f28> print(cdll.LoadLibrary("libm.so")) ... OSError: /usr/lib/x86_64-linux-gnu/libm.so: invalid ELF header (same with distro's python3, python2 and anaconda 3.6.2) So this test -> https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/ctypes/util.py#L328 has to crash on some environments (see for example: https://github.com/scipy/scipy/pull/5416/files ). And it seems like some test failures are just ignored... -- https://mail.python.org/mailman/listinfo/python-list