mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-07-30 23:41:52 +03:00
override: Fix exception handling syntax
Python 3 no longer accepts 'except Exception, e:' as valid while Python 2.4 does not accept the new syntax 'except Exception as e:' so this uses a fall back method that is compatible with both.
This commit is contained in:
@ -50,7 +50,8 @@
|
|||||||
ret = handler(self, got, opaque)
|
ret = handler(self, got, opaque)
|
||||||
if type(ret) is int and ret < 0:
|
if type(ret) is int and ret < 0:
|
||||||
raise RuntimeError("recvAll handler returned %d" % ret)
|
raise RuntimeError("recvAll handler returned %d" % ret)
|
||||||
except Exception, e:
|
except Exception:
|
||||||
|
e = sys.exc_info()[1]
|
||||||
try:
|
try:
|
||||||
self.abort()
|
self.abort()
|
||||||
except:
|
except:
|
||||||
|
@ -3,12 +3,16 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# On cygwin, the DLL is called cygvirtmod.dll
|
# On cygwin, the DLL is called cygvirtmod.dll
|
||||||
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import libvirtmod
|
import libvirtmod
|
||||||
except ImportError, lib_e:
|
except ImportError:
|
||||||
|
lib_e = sys.exc_info()[1]
|
||||||
try:
|
try:
|
||||||
import cygvirtmod as libvirtmod
|
import cygvirtmod as libvirtmod
|
||||||
except ImportError, cyg_e:
|
except ImportError:
|
||||||
|
cyg_e = sys.exc_info()[1]
|
||||||
if str(cyg_e).count("No module named"):
|
if str(cyg_e).count("No module named"):
|
||||||
raise lib_e
|
raise lib_e
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user