Skip to content

use PySys_WriteStderr instead of eprintln - #6261

Open
Person-93 wants to merge 7 commits into
PyO3:mainfrom
Person-93:no_std_err_output
Open

use PySys_WriteStderr instead of eprintln#6261
Person-93 wants to merge 7 commits into
PyO3:mainfrom
Person-93:no_std_err_output

Conversation

@Person-93

Copy link
Copy Markdown
Contributor

This is part of the WIP no_std support.

There are two places that were using the eprintln macro, this replaces them with a safe wrapper around PySys_WriteStderr.

This is arguably not a purely internal change. If this PR is merged, those error messages will be redirected (along with all other error output) if the user redirects Python's stderr. Maintainers, please let me know if this needs a news fragment and if it does, if it should be a fix or a change.

@Person-93
Person-93 force-pushed the no_std_err_output branch from 5a61e71 to ef75e64 Compare July 29, 2026 23:06
@Person-93
Person-93 force-pushed the no_std_err_output branch from ef75e64 to 3e3cbc2 Compare July 29, 2026 23:31

@Tpt Tpt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainers, please let me know if this needs a news fragment and if it does, if it should be a fix or a change.

Yes, would be great! A "change" looks like the most appropriate to me but I do not have a strong opinion

Comment thread src/conversions/jiff.rs
Comment thread src/internal/stdio.rs Outdated
@Person-93 Person-93 changed the title internal: use PySys_WriteStderr instead of eprintln use PySys_WriteStderr instead of eprintln Jul 31, 2026
@Person-93

Copy link
Copy Markdown
Contributor Author

After reviewing Icxolu's comment, I don't think calling python API to write to stderr is valid during GC traversal, so I changed it to use libc::write.

@codspeed-hq

codspeed-hq Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 140 untouched benchmarks


Comparing Person-93:no_std_err_output (965171d) with main (bdc49a7)

Open in CodSpeed

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.

3 participants