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 551056 - make codegen not import when corresponding argument types are not registered
make codegen not import when corresponding argument types are not registered
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: codegen
Git master
Other All
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2008-09-05 22:37 UTC by Paul Pogonyshev
Modified: 2008-09-08 20:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
conditional importing in .override files (2.84 KB, patch)
2008-09-05 22:39 UTC, Paul Pogonyshev
reviewed Details | Review
correct patch (2.57 KB, patch)
2008-09-07 22:14 UTC, Paul Pogonyshev
committed Details | Review

Description Paul Pogonyshev 2008-09-05 22:37:25 UTC
In bug 550754 PyGTK needs to import 'gio-types.defs' and use those types for generating various wrappers.  However, that file is not always present as PyGObject can be build without GIO.  And anyway, we might later come into situation when PyGObject doesn't define certain types (because GLib is too old), but e.g. PyGTK optionally needs them for wrappers.

Patch follows.
Comment 1 Paul Pogonyshev 2008-09-05 22:39:50 UTC
Created attachment 118127 [details] [review]
conditional importing in .override files

This patch adds featurer to import in .override files conditionally.  If importing line looks like

import python_type as c_name for arg_type

then importing is done only if arg_type is registered (as usually done in *-types.defs).  For existing imports this makes no changes at all.
Comment 2 Johan (not receiving bugmail) Dahlin 2008-09-07 21:54:58 UTC
Comment on attachment 118127 [details] [review]
conditional importing in .override files

>Index: codegen/codegen.py
>+        # All conditionals must go first.
>+        if command in ('ifdef'):

You probably meant == 'ifdef

Rest looks good
Comment 3 Paul Pogonyshev 2008-09-07 22:14:30 UTC
Created attachment 118260 [details] [review]
correct patch

Sorry, that was a wrong patch.  It doesn't do what it should...  This is the correct one.
Comment 4 Paul Pogonyshev 2008-09-08 20:26:40 UTC
Sending        ChangeLog
Sending        codegen/codegen.py
Sending        codegen/override.py
Transmitting file data ...
Committed revision 967.

2008-09-08  Paul Pogonyshev  <pogonyshev@gmx.net>

	Bug 551056 – make codegen not import when corresponding argument
	types are not registered

	* codegen/override.py (import_pat): Add support for optional 'for'
	clause.
	(Overrides.__parse_override): Handle it.

	* codegen/codegen.py (SourceWriter.write_imports)
	(SourceWriter.write_object_imports): Adapt for changes in
	get_imports() return value.
	(is_registered_object): New function.