| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…_` is set to `None`
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…ests fail elsewhere
There was a problem hiding this comment.
Thanks so much for looking at this :)
Sorry, something went wrong.
|
|
||
| func = _PyObject_LookupSpecial(o, &_Py_ID(__fspath__)); | ||
| if (NULL == func) { | ||
| if ((NULL == func) || (func == Py_None)) { |
There was a problem hiding this comment.
A few thoughts, no change requested:
Sorry, something went wrong.
There was a problem hiding this comment.
- The NULL == func here is a "Yoda condition". People write that because C lets you write if (func = NULL), and it doesn't do what you want (it always sets func to NULL).
Thanks for explaining this! I wondered what the rationale was here for writing it like this!
- There is a Py_IsNone function (https://docs.python.org/3/c-api/structures.html#c.Py_IsNone) that could be used instead of == Py_None. I think the motivation is to allow alternate C APIs where Py_None might not be a singleton.
Huh. I checked the API docs for Py_None before filing this PR, and they didn't mention this function — they recommended using ==: https://docs.python.org/3/c-api/none.html. I guess I'll leave this as it is for now, since as you say, there are a bunch of other places in this file that use == :)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #106046