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 705451 - pyg_pid_new does not work on python 3.(3)
pyg_pid_new does not work on python 3.(3)
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
unspecified
Other Linux
: Normal critical
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-04 15:46 UTC by Benjamin Berg
Modified: 2013-08-05 23:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (967 bytes, patch)
2013-08-05 15:16 UTC, Benjamin Berg
none Details | Review
Remove useless #if (901 bytes, patch)
2013-08-05 22:47 UTC, Benjamin Berg
none Details | Review
Create GLib.Pid in the same way on python 2 and 3 (947 bytes, patch)
2013-08-05 23:20 UTC, Simon Feltman
committed Details | Review
Use PyLong_Type.tp_new for GLib.Pid (1.45 KB, patch)
2013-08-05 23:20 UTC, Simon Feltman
committed Details | Review

Description Benjamin Berg 2013-08-04 15:46:22 UTC
On python 3.3 (debian unstable/experimental) I have the issue that GLib.spawn_async always returns zero for the pids child. The value that is passed to pyg_pid_new is correct, so obviously calling the __new__ function to set the (long) integer does not seem to be working.
Comment 1 Benjamin Berg 2013-08-04 15:49:47 UTC
Just tried this:

In [21]: GLib.Pid.__new__(GLib.Pid, 100)
Out[21]: 0

So obviously, it is not working :-/
Comment 2 Benjamin Berg 2013-08-05 15:16:37 UTC
Created attachment 250889 [details] [review]
patch

This patch simply copies tp_new from the original class over to the new class. This works fine as cpython correctly handles this subclasses inside the original new implementation.

Tested with both python 2.7.5 and 3.3.2.
Comment 3 Benjamin Berg 2013-08-05 22:47:38 UTC
Created attachment 250906 [details] [review]
Remove useless #if

It is not required to have different code for python 2 and 3 after the previous patch anymore. GLib.Pid.__new__(GLib.Pid, 10) works on both python 2 and 3.
Comment 4 Simon Feltman 2013-08-05 23:20:07 UTC
The following fixes have been pushed:
aba45eb Create GLib.Pid in the same way on python 2 and 3
2d203b7 Use PyLong_Type.tp_new for GLib.Pid

Thanks, I pushed these with an added test (verified it failed pre-patch).
Also I didn't think the comment for tp_new was needed as
that should be a fairly standard setup for sub-classing builtins.
Comment 5 Simon Feltman 2013-08-05 23:20:10 UTC
Created attachment 250907 [details] [review]
Create GLib.Pid in the same way on python 2 and 3
Comment 6 Simon Feltman 2013-08-05 23:20:12 UTC
Created attachment 250908 [details] [review]
Use PyLong_Type.tp_new for GLib.Pid

For GLib.Pid the original implementation for __new__ needs to be used,
as it is able to initialize the integer correctly.