[pygobject] Drop support for Python 2.6



commit 89d05f91cee419d46cb5318d4a9001ec315a3475
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Mar 25 09:03:51 2013 +0100

    Drop support for Python 2.6
    
    2.7 has been released long ago, nobody tests PyGObject with 2.6 any more, and
    this unblocks e. g. GNOME #682320.
    
    Drop usage of PyCObject_* (which has been superseded by PyCapsule for >= 2.7),
    and drop Python 2.6 specific workarounds.

 configure.ac                    |    2 +-
 gi/_glib/pyglib-python-compat.h |   20 -----------------
 gi/_gobject/pygobject.h         |    6 -----
 gi/pygi.h                       |    4 ---
 m4/python.m4                    |    2 +-
 tests/runtests.py               |   45 +--------------------------------------
 tests/test_gobject.py           |    1 -
 tests/test_signal.py            |    4 ---
 8 files changed, 3 insertions(+), 81 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 830581b..f706814 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@ AC_PREREQ([2.68])
 # You can also build against a full interpreter path, such as
 #   $ ./configure --with-python=~/my-patched-python/python
 
-m4_define(python_min_ver, 2.6)
+m4_define(python_min_ver, 2.7)
 m4_define(python3_min_ver, 3.1)
 
 dnl the pygobject version number
diff --git a/gi/_glib/pyglib-python-compat.h b/gi/_glib/pyglib-python-compat.h
index 9ba68f7..0153296 100644
--- a/gi/_glib/pyglib-python-compat.h
+++ b/gi/_glib/pyglib-python-compat.h
@@ -33,17 +33,6 @@
         } while (0)
 #endif
 
-/* PyCObject superceded by PyCapsule on Python >= 2.7
- * However since this effects header files used by
- * static bindings we are only applying the change to
- * Python 3.x where we don't support the static bindings.
- * 3.2 removed PyCObject so we don't have any choice here.
- *
- * There is talk upstream of undeprecating PyCObject
- * (at least where the 2.x branch is concerned)
- * and there is no danger of it being remove from 2.7.
- **/
-#if PY_VERSION_HEX >= 0x03000000
 # define PYGLIB_CPointer_Check PyCapsule_CheckExact
 # define PYGLIB_CPointer_WrapPointer(ptr, typename) \
     PyCapsule_New(ptr, typename, NULL)
@@ -51,15 +40,6 @@
     PyCapsule_GetPointer(obj, typename)
 # define PYGLIB_CPointer_Import(module, symbol) \
     PyCapsule_Import(##module##.##symbol##, FALSE)
-#else
-# define PYGLIB_CPointer_Check PyCObject_Check
-# define PYGLIB_CPointer_WrapPointer(ptr, typename) \
-    PyCObject_FromVoidPtr(ptr, NULL)
-# define PYGLIB_CPointer_GetPointer(obj, typename) \
-  PyCObject_AsVoidPtr(obj)
-# define PYGLIB_CPointer_Import(module, symbol) \
-    PyCObject_Import(module, symbol)
-#endif
 
 #if PY_VERSION_HEX < 0x03000000
 
diff --git a/gi/_gobject/pygobject.h b/gi/_gobject/pygobject.h
index 15b8807..0ef77b9 100644
--- a/gi/_gobject/pygobject.h
+++ b/gi/_gobject/pygobject.h
@@ -342,14 +342,8 @@ pygobject_init(int req_major, int req_minor, int req_micro)
     }
 
     cobject = PyObject_GetAttrString(gobject, "_PyGObject_API");
-#if PY_VERSION_HEX >= 0x03000000
     if (cobject && PyCapsule_CheckExact(cobject))
         _PyGObject_API = (struct _PyGObject_Functions *) PyCapsule_GetPointer(cobject, 
"gobject._PyGObject_API");
-
-#else
-    if (cobject && PyCObject_Check(cobject))
-        _PyGObject_API = (struct _PyGObject_Functions *) PyCObject_AsVoidPtr(cobject);
-#endif
     else {
         PyErr_SetString(PyExc_ImportError,
                         "could not import gobject (could not find _PyGObject_API object)");
diff --git a/gi/pygi.h b/gi/pygi.h
index 86da07f..88c1b90 100644
--- a/gi/pygi.h
+++ b/gi/pygi.h
@@ -101,11 +101,7 @@ _pygi_import (void)
     if (PyGI_API != NULL) {
         return 1;
     }
-#if PY_VERSION_HEX >= 0x03000000
     PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
-#else
-    PyGI_API = (struct PyGI_API*) PyCObject_Import("gi", "_API");
-#endif
     if (PyGI_API == NULL) {
         return -1;
     }
diff --git a/m4/python.m4 b/m4/python.m4
index 5bf200c..7e10bc0 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -146,7 +146,7 @@ AC_DEFUN([JD_PATH_PYTHON],
   dnl Find a Python interpreter.  Python versions prior to 2.0 are not
   dnl supported
   m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
-                    [python3 python3.3 python3.2 python3.1 python2 python2.7 python2.6 python])
+                    [python3 python3.3 python3.2 python3.1 python2 python2.7 python])
 
   m4_if([$1],[],[
     dnl No version check is needed.
diff --git a/tests/runtests.py b/tests/runtests.py
index d3a4f47..6085ff9 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -7,50 +7,7 @@ import sys
 
 import unittest
 
-# provide missing unittest decorators and API for python 2.6; these decorators
-# do not actually work, just avoid the syntax failure
-if sys.version_info[:2] == (2, 6):
-    def skipUnless(condition, reason):
-        if not condition:
-            sys.stderr.write('[expected failure] ')
-        return lambda obj: obj
-
-    unittest.skipUnless = skipUnless
-    unittest.expectedFailure = lambda obj: obj
-
-    def skipIf(condition, reason):
-        if condition:
-            sys.stderr.write('[expected failure] ')
-        return lambda obj: obj
-
-    unittest.skipIf = skipIf
-
-    def assertGreater(self, a, b, msg=None):
-        if not a > b:
-            self.fail('%s not greater than %s' % (repr(a), repr(b)))
-
-    def assertGreaterEqual(self, a, b, msg=None):
-        if not a >= b:
-            self.fail('%s not greater than or equal to %s' % (repr(a), repr(b)))
-
-    def assertLess(self, a, b, msg=None):
-        if not a < b:
-            self.fail('%s not less than %s' % (repr(a), repr(b)))
-
-    def assertLessEqual(self, a, b, msg=None):
-        if not a <= b:
-            self.fail('%s not less than or equal to %s' % (repr(a), repr(b)))
-
-    def assertIsInstance(self, obj, cls, msg=None):
-        if not isinstance(obj, cls):
-            self.fail('%s is not an instance of %r' % (repr(obj), cls))
-
-    unittest.TestCase.assertGreaterEqual = assertGreaterEqual
-    unittest.TestCase.assertGreater = assertGreater
-    unittest.TestCase.assertLessEqual = assertLessEqual
-    unittest.TestCase.assertLess = assertLess
-    unittest.TestCase.assertIsInstance = assertIsInstance
-
+# this was renamed in Python 3, provide backwards compatible name
 if sys.version_info[:2] == (2, 7):
     unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
 
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index ec4cb44..64422bd 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -28,7 +28,6 @@ class TestGObjectAPI(unittest.TestCase):
         # The pytype wrapper should hold the outer most Object class from overrides.
         self.assertEqual(GObject.TYPE_OBJECT.pytype, GObject.Object)
 
-    @unittest.skipIf(sys.version_info[:2] < (2, 7), 'Python 2.7 is required')
     def test_gobject_unsupported_overrides(self):
         obj = GObject.Object()
 
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 776ad7a..80f2986 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -925,12 +925,10 @@ class TestPython3Signals(unittest.TestCase):
 
 
 class TestSignalModuleLevelFunctions(unittest.TestCase):
-    @unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
     def test_signal_list_ids_with_invalid_type(self):
         with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
             GObject.signal_list_ids(GObject.TYPE_INVALID)
 
-    @unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
     def test_signal_list_ids(self):
         with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
             GObject.signal_list_ids(GObject.TYPE_INT)
@@ -942,12 +940,10 @@ class TestSignalModuleLevelFunctions(unittest.TestCase):
         # There is no signal 0 in gobject
         self.assertEqual(GObject.signal_name(0), None)
 
-    @unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
     def test_signal_lookup_with_invalid_type(self):
         with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
             GObject.signal_lookup('NOT_A_SIGNAL_NAME', GObject.TYPE_INVALID)
 
-    @unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
     def test_signal_lookup(self):
         ids = GObject.signal_list_ids(C)
         self.assertEqual(ids[0], GObject.signal_lookup('my_signal', C))


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