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

[bug] Warnings from Python libraries pollute json output #17462

Closed
jasal82 opened this issue Dec 13, 2024 · 3 comments · Fixed by #17507
Closed

[bug] Warnings from Python libraries pollute json output #17462

jasal82 opened this issue Dec 13, 2024 · 3 comments · Fixed by #17507
Assignees

Comments

@jasal82
Copy link
Contributor

jasal82 commented Dec 13, 2024

Describe the bug

Conan 2

How to reproduce it

We're using the parameter --format json when running conan create to get some information about the build. The output is redirected into a file using > buildinfo.json. The problem is now that when an internally used library like urllib emits warnings to stdout this output ends up in the json file, making it invalid. We stumbled across this bug after updating to Python 3.11 and a new urllib version which now prints warnings whenever a conanfile performs a download with verify=False.

My suggestion would be to change the --format json parameter to --json <filename> and write only the json data to the specified file.

@czoido czoido self-assigned this Dec 13, 2024
@czoido
Copy link
Contributor

czoido commented Dec 16, 2024

Hi @jasal82,

Thanks a lot for your question.

I was trying to check the issue reproducing it but it seems that the logs from urlib3 are not polluting the stdout for me.
We have specifically a line in Conan to avoid this here:

logging.captureWarnings(True)
as suggested in the urlib3 docs: https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning

Could you please guide me to try to reproduce the issue?

@memsharded
Copy link
Member

#17507 adds a new --output-file to enforce writing the result in that file irrespective of the stdout redirections or other possible issues. It will be in next Conan 2.12. Thanks for the feedback!

@jasal82
Copy link
Contributor Author

jasal82 commented Jan 16, 2025

Thank you

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

Successfully merging a pull request may close this issue.

3 participants