When run in a chroot, pypy will sometimes fail to import builtin modules
Created originally on Bitbucket by JakobKrainz
When running in a chroot where $HOME is not set and /etc/passwd does not contain an entry for the current UID, pypy 2.4.0 will fail to import some builtin modules.
More precisely, the script
#!python
a = raw_input()
b = raw_input()
n = a.count("x")
for x in range(n + 4):
if eval(a, dict(x=x)) != eval(b, dict(x=x)):
print "NOT EQUIVALENT"
exit()
print "EQUIVALENT"
will produce the following output:
'import site' failed
Traceback (most recent call last):
File "app_main.py", line 75, in run_toplevel
File "K.py", line 9, in <module>
exit()
NameError: global name 'exit' is not defined
Adding the current user to /etc/passwd or setting $HOME fixes this.