-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Replace 'cstderr.rawWrite' with 'writeToStdErr' #17288
Conversation
I'm not sure if these failed checks are related? |
@@ -42,7 +48,7 @@ elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript): | |||
add(buf, " [") | |||
add(buf, name exceptn) | |||
add(buf, "]\n") | |||
cstderr.rawWrite buf | |||
writeFatalErr(buf.cstring, buf.len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writeFatalErr(buf.cstring, buf.len) | |
writeToStdErr buf |
I don't think there's a need to introduce writeFatalErr
, instead writeToStdErr
should be made to work cross platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to reuse writeToStdErr
but I couldn't find an elegant way to do it, writeToStdErr
is mostly used in files that are include
ed into system.nim
, and as I recall system/fatal
is imported or included in multiple locations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's fixable, once you fix the other points i can look into how to fix that
@@ -551,6 +551,10 @@ when notJSnotNims and not defined(nimSeqsV2): | |||
when notJSnotNims: | |||
include "system/hti" | |||
|
|||
proc writeToStdErr(msg: cstring, length: int) | |||
proc writeToStdErr(msg: cstring) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about:
proc writeToStdErr(msg: cstring) {.inlnie.} =
writeToStdErr(msg, msg.len)
that way, no need to define this overload proc writeToStdErr(msg: cstring)
on each platform
@@ -551,6 +551,10 @@ when notJSnotNims and not defined(nimSeqsV2): | |||
when notJSnotNims: | |||
include "system/hti" | |||
|
|||
proc writeToStdErr(msg: cstring, length: int) | |||
proc writeToStdErr(msg: cstring) | |||
proc writeToStdErr(msg: string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, this could be defined directly as:
proc writeToStdErr(msg: string) {.inline.} =
writeToStdErr(msg.cstring, msg.len)
that way, the only proc to define on each platform is proc writeToStdErr(msg: cstring, length: int)
@@ -551,6 +551,10 @@ when notJSnotNims and not defined(nimSeqsV2): | |||
when notJSnotNims: | |||
include "system/hti" | |||
|
|||
proc writeToStdErr(msg: cstring, length: int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if these failed checks are related?
most likely related, and you should be able to reproduce the bug locally with smthg like
testament pcat dll
or similar (these are the failing tests in CI i see)
Use a procedure that is easy to replace on platforms without native UNIX file descriptors.
I'm not happy with this patch. Its hard to know where define |
Why not add it to |
Would this only be valid for C-comptible targets? This is something mostly used in the garbage collector. If it was to go into |
ansi_c.nim would contain the default implementation, you can re-define it with this pattern: when not declared(writeError):
proc writeError() = ...
|
ping @ehmry this is a good PR, please continue if you can! |
I don't know the code here well enough to make this change in a way that improves its quality, and I don't think I'm in a position to catch regressions. It would be a welcome improvement, but not something that I have problem with at the moment. |
Use a procedure that is easy to replace on platforms without native UNIX file descriptors.
(#17268 reattempt)
future work