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.
This commit is contained in:
Thibault Saunier 2019-11-19 10:07:09 -03:00
parent acb2da66f5
commit 95b2f64394
3 changed files with 8 additions and 29 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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', '')