Skip to content

Unable to import random with python2.7 on power pc based machine #70930

Closed

Description

@ragreddy
mannequin
BPO 26743
Nosy @rhettinger, @mdickinson, @vstinner, @skrah, @serhiy-storchaka, @csabella
Files
  • sqrt.c
  • 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 = None
    closed_at = <Date 2018-02-14.07:34:47.156>
    created_at = <Date 2016-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 = <Date 2018-02-14.07:34:47.155>
    user = 'https://bugs.python.org/ragreddy'

    bugs.python.org fields:

    activity = <Date 2018-02-14.07:34:47.155>
    actor = 'mark.dickinson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-02-14.07:34:47.156>
    closer = 'mark.dickinson'
    components = ['Library (Lib)']
    creation = <Date 2016-04-13.00:56:46.007>
    creator = 'ragreddy'
    dependencies = []
    files = ['42459']
    hgrepos = []
    issue_num = 26743
    keywords = []
    message_count = 29.0
    messages = ['263292', '263309', '263327', '263360', '263362', '263363', '263364', '263365', '263366', '263369', '263370', '263373', '263376', '263379', '263428', '263429', '263431', '263432', '263433', '263435', '263436', '263513', '263514', '263516', '263526', '263527', '263528', '312146', '312162']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'mark.dickinson', 'vstinner', 'skrah', 'serhiy.storchaka', 'ragreddy', 'cheryl.sabella']
    pr_nums = []
    priority = 'normal'
    resolution = 'third party'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26743'
    versions = ['Python 2.7']

    Activity

    1. ragreddy commented on Apr 13, 2016

      ragreddymannequin
      MannequinAuthor

      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
      >>>
    2. added
      type-crash
      stdlib
      on Apr 13, 2016
    3. added
      type-bug
      and removed
      type-crash
      on Apr 13, 2016
    4. rhettinger commented on Apr 13, 2016

      @rhettinger
      Contributor

      That's odd.

      Try:
      import math
      print math.sqrt(2.0)
      print math

      Post what you see.

    5. mdickinson commented on Apr 13, 2016

      @mdickinson
      Member

      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.

    6. ragreddy commented on Apr 13, 2016

      ragreddymannequin
      MannequinAuthor

      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@'
      >>>
    7. vstinner commented on Apr 14, 2016

      @vstinner
      Member
      >>> print math.sqrt(2.0)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ValueError: math domain error

      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.41421
    8. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      stinner victor, my host doesn't have a gcc compiler. is there a way you can give me the binary?

    9. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      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

    10. vstinner commented on Apr 14, 2016

      @vstinner
      Member

      What is your Linux distribution and what is your CPU? (try to read /proc/cpuinfo)

      You cannot install a C compiler?

    11. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      It's windriver linux. Processor is PPC64-E5500

    12. serhiy-storchaka commented on Apr 14, 2016

      @serhiy-storchaka
      Member

      What is the output of struct.pack('d', 2.0) and struct.pack('d', float(2))?

    13. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      Serhiy,

      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 struct
      >>> struct.pack('d', 2.0)
      '@\x00\x00\x00\x00\x00\x00\x00'
      >>> struct.pack('d', float(2))
      '@\x00\x00\x00\x00\x00\x00\x00'
      >>>
    14. 5 remaining items

    15. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      The keys ENDIAN and IEEE are not available.

    16. vstinner commented on Apr 14, 2016

      @vstinner
      Member

      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:
      ---

      $ grep IEEE /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 */

    17. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      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:
      #

    18. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      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__
      #  define WORDS_BIGENDIAN 1
      # endif
      #else
      # ifndef WORDS_BIGENDIAN
      #  define WORDS_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.

    19. ragreddy commented on Apr 14, 2016

      ragreddymannequin
      MannequinAuthor

      @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.

    20. ragreddy commented on Apr 15, 2016

      ragreddymannequin
      MannequinAuthor

      Hey Guys/Gals, are you still debugging the issue? Do you need more info?

    21. skrah commented on Apr 15, 2016

      skrahmannequin
      Mannequin

      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.

    22. skrah commented on Apr 15, 2016

      skrahmannequin
      Mannequin

      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?

    23. ragreddy commented on Apr 15, 2016

      ragreddymannequin
      MannequinAuthor

      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.

    24. skrah commented on Apr 15, 2016

      skrahmannequin
      Mannequin

      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.

    25. ragreddy commented on Apr 15, 2016

      ragreddymannequin
      MannequinAuthor

      Thank you skrah. I raised a support request from WR. I will keep my fingers crossed.

    26. csabella commented on Feb 14, 2018

      @csabella
      Contributor

      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!

    27. mdickinson commented on Feb 14, 2018

      @mdickinson
      Member

      @csabella: Agreed. Let's close. Thanks!

    28. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions