Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec tests fail with ASCII locale ? #12

Closed
andychu opened this issue Mar 10, 2017 · 1 comment
Closed

Spec tests fail with ASCII locale ? #12

andychu opened this issue Mar 10, 2017 · 1 comment

Comments

@andychu
Copy link
Contributor

andychu commented Mar 10, 2017

This was reported on the mailing list and also here:

https://lobste.rs/s/obktxo/oil_shell_help_needed_if_you_have_debian/comments/akvbsk#c_akvbsk

sh_spec.py needs to read with a known encoding. *.test.sh should be restricted to utf-8 ?

$ ./spec.sh all
./spec-runner.sh run-cases append 
./spec-runner.sh run-cases arith-context 
./spec-runner.sh run-cases arith 
./spec-runner.sh run-cases array 
./spec-runner.sh run-cases assign 
./spec-runner.sh run-cases assoc-zsh 
./spec-runner.sh run-cases assoc 
./spec-runner.sh run-cases blog1 
Traceback (most recent call last):
  File "./sh_spec.py", line 838, in <module>
    sys.exit(main(sys.argv))
  File "./sh_spec.py", line 766, in main
    tokens = Tokenizer(LineIter(f))
  File "./sh_spec.py", line 125, in __init__
    self.next()
  File "./sh_spec.py", line 129, in next
    self.cursor = self.it.__next__()
  File "./sh_spec.py", line 87, in LineIter
    for i, line in enumerate(f):
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 133: ordinal not in range(128)
./spec-runner.sh run-cases brace-expansion 
./spec-runner.sh run-cases bugs 
./spec-runner.sh run-cases builtins 
./spec-runner.sh run-cases case_ 
./spec-runner.sh run-cases command-sub 
./spec-runner.sh run-cases comments 
*** Got 1 allowed osh failures, exit with status 0
./spec-runner.sh run-cases dbracket 
Traceback (most recent call last):
  File "./sh_spec.py", line 838, in <module>
    sys.exit(main(sys.argv))
  File "./sh_spec.py", line 766, in main
    tokens = Tokenizer(LineIter(f))
  File "./sh_spec.py", line 125, in __init__
    self.next()
  File "./sh_spec.py", line 129, in next
    self.cursor = self.it.__next__()
  File "./sh_spec.py", line 87, in LineIter
    for i, line in enumerate(f):
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2750: ordinal not in range(128)
./spec-runner.sh run-cases dparen 
@andychu
Copy link
Contributor Author

andychu commented Jan 25, 2018

Pretty sure I fixed this recently by using an explicit .encode('utf-8').

@andychu andychu closed this as completed Jan 25, 2018
andychu pushed a commit that referenced this issue Sep 4, 2018
Now we check file descriptors (even those above #10) before using them.

This is a recurrence of the bug described here:

http://www.oilshell.org/blog/2017/07/02.html

If you do 'import random' in Python, it results in /dev/urandom being
permanently open (which can be seen in the blog post!)

At the time, I incorrectly fixed the bug by just opening our own
descriptors above #10.  But it's possible that CPython will subsequently
open something above #10 (/dev/urandom appeared as #12), so we have to
additionally check descriptors before we use them.

NOTE: 'import cgi' eventually causes 'import random'.  We're only using
it for cgi.escape(), but cgi.FieldStorage() uses tempfile, which uses a
random number generator.

Also: minimize the test case as gold/configure-bug.sh.

'test/gold.sh configure' was the case that caught this bug.  The spec
tests didn't find it!  Because it appears to take about 4 redirects for
this to happen!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant