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

Lexer "python3" in --pastebin feature causes HTTP errors #5806

Closed
goerz opened this issue Aug 30, 2019 · 3 comments

Comments

@goerz
Copy link
Contributor

commented Aug 30, 2019

The --pastebin option currently submits the output of pytest to bpaste.net using lexer=python3:

params = {"code": contents, "lexer": "python3", "expiry": "1week"}
url = "https://bpaste.net"
try:
response = (
urlopen(url, data=urlencode(params).encode("ascii")).read().decode("utf-8")
)

For some contents, this will raise a "HTTP Error 400: Bad Request".

As an example:

>>> from urllib.request import urlopen
>>> with open("data.txt", "rb") as in_fh:
...     data = in_fh.read()
>>> url = "https://bpaste.net"
>>> urlopen(url, data=data)
HTTPError: Bad Request

with the attached data.txt.

This is the underlying cause for the problems mentioned in #5764.

The call goes through fine if lexer is changed from python3 to text. This would seem like the right thing to do in any case: the console output of a pytest run that is being uploaded is not Python code, but arbitrary text.

@goerz goerz self-assigned this Aug 30, 2019
goerz added a commit to goerz/pytest that referenced this issue Aug 30, 2019
@goerz goerz changed the title The --pastebin feature submits to bpaste.net with "python3" lexer instead of "text" Lexer "python3" in --pastebin feature causes HTTP errors Aug 30, 2019
goerz added a commit to goerz/pytest that referenced this issue Sep 1, 2019
@The-Compiler

This comment has been minimized.

Copy link
Member

commented Sep 9, 2019

This wasn't auto-closed as the commits didn't land in master yet - but I guess it can be closed?

@goerz

This comment has been minimized.

Copy link
Contributor Author

commented Sep 9, 2019

It could, but I figured I'd just let the auto-close happen when the commits land in master (which would be when this fix makes it into a released version). But I can close now, depending on what's your policy on these things.

@Zac-HD

This comment has been minimized.

Copy link
Member

commented Sep 13, 2019

Closing as fixed in dev branch. Thanks @goerz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.