[Python-Dev] check for PyUnicode_READY look backwards (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Thu Oct 6 23:40:36 CEST 2011
- Previous message: [Python-Dev] check for PyUnicode_READY look backwards
- Next message: [Python-Dev] check for PyUnicode_READY look backwards
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 6 Oct 2011 17:40:20 -0400 Nick Coghlan <ncoghlan at gmail.com> wrote:
On Thu, Oct 6, 2011 at 4:47 PM, Benjamin Peterson <benjamin at python.org> wrote: > Amaury Forgeot d'Arc <amauryfa gmail.com> writes: > >> I'd prefer it was written : >> if (PyUnicodeREADY(*filename) < 0)_ _>> because "< 0" clearly indicates an error condition._ _> > Why not just have it return 0 on error? This would be more consistent with API > functions that return "false" values like NULL and would just be > > if (!PyUnicodeREADY(s)) return NULL; > > in code.
Alas, that isn't the convention in C - courtesy of Unix, the convention is that for integer return codes, "0" means success.
C is quite inconsistent, and so is our own C API.
if (PyUnicode_READY(s)) { ...}
definitely looks like the code block will be executed if the unicode string is ready, though.
Regards
Antoine.
- Previous message: [Python-Dev] check for PyUnicode_READY look backwards
- Next message: [Python-Dev] check for PyUnicode_READY look backwards
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]