You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`SystemError.from_errno` calls `Errno.value` to retrieve the system error value from the last lib call.
But this happens in the body of the method which only executes after its arguments are evaluated (for example building the error message). This can lead to a change in `Errno.value` which `.from_errno` would then mistake for the original error.
In order to fix this, we must query `Errno.value` immediately after the lib call.
Changing `.from_errno` into a macro achieves that because it expands into a call to `Errno.value` before constructing the actual error object and its arguments.
We need to change the deprecated `from_errno` method which receives an `Errno` value as well because the macro would shadow the method.
One downside of the macro approach is that it won't work with file-private error types (#15496 (comment)). But this is probably not a very relevant use case.
0 commit comments