pygobject r887 - in trunk: . glib gobject



Author: johan
Date: Sun Jul 27 10:30:30 2008
New Revision: 887
URL: http://svn.gnome.org/viewvc/pygobject?rev=887&view=rev

Log:
2008-07-27  Johan Dahlin  <johan gnome org>

    * glib/option.py:
    Remove tabs. Use sys.exc_info()[1] to fetch the exception value

    * gobject/__init__.py:
    * gobject/propertyhelper.py:
    Import gobject._gobject instead of just gobject.

    * gobject/Makefile.am:
    * gobject/constants.py.in:
    * gobject/generate-constants.c (main):
    Don't add long suffix if python >= 3.0



Modified:
   trunk/ChangeLog
   trunk/glib/   (props changed)
   trunk/glib/option.py
   trunk/gobject/Makefile.am
   trunk/gobject/__init__.py
   trunk/gobject/constants.py.in
   trunk/gobject/generate-constants.c
   trunk/gobject/propertyhelper.py

Modified: trunk/glib/option.py
==============================================================================
--- trunk/glib/option.py	(original)
+++ trunk/glib/option.py	Sun Jul 27 10:30:30 2008
@@ -34,7 +34,8 @@
 from optparse import OptParseError, OptionError, OptionValueError, \
                      BadOptionError, OptionConflictError
 
-import _glib
+import glib
+_glib = sys.modules['glib._glib']
 
 __all__ = [
     "OptParseError",
@@ -182,12 +183,13 @@
 
             try:
                 opt.process(option_name, option_value, self.values, parser)
-            except OptionValueError, error:
-            	gerror = _glib.GError(str(error))
-            	gerror.domain = _glib.OPTION_ERROR
-            	gerror.code = _glib.OPTION_ERROR_BAD_VALUE
-            	gerror.message = str(error)
-            	raise gerror
+            except OptionValueError:
+                error = sys.exc_info()[1]
+                gerror = _glib.GError(str(error))
+                gerror.domain = _glib.OPTION_ERROR
+                gerror.code = _glib.OPTION_ERROR_BAD_VALUE
+                gerror.message = str(error)
+                raise gerror
 
         group = _glib.OptionGroup(self.name, self.description,
                                     self.help_description, callback)
@@ -325,13 +327,14 @@
         try:
             options, args = optparse.OptionParser.parse_args(
                 self, args, values)
-        except _glib.GError, error:
+        except _glib.GError:
+            error = sys.exc_info()[1]
             if error.domain != _glib.OPTION_ERROR:
-            	raise
+                raise
             if error.code == _glib.OPTION_ERROR_BAD_VALUE:
                 raise OptionValueError(error.message)
             elif error.code == _glib.OPTION_ERROR_UNKNOWN_OPTION:
-    	        raise BadOptionError(error.message)
+                raise BadOptionError(error.message)
             elif error.code == _glib.OPTION_ERROR_FAILED:
                 raise OptParseError(error.message)
             else:
@@ -342,6 +345,6 @@
                 options.ensure_value(key, value)
 
         args = args[2:-len(old_args)]
-	return options, args
+        return options, args
 
 make_option = Option

Modified: trunk/gobject/Makefile.am
==============================================================================
--- trunk/gobject/Makefile.am	(original)
+++ trunk/gobject/Makefile.am	Sun Jul 27 10:30:30 2008
@@ -26,7 +26,8 @@
 	$(top_builddir)/gobject/generate-constants$(EXEEXT) >> constants.py
 	chmod 444 constants.py
 
-generate_constants_CFLAGS = $(GLIB_CFLAGS)
+generate_constants_CFLAGS = $(GLIB_CFLAGS) $(PYTHON_INCLUDES)
+
 noinst_PROGRAMS = generate-constants
 CLEANFILES = constants.py
 EXTRA_DIST = constants.py.in

Modified: trunk/gobject/__init__.py
==============================================================================
--- trunk/gobject/__init__.py	(original)
+++ trunk/gobject/__init__.py	Sun Jul 27 10:30:30 2008
@@ -52,10 +52,10 @@
      OPTION_ERROR_FAILED, OPTION_REMAINING, OPTION_ERROR
 
 from gobject.constants import *
-from _gobject import *
+from gobject._gobject import *
 _PyGObject_API = _gobject._PyGObject_API
 
-from propertyhelper import property
+from gobject.propertyhelper import property
 
 sys.modules['gobject.option'] = option
 

Modified: trunk/gobject/constants.py.in
==============================================================================
--- trunk/gobject/constants.py.in	(original)
+++ trunk/gobject/constants.py.in	Sun Jul 27 10:30:30 2008
@@ -19,29 +19,32 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 
-from _gobject import type_from_name
+import sys
+
+import gobject._gobject
+_gobject = sys.modules['gobject._gobject']
 
 # TYPE_INVALID defined in gobjectmodule.c
-TYPE_NONE = type_from_name('void')
-TYPE_INTERFACE = type_from_name('GInterface')
-TYPE_CHAR = type_from_name('gchar')
-TYPE_UCHAR = type_from_name('guchar')
-TYPE_BOOLEAN = type_from_name('gboolean')
-TYPE_INT = type_from_name('gint')
-TYPE_UINT = type_from_name('guint')
-TYPE_LONG = type_from_name('glong')
-TYPE_ULONG = type_from_name('gulong')
-TYPE_INT64 = type_from_name('gint64')
-TYPE_UINT64 = type_from_name('guint64')
-TYPE_ENUM = type_from_name('GEnum')
-TYPE_FLAGS = type_from_name('GFlags')
-TYPE_FLOAT = type_from_name('gfloat')
-TYPE_DOUBLE = type_from_name('gdouble')
-TYPE_STRING = type_from_name('gchararray')
-TYPE_POINTER = type_from_name('gpointer')
-TYPE_BOXED = type_from_name('GBoxed')
-TYPE_PARAM = type_from_name('GParam')
-TYPE_OBJECT = type_from_name('GObject')
-TYPE_PYOBJECT = type_from_name('PyObject')
+TYPE_NONE = _gobject.type_from_name('void')
+TYPE_INTERFACE = _gobject.type_from_name('GInterface')
+TYPE_CHAR = _gobject.type_from_name('gchar')
+TYPE_UCHAR = _gobject.type_from_name('guchar')
+TYPE_BOOLEAN = _gobject.type_from_name('gboolean')
+TYPE_INT = _gobject.type_from_name('gint')
+TYPE_UINT = _gobject.type_from_name('guint')
+TYPE_LONG = _gobject.type_from_name('glong')
+TYPE_ULONG = _gobject.type_from_name('gulong')
+TYPE_INT64 = _gobject.type_from_name('gint64')
+TYPE_UINT64 = _gobject.type_from_name('guint64')
+TYPE_ENUM = _gobject.type_from_name('GEnum')
+TYPE_FLAGS = _gobject.type_from_name('GFlags')
+TYPE_FLOAT = _gobject.type_from_name('gfloat')
+TYPE_DOUBLE = _gobject.type_from_name('gdouble')
+TYPE_STRING = _gobject.type_from_name('gchararray')
+TYPE_POINTER = _gobject.type_from_name('gpointer')
+TYPE_BOXED = _gobject.type_from_name('GBoxed')
+TYPE_PARAM = _gobject.type_from_name('GParam')
+TYPE_OBJECT = _gobject.type_from_name('GObject')
+TYPE_PYOBJECT = _gobject.type_from_name('PyObject')
 TYPE_UNICHAR = TYPE_UINT
 

Modified: trunk/gobject/generate-constants.c
==============================================================================
--- trunk/gobject/generate-constants.c	(original)
+++ trunk/gobject/generate-constants.c	Sun Jul 27 10:30:30 2008
@@ -1,5 +1,12 @@
 #include <stdio.h>
 #include <glibconfig.h>
+#include <Python.h>
+
+#if PY_VERSION_HEX < 0x03000000
+# define LONGSUFFIX "L"
+#else
+# define LONGSUFFIX ""
+#endif
 
 int main(void)
 {
@@ -15,8 +22,8 @@
   printf("G_MININT = %d\n", G_MININT);
   printf("G_MAXINT = %d\n", G_MAXINT);
   printf("G_MAXUINT = %u\n", G_MAXUINT);
-  printf("G_MINLONG = %ldL\n", G_MINLONG);
-  printf("G_MAXLONG = %ldL\n", G_MAXLONG);
-  printf("G_MAXULONG = %luL\n", G_MAXULONG);
+  printf("G_MINLONG = %ld%s\n", G_MINLONG, LONGSUFFIX);
+  printf("G_MAXLONG = %ld%s\n", G_MAXLONG, LONGSUFFIX);
+  printf("G_MAXULONG = %lu%s\n", G_MAXULONG, LONGSUFFIX);
   return 0;
 }

Modified: trunk/gobject/propertyhelper.py
==============================================================================
--- trunk/gobject/propertyhelper.py	(original)
+++ trunk/gobject/propertyhelper.py	Sun Jul 27 10:30:30 2008
@@ -19,7 +19,11 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 
-import _gobject
+import sys
+
+import gobject._gobject
+_gobject = sys.modules['gobject._gobject']
+
 from gobject.constants import \
      TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, \
      TYPE_BOOLEAN, TYPE_INT, TYPE_UINT, TYPE_LONG, \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]