From: Martin Ling Date: Wed, 17 Apr 2013 14:37:58 +0000 (+0100) Subject: python: Fix syntax to support Python 3.x. X-Git-Tag: dsupstream~111 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1cad2115477176001f44cbe8a46a3c74e650f866;p=libsigrok.git python: Fix syntax to support Python 3.x. --- diff --git a/bindings/python/sigrok/core/__init__.py b/bindings/python/sigrok/core/__init__.py index 4c1f4319..7baf616d 100644 --- a/bindings/python/sigrok/core/__init__.py +++ b/bindings/python/sigrok/core/__init__.py @@ -1,3 +1,3 @@ -import lowlevel -import classes -from classes import * +from . import lowlevel +from . import classes +from .classes import * diff --git a/bindings/python/sigrok/core/classes.py b/bindings/python/sigrok/core/classes.py index cf955e94..4bbda25d 100644 --- a/bindings/python/sigrok/core/classes.py +++ b/bindings/python/sigrok/core/classes.py @@ -19,8 +19,8 @@ from functools import partial from fractions import Fraction -from lowlevel import * -import lowlevel +from .lowlevel import * +from . import lowlevel import itertools __all__ = ['Error', 'Context', 'Driver', 'Device', 'Session', 'Packet'] @@ -54,7 +54,7 @@ def gvariant_to_python(value): return Fraction( g_variant_get_uint64(g_variant_get_child_value(value, 0)), g_variant_get_uint64(g_variant_get_child_value(value, 1))) - raise NotImplementedError, ( + raise NotImplementedError( "Can't convert GVariant type '%s' to a Python type." % type_string) def python_to_gvariant(value): @@ -73,7 +73,7 @@ def python_to_gvariant(value): result = g_variant_new_tuple(array, 2) delete_gvariant_ptr_array(array) return result - raise NotImplementedError, ( + raise NotImplementedError( "Can't convert Python '%s' to a GVariant." % type(value)) def callback_wrapper(session, callback, device_ptr, packet_ptr): @@ -153,7 +153,7 @@ class Device(object): check(sr_config_get(self.driver.struct, key, data, self.struct)) except Error as error: if error.errno == SR_ERR_ARG: - raise NotImplementedError, ( + raise NotImplementedError( "Device does not implement %s" % name) else: raise AttributeError @@ -226,7 +226,7 @@ class Packet(object): self._payload = Logic(self, void_ptr_to_sr_datafeed_logic_ptr(pointer)) else: - raise NotImplementedError, ( + raise NotImplementedError( "No Python mapping for packet type %ѕ" % self.struct.type) return self._payload