Bug 625484 - PyGobject does not know how to convert GType paramspec for class properties
PyGobject does not know how to convert GType paramspec for class properties
Product: Fedora
Classification: Fedora
Component: pygobject2 (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Colin Walters
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2010-08-19 11:21 EDT by Daniel Berrange
Modified: 2012-08-16 17:20 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-08-16 17:20:27 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Special case GType conversion (1.20 KB, patch)
2010-09-05 12:55 EDT, Daniel Berrange
no flags Details | Diff

  None (edit)
Description Daniel Berrange 2010-08-19 11:21:06 EDT
Description of problem:
I have a GObject subclass which registers a property called 'result-type' which accepts a GType as its value. At the C level it is declared with

                                                       "Result type",
                                                       "The command result type",
                                                       G_PARAM_READABLE |
                                                       G_PARAM_WRITABLE |
                                                       G_PARAM_CONSTRUCT_ONLY |
                                                       G_PARAM_STATIC_NAME |
                                                       G_PARAM_STATIC_NICK |

Attempting it instantiate an instance of the class, in python, passing in the 'result-type' property value to the constructor:

        LibvirtShell.Command.__init__(self, name="foo", result_type=gobject.GObject.__gtype__)

fails with:

  Traceback (most recent call last):
    File "./plugins/pythonhello/pythonhello.py", line 36, in do_activate
    File "./plugins/pythonhello/pythonhello.py", line 17, in __init__
      LibvirtShell.Command.__init__(self, name="foo", result_type=gobject.GObject.__gtype__)
  TypeError: could not convert value for property `result_type'

Python definitely knows that I am passing a GType instance:

       # print str(gobject.GObject.__gtype__)
       <GType GObject (80)>

Using set_property:

        self.set_property("result-type", gobject.GObject.__gtype__)

Gives a slightly different message:

Traceback (most recent call last):
  File "./plugins/pythonhello/pythonhello.py", line 36, in do_activate
  File "./plugins/pythonhello/pythonhello.py", line 20, in __init__
    self.set_property("result-type", gobject.GObject.__gtype__)
TypeError: could not convert argument to correct param type

Version-Release number of selected component (if applicable):

How reproducible:
Always for properties whose value is a GType

Steps to Reproduce:
1. See above example class property
2. Attempt to set the property from python
Actual results:

Expected results:

Additional info:
Comment 1 Daniel Berrange 2010-09-05 12:55:56 EDT
Created attachment 443173 [details]
Special case GType conversion

The problem methods are appear to be pyg_value_from_pyobject and pyg_value_to_pyobject, which don't handle G_TYPE_GTYPE correctly. G_TYPE_GTYPE inherits from G_TYPE_POINTER, but the case statement for G_TYPE_POINTER can't cope with G_TYPE_GTYPE data. This patch adds two special cases for G_TYPE_GTYPE.
I'm not sure this is the right way to approach it, but it makes it does seem to make things work for my app's needs.
Comment 2 Fedora End Of Life 2012-08-16 17:20:29 EDT
This message is a notice that Fedora 14 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 14. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained.  At this time, all open bugs with a Fedora 'version'
of '14' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this 
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen 
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we were unable to fix it before Fedora 14 reached end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" (top right of this page) and open it against that 
version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Note You need to log in before you can comment on or make changes to this bug.