Commit b383fe31 authored by Jason R. Coombs's avatar Jason R. Coombs

Replaced overly-specific error messages with more general ones for improved...

Replaced overly-specific error messages with more general ones for improved cross-implementation compatibility. Fixes #50.
parent 4b432e0f
......@@ -11,6 +11,8 @@ CHANGES
`pkg_resources.invalid_marker`. Any clients depending on the specific
string representation of exceptions returned by that function may need to
be updated to account for this change.
* Issue #50: SyntaxErrors generated by `pkg_resources.invalid_marker` are
normalized for cross-implementation consistency.
-----
0.9.8
......
......@@ -1271,9 +1271,15 @@ def normalize_exception(exc):
"""
Given a SyntaxError from a marker evaluation, normalize the error message:
- Remove indications of filename and line number.
- Replace platform-specific error messages with standard error messages.
"""
subs = {
'unexpected EOF while parsing': 'invalid syntax',
'parenthesis is never closed': 'invalid syntax',
}
exc.filename = None
exc.lineno = None
exc.msg = subs.get(exc.msg, exc.msg)
return exc
......
......@@ -342,7 +342,7 @@ Environment Markers
Comparison or logical expression expected
>>> print(im("sys_platform=="))
unexpected EOF while parsing
invalid syntax
>>> print(im("sys_platform=='win32'"))
False
......@@ -354,7 +354,7 @@ Environment Markers
Comparison or logical expression expected
>>> print(im("(extra"))
unexpected EOF while parsing
invalid syntax
>>> print(im("os.open('foo')=='y'"))
Language feature not supported in environment markers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment