After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 334548 - Proper use of PyTuple and PyList for return values
Proper use of PyTuple and PyList for return values
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other Linux
: Normal enhancement
: 0.10.5
Assigned To: GStreamer Maintainers
Johan (not receiving bugmail) Dahlin
Depends on:
Blocks:
 
 
Reported: 2006-03-14 15:38 UTC by Edward Hervey
Modified: 2006-07-03 09:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proper use of PyTuple and PyList in return values of overrides. (16.79 KB, patch)
2006-03-14 15:39 UTC, Edward Hervey
none Details | Review
same patch with function names (17.84 KB, patch)
2006-03-14 15:43 UTC, Edward Hervey
none Details | Review
Johan Dahlin's patch (18.45 KB, patch)
2006-03-14 16:24 UTC, Edward Hervey
none Details | Review

Description Edward Hervey 2006-03-14 15:38:31 UTC
PyTuple should be used for immutable collection of different type of objects, whereas PyList should be used for mutable collection of same type of objects.

See http://www.python.org/doc/faq/general/#why-are-there-separate-tuple-and-list-data-types
for more explanation.
Comment 1 Edward Hervey 2006-03-14 15:39:13 UTC
Created attachment 61235 [details] [review]
Proper use of PyTuple and PyList in return values of overrides.
Comment 2 Edward Hervey 2006-03-14 15:43:58 UTC
Created attachment 61236 [details] [review]
same patch with function names
Comment 3 Andy Wingo 2006-03-14 16:12:42 UTC
I think this is fine. These functions all belong to the class that is usually used like "foo, bar = do_baz()", so you never see the actual object anyway. I don't see a problem with this change.
Comment 4 Edward Hervey 2006-03-14 16:21:20 UTC
Delaying this to after release and should use attached patch by johan that uses Py_BuildValue but that wasn't tested.
Comment 5 Edward Hervey 2006-03-14 16:24:26 UTC
Created attachment 61237 [details] [review]
Johan Dahlin's patch

Better version using Py_BuildValue, has to be reviewed and tested for refcount issues.
Comment 6 Edward Hervey 2006-07-03 09:02:00 UTC
2006-07-03  Johan Dahlin  <jdahlin@async.com.br>

        reviewed by: Edward Hervey  <edward@fluendo.com>

        * gst/gstelement.override:
        * gst/gstevent.override:
        * gst/gstmessage.override:
        * gst/gstpad.override:
        * gst/gstquery.override:
        Use Py_BuildValue to construct tuples.
        Use tuples for collection of different objects.
        See http://www.python.org/doc/faq/general/#why-are-there-separate-tuple-and-list-data-types
        * testsuite/test_event.py:
        [message|query|event].parse_* now return tuples and not list.

        Fixes #334548