You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to import random with python2.7 on power pc based machine #70930
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2018-02-14.07:34:47.156>created_at=<Date2016-04-13.00:56:46.007>labels= ['type-bug', 'library']
title='Unable to import random with python2.7 on power pc based machine'updated_at=<Date2018-02-14.07:34:47.155>user='https://bugs.python.org/ragreddy'
Hi, I am trying to import random on a power pc based machine and I see this exception. Could you please help me?
root@host# python
Python 2.7.3 (default, Apr 3 2016, 22:31:30)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/random.py", line 58, in <module>
NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
ValueError: math domain error
>>>
The output of struct.pack('<d', 2.0) would also be worth knowing about. I'm wondering whether there's some kind of endianness issue going on in the float-to-string conversions.
ragreddy commented on Apr 13, 2016
ragreddymannequin
MannequinAuthor
More actions
Hi, I apologize. I didn't expect a quick reply.
Here are the outputs you requested.
root@host:~# python
Python 2.7.3 (default, Apr 3 2016, 22:31:30)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> print math.sqrt(2.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error
>>> print math
<module 'math' from '/usr/lib/python2.7/lib-dynload/math.so'>
>>> import struct
>>> struct.pack('<d', 2.0)
'\x00\x00\x00\x00\x00\x00\x00@'
>>>
I guess that Serhiy is looking for these variables defined in pyconfig.h:
---
/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM
mixed-endian order (byte order 45670123) */
#undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most
significant byte first */
#undef DOUBLE_IS_BIG_ENDIAN_IEEE754
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
least significant byte first */
#undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
---
On Fedora, pyconfig.h is installed into /usr/include/python2.7/pyconfig.h. This file doesn't contain any sensitive information, it is the configuration used to build Python.
On Fedora, this file only dispatches between pyconfig-32.h and pyconfig-64.h:
---
$cat /usr/include/python2.7/pyconfig.h#include<bits/wordsize.h>#if__WORDSIZE==32#include"pyconfig-32.h"#elif__WORDSIZE==64#include"pyconfig-64.h"#else#error "Unknown word size"
#endif
My system is 64-bit, so I can use pyconfig-64.h:
---
$grepIEEE /usr/include/python2.7/pyconfig-64.h/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 *//* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 *//* Define if C doubles are 64-bit IEEE 754 binary format, stored with the#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1/* #undef HAVE_IEEEFP_H *//* #undef HAVE_LIBIEEE *//* Define to activate features from IEEE Stds 1003.1-2001 */
ragreddy commented on Apr 14, 2016
ragreddymannequin
MannequinAuthor
More actions
Here is one output:
root@fpc0:# grep IEEE /usr/include/python2.7/pyconfig-32.h
/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM
/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most
/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */
/* #undef HAVE_IEEEFP_H */
/* #undef HAVE_LIBIEEE */
/* Define to activate features from IEEE Stds 1003.1-2001 */
root@fpc0:#
ragreddy commented on Apr 14, 2016
ragreddymannequin
MannequinAuthor
More actions
Couple more outputs:
----------------
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */#if defined AC_APPLE_UNIVERSAL_BUILD# if defined __BIG_ENDIAN__# defineWORDS_BIGENDIAN 1
# endif#else# ifndefWORDS_BIGENDIAN# defineWORDS_BIGENDIAN 1
# endif#endif
Math works in some cases.
----------------
>>> import math
>>> math.sqrt(2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error
>>> math.floor(2.5)
2.0
>>>
Also, could you please let me know the train of thought and ask for all the outputs as much as possible in one go? because I feel like I am delaying your debugging.
ragreddy commented on Apr 14, 2016
ragreddymannequin
MannequinAuthor
More actions
@Stinner, my host doesn't have internet connection and it doesn't have gcc installed.
I don't know how to install gcc in windriverlinux.
In famous linux distributions like ubuntu and centos, i install gcc using 'yum install gcc' or 'apt-get install gcc' commands.
ragreddy commented on Apr 15, 2016
ragreddymannequin
MannequinAuthor
More actions
Hey Guys/Gals, are you still debugging the issue? Do you need more info?
skrah commented on Apr 15, 2016
skrahmannequin
Mannequin
More actions
An option would be to use the support of the probably commercial
and ask them why they're still on Python 2.7.3. They'll also
have gcc installed and can run the test case proposed in this
issue.
skrah commented on Apr 15, 2016
skrahmannequin
Mannequin
More actions
Also, I don't understand how the test suite could pass with
these kinds of errors. Are you sure this is the Wind-River
system Python? Did they run the test suite?
ragreddy commented on Apr 15, 2016
ragreddymannequin
MannequinAuthor
More actions
Yes, it is a WindRiver linux. I will check if Commercial WindRiver team can help me.
Host details:
Linux fpc0 3.10.62-ltsi-WR6.0.0.18_standard #1 SMP PREEMPT Sun Apr 3 23:17:02 PDT 2016 ppc64 ppc64 ppc64 GNU/Linux
Also is there a protocol followed in this website? If I have done something wrong it's because I didn't know I was doing it incorrectly. I ask because, a new person replies everyday and they don't even completely tell me the solution or what conclusions they have made. I am lost.
skrah commented on Apr 15, 2016
skrahmannequin
Mannequin
More actions
My conclusion is: The error in msg263292 should have been
caught by the test suite.
I'd ask the WindRiver support if they actually run the test suite
before shipping the binaries.
ragreddy commented on Apr 15, 2016
ragreddymannequin
MannequinAuthor
More actions
Thank you skrah. I raised a support request from WR. I will keep my fingers crossed.
Since there hasn't been activity on this for nearly 2 years, should it be closed as third party? Stefan seemed to conclude that it was a WindRiver issue. Thanks!
Activity
ragreddy commentedon Apr 13, 2016
Hi, I am trying to import random on a power pc based machine and I see this exception. Could you please help me?
root@host# python Python 2.7.3 (default, Apr 3 2016, 22:31:30) [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/random.py", line 58, in <module> NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0) ValueError: math domain error >>>rhettinger commentedon Apr 13, 2016
That's odd.
Try:
import math
print math.sqrt(2.0)
print math
Post what you see.
mdickinson commentedon Apr 13, 2016
The output of
struct.pack('<d', 2.0)would also be worth knowing about. I'm wondering whether there's some kind of endianness issue going on in the float-to-string conversions.ragreddy commentedon Apr 13, 2016
Hi, I apologize. I didn't expect a quick reply.
Here are the outputs you requested.
vstinner commentedon Apr 14, 2016
I'm surprised that such basic math function fails.
Can you please try to compile and run attached C program?
$ gcc sqrt.c -o sqrt -lm && ./sqrt sqrt(2) = 1.41421ragreddy commentedon Apr 14, 2016
stinner victor, my host doesn't have a gcc compiler. is there a way you can give me the binary?
ragreddy commentedon Apr 14, 2016
my host details:
Linux fpc0 3.10.62-ltsi-WR6.0.0.18_standard #1 SMP PREEMPT Sun Apr 3 23:17:02 PDT 2016 ppc64 ppc64 ppc64 GNU/Linux
vstinner commentedon Apr 14, 2016
What is your Linux distribution and what is your CPU? (try to read /proc/cpuinfo)
You cannot install a C compiler?
ragreddy commentedon Apr 14, 2016
It's windriver linux. Processor is PPC64-E5500
serhiy-storchaka commentedon Apr 14, 2016
What is the output of
struct.pack('d', 2.0)andstruct.pack('d', float(2))?ragreddy commentedon Apr 14, 2016
Serhiy,
5 remaining items
ragreddy commentedon Apr 14, 2016
The keys ENDIAN and IEEE are not available.
vstinner commentedon Apr 14, 2016
I guess that Serhiy is looking for these variables defined in pyconfig.h:
---
/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM
mixed-endian order (byte order 45670123) */
#undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most
significant byte first */
#undef DOUBLE_IS_BIG_ENDIAN_IEEE754
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
least significant byte first */
#undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
---
On Fedora, pyconfig.h is installed into /usr/include/python2.7/pyconfig.h. This file doesn't contain any sensitive information, it is the configuration used to build Python.
On Fedora, this file only dispatches between pyconfig-32.h and pyconfig-64.h:
---
My system is 64-bit, so I can use pyconfig-64.h:
---
ragreddy commentedon Apr 14, 2016
Here is one output:
root@fpc0:
# grep IEEE /usr/include/python2.7/pyconfig-32.h#/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM
/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most
/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */
/* #undef HAVE_IEEEFP_H */
/* #undef HAVE_LIBIEEE */
/* Define to activate features from IEEE Stds 1003.1-2001 */
root@fpc0:
ragreddy commentedon Apr 14, 2016
Couple more outputs:
----------------
Math works in some cases.
----------------
Also, could you please let me know the train of thought and ask for all the outputs as much as possible in one go? because I feel like I am delaying your debugging.
ragreddy commentedon Apr 14, 2016
@Stinner, my host doesn't have internet connection and it doesn't have gcc installed.
I don't know how to install gcc in windriverlinux.
In famous linux distributions like ubuntu and centos, i install gcc using 'yum install gcc' or 'apt-get install gcc' commands.
ragreddy commentedon Apr 15, 2016
Hey Guys/Gals, are you still debugging the issue? Do you need more info?
skrah commentedon Apr 15, 2016
An option would be to use the support of the probably commercial
http://www.windriver.com/products/linux/
and ask them why they're still on Python 2.7.3. They'll also
have gcc installed and can run the test case proposed in this
issue.
skrah commentedon Apr 15, 2016
Also, I don't understand how the test suite could pass with
these kinds of errors. Are you sure this is the Wind-River
system Python? Did they run the test suite?
ragreddy commentedon Apr 15, 2016
Yes, it is a WindRiver linux. I will check if Commercial WindRiver team can help me.
Host details:
Linux fpc0 3.10.62-ltsi-WR6.0.0.18_standard #1 SMP PREEMPT Sun Apr 3 23:17:02 PDT 2016 ppc64 ppc64 ppc64 GNU/Linux
Also is there a protocol followed in this website? If I have done something wrong it's because I didn't know I was doing it incorrectly. I ask because, a new person replies everyday and they don't even completely tell me the solution or what conclusions they have made. I am lost.
skrah commentedon Apr 15, 2016
My conclusion is: The error in msg263292 should have been
caught by the test suite.
I'd ask the WindRiver support if they actually run the test suite
before shipping the binaries.
ragreddy commentedon Apr 15, 2016
Thank you skrah. I raised a support request from WR. I will keep my fingers crossed.
csabella commentedon Feb 14, 2018
Since there hasn't been activity on this for nearly 2 years, should it be closed as third party? Stefan seemed to conclude that it was a WindRiver issue. Thanks!
mdickinson commentedon Feb 14, 2018
@csabella: Agreed. Let's close. Thanks!