Skip to content
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

Internal assertion error on ...-elided traceback blocks #69

Closed
Zac-HD opened this issue Jan 5, 2021 · 3 comments · Fixed by #71
Closed

Internal assertion error on ...-elided traceback blocks #69

Zac-HD opened this issue Jan 5, 2021 · 3 comments · Fixed by #71
Labels
bug Something isn't working

Comments

@Zac-HD
Copy link

Zac-HD commented Jan 5, 2021

$ blacken-docs t.rst
Traceback (most recent call last):
  File "/tmp/c/venv/bin/blacken-docs", line 8, in <module>
    sys.exit(main())
  File "/tmp/c/venv/lib/python3.8/site-packages/blacken_docs.py", line 210, in main
    retv |= format_file(filename, black_mode, skip_errors=args.skip_errors)
  File "/tmp/c/venv/lib/python3.8/site-packages/blacken_docs.py", line 166, in format_file
    new_contents, errors = format_str(contents, black_mode)
  File "/tmp/c/venv/lib/python3.8/site-packages/blacken_docs.py", line 155, in format_str
    src = RST_PYCON_RE.sub(_rst_pycon_match, src)
  File "/tmp/c/venv/lib/python3.8/site-packages/blacken_docs.py", line 131, in _rst_pycon_match
    assert fragment is not None
AssertionError
.. code-block:: pycon

    >>> 1/0
    Traceback (most recent call last):
        ...
    ZeroDivisionError: division by zero

https://github.com/asottile/blacken-docs/blob/master/blacken_docs.py#L130-L134

            if continuation_match:
                assert fragment is not None
                fragment += line[continuation_match.end():] + '\n'
            else:
                finish_fragment()

I think this could just translate to if continuation_match and fragment is not None: so that ... lines in output are not treated as continuations.

@asottile asottile added the bug Something isn't working label Jan 5, 2021
@asottile
Copy link
Contributor

asottile commented Jan 5, 2021

@jdufresne this one too <3

@Zac-HD
Copy link
Author

Zac-HD commented Jan 5, 2021

That's all I've found lately 🙂

@jdufresne
Copy link
Contributor

Thanks again for the report and nice catch! I agree with the fix you've presented. I've packaged it in PR #71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants