-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue recognizing my docstring #106
Comments
Thanks for the report! This is definitely a bug. FWIW if you move the statements to newlines, the syntax error goes away:
But the example you provided is valid Python syntax, so I'll look into why it thinks there is an error. If the body of the function isn't too complicated do you mind sharing it? I'd also like to check that the traceback is correctly matched. I don't often use the exception checker (usually I would just import pytest and do a |
Sure, but my compressed code style is probably not very test-case worthy:
|
@ArneBachmannDLR I've looked into this a little bit. This is a tricky issue. It won't be a quick fix. As a very immediate workaround you can just change the second The fundamental issue is that this piece of code errors: compile('try: raise Exception\nexcept Exception: pass', mode='single', filename="") With
Note that the following variations do not error: compile('try: raise Exception\nexcept Exception: pass', mode='exec', filename="")
compile('try:\n raise Exception\nexcept Exception:\n pass', mode='single', filename="")
compile('try:\n raise Exception\nexcept Exception:\n pass', mode='exec', filename="") So I'm wondering if this is an actual honest-to-goodness CPython bug (this wouldn't be the first time I've run into one working on this project). It's very strange that the version of this statement with newlines and indentation works correctly, but the concise version does not in the builtin python compile function. Normally, xdoctest just uses I could just put a workaround in that switches to EDIT: It is not a CPython bug: As the docs state: https://docs.python.org/3/library/functions.html#compile "When compiling a string with multi-line code in 'single' or 'eval' mode, input must be terminated by at least one newline character. This is to facilitate detection of incomplete and complete statements in the code module" |
So, maybe it wont take that long after all. The PR with a fix is up: #107 The basic change is that any doctest part that is asked to be compiled in single mode ensures that it adds an extra newline at the end of it's source. |
Awesome! |
This should be fixed in the released 0.15.9. Please let me know if there is still an issue. |
Thanks, great work! I can finally see |
For the following docstring I get an error:
Error:
The text was updated successfully, but these errors were encountered: