[SOLVED] Python 2.7 is broken

This forum is for topics dealing with problems with software specifically in the ARMv7h repo.

[SOLVED] Python 2.7 is broken

Postby RMJ » Fri May 05, 2017 9:50 pm

Since this week softwares like offlineimaps and other python2 based have not been working because something is broken with the "random" python2.7 built-in.

The broken package is: python2-2.7.13-2-armv7h.pkg.tar.xz
Downgrading back to python2-2.7.13-1-armv7h.pkg.tar.xz did the trick, but I'm still waiting the FIX.


Edit (11.2017): solved with python2-2.7.14-1 update.
Last edited by RMJ on Tue Nov 07, 2017 1:09 pm, edited 1 time in total.
RMJ
 
Posts: 29
Joined: Fri May 05, 2017 9:32 pm

Re: [!] Python 2.7 is broken

Postby WarheadsSE » Fri May 05, 2017 10:07 pm

What device, and what kernel package are you using?
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6727
Joined: Mon Oct 18, 2010 2:12 pm

Re: [!] Python 2.7 is broken

Postby RMJ » Fri May 05, 2017 10:15 pm

I'm using a Samsung Chromebook (the first one, snow something...)

$ uname -a
Linux alarm 3.8.11-4-ARCH #1 SMP Sat Oct 22 11:59:55 MDT 2016 armv7l GNU/Linux
RMJ
 
Posts: 29
Joined: Fri May 05, 2017 9:32 pm

Re: [!] Python 2.7 is broken

Postby Polichronucci » Sat May 06, 2017 10:26 am

I can reproduce this on the cubox-i4.

Code: Select all
$ uname -r
3.14.79-1-ARCH

$ python2 -c "import random"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/random.py", line 885, in <module>
    _inst = Random()
  File "/usr/lib/python2.7/random.py", line 97, in __init__
    self.seed(x)
  File "/usr/lib/python2.7/random.py", line 113, in seed
    a = long(_hexlify(_urandom(2500)), 16)
OSError: [Errno 38] Function not implemented


Falling back to python2-2.7.13-1-armv7h.pkg.tar.xz fixes the issue but raises another. Maybe this is off-topic but here's the error.

Code: Select all
$ python2 -c "import hashlib"
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Polichronucci
 
Posts: 31
Joined: Wed Oct 09, 2013 10:47 am

Re: [!] Python 2.7 is broken

Postby rcf » Sat May 06, 2017 9:32 pm

I can't get a debug build of python2 (due to the issue), so I can't find the specific cause with any certainty, but ultimately the problem is that /usr/lib/python2.7/random.py relies solely on NotImplementedError to select alternative implementations while low-level code somewhere else assumes the user will check for ENOSYS via OSError. As such, a quick-and-dirty workaround is to replace both instances of
Code: Select all
except NotImplementedError:

in random.py with
Code: Select all
except (NotImplementedError, OSError):
rcf
 
Posts: 3
Joined: Sat May 06, 2017 8:47 pm

Re: [!] Python 2.7 is broken

Postby steals » Sun May 07, 2017 7:49 am

The same error on Odroid C1 (3.10.104-11-ARCH #1 SMP PREEMPT Thu Mar 23 20:57:50 MDT 2017 armv7l GNU/Linux)
And here is another thread about this error (with no fixes :( ) viewtopic.php?f=15&t=11647


Tried dirty hack suggested in previous post, but after applying it mopidy still fails with following error:
Code: Select all
File "/usr/lib/python2.7/multiprocessing/process.py", line 309, in __init__
  self._authkey = AuthenticationString(os.urandom(32))
OSError: [Errno 38] Function not implemented
steals
 
Posts: 6
Joined: Tue Sep 06, 2016 12:55 pm

Re: [!] Python 2.7 is broken

Postby mhf » Mon May 08, 2017 11:05 am

i'm also getting errors using seafile on odroid c1 (Kernel 3.10)

Code: Select all
seaf-cli start
Traceback (most recent call last):
File "/usr/bin/seaf-cli", line 82, in <module>
import urllib2
File "/usr/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "/usr/lib/python2.7/random.py", line 885, in <module>
_inst = Random()
File "/usr/lib/python2.7/random.py", line 97, in __init__
self.seed(x)
File "/usr/lib/python2.7/random.py", line 113, in seed
a = long(_hexlify(_urandom(2500)), 16)
OSError: [Errno 38] Function not implemented
mhf
 
Posts: 6
Joined: Tue Dec 13, 2016 7:21 pm

Re: [!] Python 2.7 is broken

Postby rcf » Mon May 08, 2017 2:47 pm

Having delved into the actual cpython source, the issue seems to stem from the fact that getentropy() is not implemented, yet configure thinks it is and defines PY_GETENTROPY anyway. The proper fix at this point would be to patch configure.ac in the cpython source to use something like
Code: Select all
#include <unistd.h>

int main()
{
        char buf;
        return getentropy(&buf,1);
}

instead of trusting the defintion as it does now.
rcf
 
Posts: 3
Joined: Sat May 06, 2017 8:47 pm

Re: [!] Python 2.7 is broken

Postby RMJ » Mon May 08, 2017 7:17 pm

Great.

So... how does the package mantainer knows about what we're discussing?


EDIT:
I downgraded it and am currently ignoring it's upgrade with:

As a general follow up here's why I did until waiting the fix:
Code: Select all
$ cd /var/cache/pacman/pkg/
$ sudo pacman -U python2-2.7.13-1-armv7h.pkg.tar.xz
$ sudo pacman -Syu --ignore python2
RMJ
 
Posts: 29
Joined: Fri May 05, 2017 9:32 pm

Re: [!] Python 2.7 is broken

Postby mhf » Mon May 15, 2017 5:45 pm

Downgrading to python2-2.7.13-1-armv7h.pkg.tar.xz works. I can run my programs but i get lots of error messages:

ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
File "/usr/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
mhf
 
Posts: 6
Joined: Tue Dec 13, 2016 7:21 pm

Next

Return to ARMv7h

Who is online

Users browsing this forum: No registered users and 3 guests