Skip to content

Commit ab4b5de

Browse files
alalazotgamblin
authored andcommitted
bugfix: Python 2.6 parsing error (spack#11867)
Apparently shlex.split can't deal with unicode encoded characters in Python2.6. The solution is to convert to str before calling the function.
1 parent 172fcb0 commit ab4b5de

File tree

5 files changed

+4
-12
lines changed

5 files changed

+4
-12
lines changed

lib/spack/spack/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def expect(self, id):
143143

144144
def setup(self, text):
145145
if isinstance(text, string_types):
146-
text = shlex.split(text)
146+
text = shlex.split(str(text))
147147
self.text = text
148148
self.push_tokens(self.lexer.lex(text))
149149

lib/spack/spack/test/cmd/release_jobs.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#
44
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
55

6-
import pytest
7-
86
import json
9-
import sys
107

118
from jsonschema import validate
129

@@ -39,11 +36,6 @@ def test_specs_deps(tmpdir, config):
3936
validate(deps_object, specs_deps_schema)
4037

4138

42-
@pytest.mark.skipif(
43-
sys.version_info[:2] < (2, 7),
44-
reason="For some reason in Python2.6 we get a utf-32 string "
45-
"that can't be parsed"
46-
)
4739
def test_specs_staging(config):
4840
"""Make sure we achieve the best possible staging for the following
4941
spec DAG::

lib/spack/spack/test/spec_syntax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def check_parse(self, expected, spec=None):
9797

9898
def check_lex(self, tokens, spec):
9999
"""Check that the provided spec parses to the provided token list."""
100-
spec = shlex.split(spec)
100+
spec = shlex.split(str(spec))
101101
lex_output = sp.SpecLexer().lex(spec)
102102
for tok, spec_tok in zip(tokens, lex_output):
103103
if tok.type == sp.ID or tok.type == sp.VAL:

lib/spack/spack/util/editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _find_exe_from_env_var(var):
4141
return None, []
4242

4343
# split env var into executable and args if needed
44-
args = shlex.split(exe)
44+
args = shlex.split(str(exe))
4545
if not args:
4646
return None, []
4747

lib/spack/spack/util/executable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Executable(object):
2020
"""Class representing a program that can be run on the command line."""
2121

2222
def __init__(self, name):
23-
self.exe = shlex.split(name)
23+
self.exe = shlex.split(str(name))
2424
self.default_env = {}
2525
self.returncode = None
2626

0 commit comments

Comments
 (0)