^- PyTuple_SET_ITEM doesn't INCREF, it 'steals' a reference. This is ok
for 'as_tuple' because you are transferring ownership from
StaticTuple_as_tuple. However it is not ok for StaticTuple_Type. So you
just need to add
Py_INCREF(&StaticTuple_Type)
I think it would probably also be good to test that pickling a nested
StaticTuple works, but otherwise this looks good to me. (as long as we
add the one Py_INCREF call.)
review: approve
merge: approve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Matt Nordhoff wrote: bzr.mattnordhof f.com/loggerhea d/bzr/statictup le-pickling/ changes bzr.mattnordhof f.com/bzr/ bzr/statictuple -pickling/ statictuple- pickling- r4778.patch
> Matt Nordhoff has proposed merging lp:~mnordhoff/bzr/statictuple-pickling into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
>
> This adds pickling support to StaticTuple.
>
> Before this, I had written approximately 4 lines of C in my life, and had never used Python's C API. Please review it carefully. I think I actually have the error handling and reference counting right, but I really can't be sure.
>
> The Launchpad mirror for this branch is not up-to-date. Please get an up-to-date copy from my website, or look at my Loggerhead or a diff I made:
>
> http://
> http://
>
>
static PyObject * reduce( StaticTuple *self) as_tuple( self); SET_ITEM( result, 0, (PyObject *)&StaticTuple_ Type); SET_ITEM( result, 1, as_tuple);
+StaticTuple_
+{
+ PyObject *result = NULL, *as_tuple = NULL;
+
+ result = PyTuple_New(2);
+ if (!result) {
+ return NULL;
+ }
+ as_tuple = StaticTuple_
+ if (as_tuple == NULL) {
+ Py_DECREF(result);
+ return NULL;
+ }
+ PyTuple_
+ PyTuple_
+ return result;
+}
^- PyTuple_SET_ITEM doesn't INCREF, it 'steals' a reference. This is ok as_tuple. However it is not ok for StaticTuple_Type. So you
for 'as_tuple' because you are transferring ownership from
StaticTuple_
just need to add
Py_INCREF( &StaticTuple_ Type)
I think it would probably also be good to test that pickling a nested
StaticTuple works, but otherwise this looks good to me. (as long as we
add the one Py_INCREF call.)
review: approve enigmail. mozdev. org/
merge: approve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkr fSSkACgkQJdeBCY SNAAN71gCg0Rnh2 IJRMr5cjnTO0shD 0wpz vg+9X9U0OLR08sa z7
CHQAoIA72B56GWB
=MCX3
-----END PGP SIGNATURE-----