Commits

Jason R. Coombs committed 17ccff4

Replaced overly-specific error messages with more general ones for improved cross-implementation compatibility. Fixes #50.

Comments (0)

Files changed (3)

   `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
     """
     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
 
 

tests/api_tests.txt

     Comparison or logical expression expected
 
     >>> print(im("sys_platform=="))
-    unexpected EOF while parsing
+    invalid syntax
 
     >>> print(im("sys_platform=='win32'"))
     False
     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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.