GNOME Bugzilla – Bug 705451
pyg_pid_new does not work on python 3.(3)
Last modified: 2013-08-05 23:21:49 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.
Just tried this: In [21]: GLib.Pid.__new__(GLib.Pid, 100) Out[21]: 0 So obviously, it is not working :-/
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.
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.
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.
Created attachment 250907 [details] [review] Create GLib.Pid in the same way on python 2 and 3
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.