[Python-3000] Interaction between unittest and keyword argument machinery (original) (raw)
Guido van Rossum guido at python.org
Wed Mar 7 06:32:03 CET 2007
- Previous message: [Python-3000] Interaction between unittest and keyword argument machinery
- Next message: [Python-3000] Interaction between unittest and keyword argument machinery
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3/6/07, Patrick Maupin <pmaupin at gmail.com> wrote:
It appears that if a C function is called from Python with **kwargs, a new dictionary object is created and passed to the C function even if **kwargs is empty, but if the same C function is called without **kwargs, then the NULL pointer is passed to the C function.
Because unittest always creates **kwargs, any code path in a C function which is only executed when the *keywords parameter is NULL will never be correctly tested from the standard unittest methods.
This needs some context; which call from unittest to a C function are you talking about?
doctest doesn't have this issue, but appears to be deprecated.
Far from it! Doctest is alive and well. I even used it to test the xreload module I added to Py3k. I admit that I've not been a fan of it in the past, and in many cases I will prefer unittest, but there are definitely very good reasons to support doctest. Consider it a rare deviation from TOOWTDI.
OTOH unless it would be a major performance hit to never pass empty *dictionary parameters (always use a NULL pointer) to C functions, it would remove a whole class of untested potential execution paths to change the interpreter.
You guessed it, it's a major performance hit to create a whole new dict object (even if empty) when the majority of calls don't need it. So, no, this isn't going away any time soon.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-3000] Interaction between unittest and keyword argument machinery
- Next message: [Python-3000] Interaction between unittest and keyword argument machinery
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]