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

encode str into bytes for _lookup_ctag argument; #1724

Merged
merged 1 commit into from
May 2, 2021

Conversation

cykerway
Copy link
Contributor

check source code of python-ctags and python-ctags3 to see what
argument type is expected (answer: char *);

guess this is python 2 legacy; but now it should work in python 3;

check source code of `python-ctags` and `python-ctags3` to see what
argument type is expected (answer: `char *`);

guess this is python 2 legacy; but now it should work in python 3;
@Anteru
Copy link
Collaborator

Anteru commented Feb 27, 2021

Could you please add a test case exercising this path? I've got no idea where this is triggered :)

@cykerway
Copy link
Contributor Author

I just ran the shipped test file tests/test_html_formatter.py and it failed.

def test_ctags():
    try:
        import ctags
    except ImportError:
        # we can't check without the ctags module, but at least check the exception
        assert pytest.raises(
            RuntimeError, HtmlFormatter, tagsfile='support/tags'
        )
    else:
        # this tagfile says that test_ctags() is on line 165, even if it isn't
        # anymore in the actual source
        fmt = HtmlFormatter(tagsfile='support/tags', lineanchors='L',
                            tagurlformat='%(fname)s%(fext)s')
        outfile = StringIO()
        fmt.format(tokensource, outfile)
        assert '<a href="test_html_formatter.py#L-165">test_ctags</a>' \
            in outfile.getvalue()

You can probably debug if the problematic value in html.py has type str or bytes. It's str on my machine and that caused the error.

@Anteru Anteru added this to the 2.9 milestone May 2, 2021
@Anteru Anteru merged commit 30cfa26 into pygments:master May 2, 2021
@Anteru
Copy link
Collaborator

Anteru commented May 2, 2021

Thanks, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants