Author pitrou
Recipients alex, pitrou, rhettinger, terry.reedy, tzot
Date 2010-10-30.18:11:04
SpamBayes Score 1.13602e-10
Marked as misclassified No
Message-id <>
Some comments about the patch:
- this seems to be some dead code:

     if (nattrs <= 1) {
         if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &attr))
             return NULL;

- you can't call PyUnicode_GET_SIZE or PyUnicode_AS_UNICODE before you have called PyUnicode_Check. If the object is not an unicode object, it triggers an assertion in debug mode:
python: ./Modules/operator.c:404: attrgetter_new: Assertion `((((((PyObject*)(item))->ob_type))->tp_flags & ((1L<<28))) != 0)' failed.

- you should also call PyUnicode_InternInPlace() on the last dotless name (after the for loop)

- this comment looks false:
  /* attrgetter_new code should ensure we never come here */

- in dotted_getattr, when attr is a tuple, you leak references to intermediate objects (because you don't decref obj before doing "newobj = obj")

Other than that, looks quite worthwhile.
Date User Action Args
2010-10-30 18:11:06pitrousetrecipients: + pitrou, rhettinger, terry.reedy, tzot, alex
2010-10-30 18:11:05pitrousetmessageid: <>
2010-10-30 18:11:04pitroulinkissue10160 messages
2010-10-30 18:11:04pitroucreate