summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2019-11-19 10:07:09 -0300
committerThibault Saunier <tsaunier@igalia.com>2019-11-19 11:18:59 -0300
commit95b2f643944b49a5676da78b4b77358b386591be (patch)
tree7d0788d03b491563d0cd4d18079eec7588a55945
parentacb2da66f5d8e58b52f9a61b2cd8679a88e79c45 (diff)
Remove python2 support
We have notified application developers this would happen a long time ago and python2 is going to be deprecated very soon now, before 1.18 is going to be released.
-rw-r--r--gi/overrides/Gst.py16
-rw-r--r--gi/overrides/gstmodule.c18
-rw-r--r--meson.build3
3 files changed, 8 insertions, 29 deletions
diff --git a/gi/overrides/Gst.py b/gi/overrides/Gst.py
index 0f5f2be..3afc9c2 100644
--- a/gi/overrides/Gst.py
+++ b/gi/overrides/Gst.py
@@ -34,14 +34,6 @@ from ..module import get_introspection_module
from gi.repository import GLib
-if sys.version_info >= (3, 0):
- _basestring = str
- _callable = lambda c: hasattr(c, '__call__')
- long = int
-else:
- _basestring = basestring
- _callable = callable
-
Gst = get_introspection_module('Gst')
__all__ = []
@@ -52,7 +44,7 @@ if Gst._version == '0.10':
was not designed for use with introspection some of the \
interfaces and API will fail. As such this is not supported \
by the GStreamer development team and we encourage you to \
-port your app to Gst 1 or greater. gst-python is the recomended \
+port your app to Gst 1 or greater. gst-python is the recommended \
python module to use with Gst 0.10"
warnings.warn(warn_msg, RuntimeWarning)
@@ -481,10 +473,10 @@ class Int64Range(Gst.Int64Range):
class Bitmask(Gst.Bitmask):
def __init__(self, v):
- if not isinstance(v, long) and not isinstance(v, int):
- raise TypeError("%s is not an int or long." % (type(v)))
+ if not isinstance(v, int):
+ raise TypeError("%s is not an int." % (type(v)))
- self.v = long(v)
+ self.v = int(v)
def __str__(self):
return hex(self.v)
diff --git a/gi/overrides/gstmodule.c b/gi/overrides/gstmodule.c
index a28959f..4e26fdb 100644
--- a/gi/overrides/gstmodule.c
+++ b/gi/overrides/gstmodule.c
@@ -32,7 +32,6 @@
#include <locale.h>
-#if PY_MAJOR_VERSION >= 3
#define PYGLIB_MODULE_START(symbol, modname) \
static struct PyModuleDef _##symbol##module = { \
PyModuleDef_HEAD_INIT, \
@@ -51,15 +50,6 @@ PyMODINIT_FUNC PyInit_##symbol(void) \
PyObject *module; \
module = PyModule_Create(&_##symbol##module);
#define PYGLIB_MODULE_END return module; }
-#else
-#define PYGLIB_MODULE_START(symbol, modname) \
-DL_EXPORT(void) init##symbol(void); \
-DL_EXPORT(void) init##symbol(void) \
-{ \
- PyObject *module; \
- module = Py_InitModule(modname, symbol##_functions);
-#define PYGLIB_MODULE_END }
-#endif
GST_DEBUG_CATEGORY_STATIC (python_debug);
GST_DEBUG_CATEGORY_STATIC (pygst_debug);
@@ -81,7 +71,7 @@ gi_gst_get_type (gchar * type_name)
dict = PyModule_GetDict (module);
Py_DECREF (module);
- /* For some reson we need this intermediary step */
+ /* For some reason we need this intermediary step */
module = PyMapping_GetItemString (dict, "_overrides_module");
if (module == NULL) {
PyErr_SetString (PyExc_KeyError,
@@ -654,7 +644,6 @@ pygst_debug_log (PyObject * pyobject, PyObject * string, GstDebugLevel level,
}
frame = PyEval_GetFrame ();
-#if PY_MAJOR_VERSION >= 3
{
PyObject *utf8;
const gchar *utf8_str;
@@ -671,11 +660,6 @@ pygst_debug_log (PyObject * pyobject, PyObject * string, GstDebugLevel level,
filename = g_strdup (utf8_str);
Py_DECREF (utf8);
}
-#else
- function = g_strdup (PyString_AsString (frame->f_code->co_name));
- filename =
- g_path_get_basename (PyString_AsString (frame->f_code->co_filename));
-#endif
lineno = PyCode_Addr2Line (frame->f_code, frame->f_lasti);
/* gst_debug_log : category, level, file, function, line, object, format, va_list */
if (isgstobject)
diff --git a/meson.build b/meson.build
index 0c0a5ae..5f13b48 100644
--- a/meson.build
+++ b/meson.build
@@ -24,6 +24,9 @@ pygobject_dep = dependency('pygobject-3.0', fallback: ['pygobject', 'pygobject_d
pymod = import('python')
python = pymod.find_installation(get_option('python'))
+if python.language_version().version_compare('<3.0')
+ error('Python2 is not supported anymore, please port your code to python3 (@0@ specified)'.format(python.language_version()))
+endif
python_dep = python.dependency(required : true)
python_abi_flags = python.get_variable('ABIFLAGS', '')