diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-08-09 22:45:59 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-08-09 22:45:59 -0400 |
commit | 4b432e0f50e9f5871a2f7375b406be7258bfa22c (patch) | |
tree | b054a4b3502a8ab6a68feec89822644919d41483 /pkg_resources.py | |
parent | f3f0c144dcfec41924e2e3eac3cbbaa81cb53819 (diff) | |
download | external_python_setuptools-4b432e0f50e9f5871a2f7375b406be7258bfa22c.tar.gz external_python_setuptools-4b432e0f50e9f5871a2f7375b406be7258bfa22c.tar.bz2 external_python_setuptools-4b432e0f50e9f5871a2f7375b406be7258bfa22c.zip |
Issue 50: Removed filename and line number from SyntaxErrors returned by invalid_marker. This change simplifies the test and paves the way for supporting PyPy.
Diffstat (limited to 'pkg_resources.py')
-rw-r--r-- | pkg_resources.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index 36a0e6ed..7c3bdccd 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -1267,12 +1267,22 @@ def _pyimp(): else: return 'CPython' +def normalize_exception(exc): + """ + Given a SyntaxError from a marker evaluation, normalize the error message: + - Remove indications of filename and line number. + """ + exc.filename = None + exc.lineno = None + return exc + + def invalid_marker(text): """Validate text as a PEP 426 environment marker; return exception or False""" try: evaluate_marker(text) except SyntaxError: - return sys.exc_info()[1] + return normalize_exception(sys.exc_info()[1]) return False def evaluate_marker(text, extra=None, _ops={}): |