Skip to content

py3

Functionality to facilitate keeping code compatible with Python 2 & Python 3.

Implementations for Python 3.

Authors:

  • Kenneth Hoste (Ghent University)

extract_method_name(method_func)

Extract method name from lambda function.

json_loads(body)

Wrapper for json.loads that takes into account that Python versions older than 3.6 require a string value.

load_source(filename, path)

Load file as Python module

raise_with_traceback(exception_class, message, traceback)

Raise exception of specified class with given message and traceback.

safe_cmp_looseversions(v1, v2)

Safe comparison function for two (values containing) LooseVersion instances.

sort_looseversions(looseversions)

Sort list of (values including) distutils.version.LooseVersion instances.

subprocess_popen_text(cmd, **kwargs)

Call subprocess.Popen in text mode with specified named arguments.

subprocess_terminate(proc, timeout)

Terminate the subprocess if it hasn't finished after the given timeout