Fix NUL byte error handling on Python 3.4
Looks like Python 3.4 raises TypeError and not ValueError...
This commit is contained in:
parent
d901bee88e
commit
a7d5a98cc4
@ -198,7 +198,7 @@ def read_config_py(filename=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
code = compile(source, filename, 'exec')
|
code = compile(source, filename, 'exec')
|
||||||
except ValueError as e:
|
except (ValueError, TypeError) as e:
|
||||||
# source contains NUL bytes
|
# source contains NUL bytes
|
||||||
desc = configexc.ConfigErrorDesc("Error while compiling", e)
|
desc = configexc.ConfigErrorDesc("Error while compiling", e)
|
||||||
raise configexc.ConfigFileErrors(basename, [desc])
|
raise configexc.ConfigFileErrors(basename, [desc])
|
||||||
|
@ -236,7 +236,7 @@ class TestConfigPy:
|
|||||||
|
|
||||||
assert len(excinfo.value.errors) == 1
|
assert len(excinfo.value.errors) == 1
|
||||||
error = excinfo.value.errors[0]
|
error = excinfo.value.errors[0]
|
||||||
assert isinstance(error.exception, ValueError)
|
assert isinstance(error.exception, (TypeError, ValueError))
|
||||||
assert error.text == "Error while compiling"
|
assert error.text == "Error while compiling"
|
||||||
exception_text = 'source code string cannot contain null bytes'
|
exception_text = 'source code string cannot contain null bytes'
|
||||||
assert str(error.exception) == exception_text
|
assert str(error.exception) == exception_text
|
||||||
|
Loading…
Reference in New Issue
Block a user