summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Kuska <rkuska@redhat.com>2015-08-24 12:40:33 +0200
committerJan Cholasta <jcholast@redhat.com>2015-09-30 10:51:36 +0200
commit01da4a8de3ed8651cc95df6125751e1603dbd14e (patch)
tree823856bad461808163b3fc05c54e0d87d26dd381
parent34e6c3ea05b23f4a5fe6fb6aaadd394967f31340 (diff)
downloadfreeipa-01da4a8de3ed8651cc95df6125751e1603dbd14e.tar.gz
freeipa-01da4a8de3ed8651cc95df6125751e1603dbd14e.tar.xz
freeipa-01da4a8de3ed8651cc95df6125751e1603dbd14e.zip
Replace StandardError with Exception
StandardError was removed in Python3 and instead Exception should be used. Signed-off-by: Robert Kuska <rkuska@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
-rw-r--r--doc/guide/guide.org2
-rw-r--r--doc/guide/wsgi.py.txt2
-rw-r--r--install/share/wsgi.py2
-rwxr-xr-xipa-client/ipa-install/ipa-client-install2
-rw-r--r--ipalib/backend.py6
-rw-r--r--ipalib/cli.py2
-rw-r--r--ipalib/config.py4
-rw-r--r--ipalib/constants.py2
-rw-r--r--ipalib/errors.py6
-rw-r--r--ipalib/parameters.py6
-rw-r--r--ipalib/plugable.py4
-rw-r--r--ipalib/plugins/migration.py4
-rw-r--r--ipapython/errors.py2
-rw-r--r--ipaserver/rpcserver.py8
-rw-r--r--ipatests/test_cmdline/test_ipagetkeytab.py4
-rw-r--r--ipatests/test_ipalib/test_backend.py6
-rw-r--r--ipatests/test_ipalib/test_config.py10
-rw-r--r--ipatests/test_ipalib/test_errors.py10
-rw-r--r--ipatests/test_ipalib/test_plugable.py8
-rw-r--r--ipatests/test_ipaserver/test_rpcserver.py4
-rw-r--r--ipatests/test_xmlrpc/xmlrpc_test.py4
21 files changed, 49 insertions, 49 deletions
diff --git a/doc/guide/guide.org b/doc/guide/guide.org
index ad0c5953a..55c172535 100644
--- a/doc/guide/guide.org
+++ b/doc/guide/guide.org
@@ -754,7 +754,7 @@ def run(api):
api.log.info('operation aborted')
except PublicError, e:
error = e
- except StandardError, e:
+ except Exception, e:
api.log.exception('%s: %s', e.__class__.__name__, str(e))
error = InternalError()
if error is not None:
diff --git a/doc/guide/wsgi.py.txt b/doc/guide/wsgi.py.txt
index 2c4a9aaaa..eb64f3a82 100644
--- a/doc/guide/wsgi.py.txt
+++ b/doc/guide/wsgi.py.txt
@@ -13,7 +13,7 @@ env._finalize_core(**dict(DEFAULT_CONFIG))
api.bootstrap(context='server', debug=env.debug, log=None) (ref:wsgi-app-bootstrap)
try:
api.finalize() (ref:wsgi-app-finalize)
-except StandardError, e:
+except Exception, e:
api.log.error('Failed to start IPA: %s' % e)
else:
api.log.info('*** PROCESS START ***')
diff --git a/install/share/wsgi.py b/install/share/wsgi.py
index eab612053..ee9311e4e 100644
--- a/install/share/wsgi.py
+++ b/install/share/wsgi.py
@@ -38,7 +38,7 @@ env._finalize_core(**dict(DEFAULT_CONFIG))
api.bootstrap(context='server', debug=env.debug, log=None)
try:
api.finalize()
-except StandardError as e:
+except Exception as e:
api.log.error('Failed to start IPA: %s' % e)
else:
api.log.info('*** PROCESS START ***')
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install
index 91c78c9b3..ff44fbb9b 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -1818,7 +1818,7 @@ def update_ssh_keys(server, hostname, ssh_dir, create_sshfp):
)
except errors.EmptyModlist:
pass
- except StandardError as e:
+ except Exception as e:
root_logger.info("host_mod: %s", str(e))
root_logger.warning("Failed to upload host SSH public keys.")
return
diff --git a/ipalib/backend.py b/ipalib/backend.py
index 288a0edf2..b8fa29626 100644
--- a/ipalib/backend.py
+++ b/ipalib/backend.py
@@ -56,7 +56,7 @@ class Connectible(Backend):
Create thread-local connection.
"""
if hasattr(context, self.id):
- raise StandardError(
+ raise Exception(
"connect: 'context.%s' already exists in thread %r" % (
self.id, threading.currentThread().getName()
)
@@ -71,7 +71,7 @@ class Connectible(Backend):
def disconnect(self):
if not hasattr(context, self.id):
- raise StandardError(
+ raise Exception(
"disconnect: 'context.%s' does not exist in thread %r" % (
self.id, threading.currentThread().getName()
)
@@ -130,7 +130,7 @@ class Executioner(Backend):
result = self.Command[_name](*args, **options)
except PublicError as e:
error = e
- except StandardError as e:
+ except Exception as e:
self.exception(
'non-public: %s: %s', e.__class__.__name__, str(e)
)
diff --git a/ipalib/cli.py b/ipalib/cli.py
index b0e138925..44ef61d30 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -1350,7 +1350,7 @@ def run(api):
api.log.info('operation aborted')
except PublicError as e:
error = e
- except StandardError as e:
+ except Exception as e:
api.log.exception('%s: %s', e.__class__.__name__, str(e))
error = InternalError()
if error is not None:
diff --git a/ipalib/config.py b/ipalib/config.py
index 14368e2b4..eb823d851 100644
--- a/ipalib/config.py
+++ b/ipalib/config.py
@@ -210,7 +210,7 @@ class Env(object):
Prevent further changes to environment.
"""
if self.__locked is True:
- raise StandardError(
+ raise Exception(
'%s.__lock__() already called' % self.__class__.__name__
)
object.__setattr__(self, '_Env__locked', True)
@@ -407,7 +407,7 @@ class Env(object):
def __doing(self, name):
if name in self.__done:
- raise StandardError(
+ raise Exception(
'%s.%s() already called' % (self.__class__.__name__, name)
)
self.__done.add(name)
diff --git a/ipalib/constants.py b/ipalib/constants.py
index 53c3106cd..987d40901 100644
--- a/ipalib/constants.py
+++ b/ipalib/constants.py
@@ -49,7 +49,7 @@ TYPE_ERROR = '%s: need a %r; got %r (a %r)'
# Stardard format for TypeError message when a callable is expected:
CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)'
-# Standard format for StandardError message when overriding an attribute:
+# Standard format for Exception message when overriding an attribute:
OVERRIDE_ERROR = 'cannot override %s.%s value %r with %r'
# Standard format for AttributeError message when a read-only attribute is
diff --git a/ipalib/errors.py b/ipalib/errors.py
index 2f7c77c1c..49b628aad 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -107,7 +107,7 @@ from ipalib import messages
from ipaplatform.paths import paths
-class PrivateError(StandardError):
+class PrivateError(Exception):
"""
Base class for exceptions that are *never* forwarded in an RPC response.
"""
@@ -122,7 +122,7 @@ class PrivateError(StandardError):
self.__class__.__name__, key, value,
)
setattr(self, key, value)
- StandardError.__init__(self, self.msg)
+ Exception.__init__(self, self.msg)
class SubprocessError(PrivateError):
@@ -239,7 +239,7 @@ def _(message):
return message
-class PublicError(StandardError):
+class PublicError(Exception):
"""
**900** Base class for exceptions that can be forwarded in an RPC response.
"""
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 176df09ea..dab235a24 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -242,7 +242,7 @@ class DefaultFrom(ReadOnly):
return
try:
return self.callback(*vals)
- except StandardError:
+ except Exception:
pass
def __json__(self):
@@ -740,7 +740,7 @@ class Param(ReadOnly):
return value
try:
return self.normalizer(value)
- except StandardError:
+ except Exception:
return value
def convert(self, value):
@@ -917,7 +917,7 @@ class Param(ReadOnly):
if default is not None:
try:
return self.convert(self.normalize(default))
- except StandardError:
+ except Exception:
pass
return self.default
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 2a608d8cb..2b593ec3b 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -360,7 +360,7 @@ class API(ReadOnly):
def __doing(self, name):
if name in self.__done:
- raise StandardError(
+ raise Exception(
'%s.%s() already called' % (self.__class__.__name__, name)
)
self.__done.add(name)
@@ -572,7 +572,7 @@ class API(ReadOnly):
module = importlib.import_module(name)
except errors.SkipPluginModule as e:
self.log.debug("skipping plugin module %s: %s", name, e.reason)
- except StandardError as e:
+ except Exception as e:
if self.env.startup_traceback:
import traceback
self.log.error("could not load plugin module %s\n%s", name,
diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 3e3c0fe19..59c49fae5 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -31,7 +31,7 @@ from ipalib.plugins.user import NO_UPG_MAGIC
if api.env.in_server and api.env.context in ['lite', 'server']:
try:
from ipaserver.plugins.ldap2 import ldap2
- except StandardError as e:
+ except Exception as e:
raise e
from ipalib import _
from ipapython.dn import DN
@@ -922,7 +922,7 @@ can use their Kerberos accounts.''')
ds_base_dn = DN(entries[0]['namingcontexts'][0])
assert isinstance(ds_base_dn, DN)
except (IndexError, KeyError) as e:
- raise StandardError(str(e))
+ raise Exception(str(e))
# migrate!
(migrated, failed) = self.migrate(
diff --git a/ipapython/errors.py b/ipapython/errors.py
index 9fc28359c..aad485b0f 100644
--- a/ipapython/errors.py
+++ b/ipapython/errors.py
@@ -18,7 +18,7 @@
#
-class SetseboolError(StandardError):
+class SetseboolError(Exception):
"""Raised when setting a SELinux boolean fails
:param failed: Dictionary mapping boolean names to intended values
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 1195d5c88..554f4f506 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -282,11 +282,11 @@ class wsgi_dispatch(Executioner, HTTP_Status):
Mount the WSGI application *app* at *key*.
"""
# if self.__islocked__():
-# raise StandardError('%s.mount(): locked, cannot mount %r at %r' % (
+# raise Exception('%s.mount(): locked, cannot mount %r at %r' % (
# self.name, app, key)
# )
if key in self.__apps:
- raise StandardError('%s.mount(): cannot replace %r with %r at %r' % (
+ raise Exception('%s.mount(): cannot replace %r with %r at %r' % (
self.name, self.__apps[key], app, key)
)
self.debug('Mounting %r at %r', app, key)
@@ -354,7 +354,7 @@ class WSGIExecutioner(Executioner):
if self.api.env.debug:
self.debug('WSGI wsgi_execute PublicError: %s', traceback.format_exc())
error = e
- except StandardError as e:
+ except Exception as e:
self.exception(
'non-public: %s: %s', e.__class__.__name__, str(e)
)
@@ -407,7 +407,7 @@ class WSGIExecutioner(Executioner):
status = HTTP_STATUS_SUCCESS
response = self.wsgi_execute(environ)
headers = [('Content-Type', self.content_type + '; charset=utf-8')]
- except StandardError as e:
+ except Exception as e:
self.exception('WSGI %s.__call__():', self.name)
status = HTTP_STATUS_SERVER_ERROR
response = status
diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py
index d9ab0daaa..7b57ba194 100644
--- a/ipatests/test_cmdline/test_ipagetkeytab.py
+++ b/ipatests/test_cmdline/test_ipagetkeytab.py
@@ -46,7 +46,7 @@ def use_keytab(principal, keytab):
conn.connect(autobind=ipaldap.AUTOBIND_DISABLED)
conn.disconnect()
except gssapi.exceptions.GSSError as e:
- raise StandardError('Unable to bind to LDAP. Error initializing principal %s in %s: %s' % (principal, keytab, str(e)))
+ raise Exception('Unable to bind to LDAP. Error initializing principal %s in %s: %s' % (principal, keytab, str(e)))
finally:
os.environ.pop('KRB5CCNAME', None)
if tmpdir:
@@ -138,7 +138,7 @@ class test_ipagetkeytab(cmdline_test):
"""
try:
use_keytab(self.service_princ, self.keytabname)
- except StandardError as errmsg:
+ except Exception as errmsg:
assert('Unable to bind to LDAP. Error initializing principal' in str(errmsg))
def test_9_cleanup(self):
diff --git a/ipatests/test_ipalib/test_backend.py b/ipatests/test_ipalib/test_backend.py
index f7887bf64..4e014f654 100644
--- a/ipatests/test_ipalib/test_backend.py
+++ b/ipatests/test_ipalib/test_backend.py
@@ -90,9 +90,9 @@ class test_Connectible(ClassChecker):
assert conn.conn == 'The connection.'
assert conn.disconnect == o.disconnect
- # Test that StandardError is raised if already connected:
+ # Test that Exception is raised if already connected:
m = "connect: 'context.%s' already exists in thread %r"
- e = raises(StandardError, o.connect, *args, **kw)
+ e = raises(Exception, o.connect, *args, **kw)
assert str(e) == m % ('example', threading.currentThread().getName())
# Double check that it works after deleting context.example:
@@ -121,7 +121,7 @@ class test_Connectible(ClassChecker):
o = example(api, shared_instance=True)
m = "disconnect: 'context.%s' does not exist in thread %r"
- e = raises(StandardError, o.disconnect)
+ e = raises(Exception, o.disconnect)
assert str(e) == m % ('example', threading.currentThread().getName())
context.example = 'The connection.'
diff --git a/ipatests/test_ipalib/test_config.py b/ipatests/test_ipalib/test_config.py
index b8cba516d..5a0de1e1f 100644
--- a/ipatests/test_ipalib/test_config.py
+++ b/ipatests/test_ipalib/test_config.py
@@ -166,7 +166,7 @@ class test_Env(ClassChecker):
assert o.__islocked__() is False
o.__lock__()
assert o.__islocked__() is True
- e = raises(StandardError, o.__lock__)
+ e = raises(Exception, o.__lock__)
assert str(e) == 'Env.__lock__() already called'
# Also test with base.lock() function:
@@ -429,7 +429,7 @@ class test_Env(ClassChecker):
assert o._isdone('_bootstrap') is False
o._bootstrap(**overrides)
assert o._isdone('_bootstrap') is True
- e = raises(StandardError, o._bootstrap)
+ e = raises(Exception, o._bootstrap)
assert str(e) == 'Env._bootstrap() already called'
return (o, home)
@@ -512,7 +512,7 @@ class test_Env(ClassChecker):
assert key in o
# Check that it can't be called twice:
- e = raises(StandardError, o._finalize_core)
+ e = raises(Exception, o._finalize_core)
assert str(e) == 'Env._finalize_core() already called'
return (o, home)
@@ -586,7 +586,7 @@ class test_Env(ClassChecker):
assert o._isdone('_finalize') is True
# Check that it can't be called twice:
- e = raises(StandardError, o._finalize)
+ e = raises(Exception, o._finalize)
assert str(e) == 'Env._finalize() already called'
# Check that _finalize() calls __lock__()
@@ -594,7 +594,7 @@ class test_Env(ClassChecker):
assert o.__islocked__() is False
o._finalize()
assert o.__islocked__() is True
- e = raises(StandardError, o.__lock__)
+ e = raises(Exception, o.__lock__)
assert str(e) == 'Env.__lock__() already called'
# Check that **lastchance works
diff --git a/ipatests/test_ipalib/test_errors.py b/ipatests/test_ipalib/test_errors.py
index 8cc9cd276..6dd9e6cce 100644
--- a/ipatests/test_ipalib/test_errors.py
+++ b/ipatests/test_ipalib/test_errors.py
@@ -45,7 +45,7 @@ class PrivateExceptionTester(object):
def __get_klass(self):
if self.__klass is None:
self.__klass = self._klass
- assert issubclass(self.__klass, StandardError)
+ assert issubclass(self.__klass, Exception)
assert issubclass(self.__klass, errors.PrivateError)
assert not issubclass(self.__klass, errors.PublicError)
return self.__klass
@@ -55,7 +55,7 @@ class PrivateExceptionTester(object):
for (key, value) in kw.items():
assert not hasattr(self.klass, key), key
inst = self.klass(**kw)
- assert isinstance(inst, StandardError)
+ assert isinstance(inst, Exception)
assert isinstance(inst, errors.PrivateError)
assert isinstance(inst, self.klass)
assert not isinstance(inst, errors.PublicError)
@@ -203,7 +203,7 @@ class PublicExceptionTester(object):
def __get_klass(self):
if self.__klass is None:
self.__klass = self._klass
- assert issubclass(self.__klass, StandardError)
+ assert issubclass(self.__klass, Exception)
assert issubclass(self.__klass, errors.PublicError)
assert not issubclass(self.__klass, errors.PrivateError)
assert type(self.__klass.errno) is int
@@ -234,7 +234,7 @@ class test_PublicError(PublicExceptionTester):
Test the `ipalib.errors.PublicError` exception.
"""
_klass = errors.PublicError
- required_classes = StandardError, errors.PublicError
+ required_classes = Exception, errors.PublicError
def test_init(self):
message = u'The translated, interpolated message'
@@ -375,7 +375,7 @@ class BaseMessagesTest(object):
class test_PublicErrors(object):
message_list = errors.public_errors
errno_range = list(range(900, 5999))
- required_classes = (StandardError, errors.PublicError)
+ required_classes = (Exception, errors.PublicError)
texts = errors._texts
def extratest(self, cls):
diff --git a/ipatests/test_ipalib/test_plugable.py b/ipatests/test_ipalib/test_plugable.py
index 148139464..caf08d6b9 100644
--- a/ipatests/test_ipalib/test_plugable.py
+++ b/ipatests/test_ipalib/test_plugable.py
@@ -80,7 +80,7 @@ class test_Plugin(ClassChecker):
# whose names conflict with the logger methods set in Plugin.__init__():
class check(self.cls):
info = 'whatever'
- e = raises(StandardError, check, api)
+ e = raises(Exception, check, api)
assert str(e) == \
"info is already bound to ipatests.test_ipalib.test_plugable.check()"
@@ -257,7 +257,7 @@ class test_API(ClassChecker):
assert inst.method(7) == 7 + b
# Test that calling finilize again raises AssertionError:
- e = raises(StandardError, api.finalize)
+ e = raises(Exception, api.finalize)
assert str(e) == 'API.finalize() already called', str(e)
def test_bootstrap(self):
@@ -273,7 +273,7 @@ class test_API(ClassChecker):
assert o.env._isdone('_bootstrap') is True
assert o.env._isdone('_finalize_core') is True
assert o.env.my_test_override == 'Hello, world!'
- e = raises(StandardError, o.bootstrap)
+ e = raises(Exception, o.bootstrap)
assert str(e) == 'API.bootstrap() already called'
def test_load_plugins(self):
@@ -286,5 +286,5 @@ class test_API(ClassChecker):
o.load_plugins()
assert o.isdone('bootstrap') is True
assert o.isdone('load_plugins') is True
- e = raises(StandardError, o.load_plugins)
+ e = raises(Exception, o.load_plugins)
assert str(e) == 'API.load_plugins() already called'
diff --git a/ipatests/test_ipaserver/test_rpcserver.py b/ipatests/test_ipaserver/test_rpcserver.py
index 95980eb05..ce5a03a13 100644
--- a/ipatests/test_ipaserver/test_rpcserver.py
+++ b/ipatests/test_ipaserver/test_rpcserver.py
@@ -173,8 +173,8 @@ class test_session(object):
assert inst['foo'] is app1
assert list(inst) == ['foo']
- # Test that StandardError is raise if trying override a mount:
- e = raises(StandardError, inst.mount, app2, 'foo')
+ # Test that Exception is raise if trying override a mount:
+ e = raises(Exception, inst.mount, app2, 'foo')
assert str(e) == '%s.mount(): cannot replace %r with %r at %r' % (
'wsgi_dispatch', app1, app2, 'foo'
)
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 56ddad9b8..80638e2ef 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -313,7 +313,7 @@ class Declarative(XMLRPC_test):
name = klass.__name__
try:
output = api.Command[cmd](*args, **options)
- except StandardError as e:
+ except Exception as e:
pass
else:
raise AssertionError(
@@ -336,7 +336,7 @@ class Declarative(XMLRPC_test):
e = None
try:
output = api.Command[cmd](*args, **options)
- except StandardError as e:
+ except Exception as e:
pass
if not expected(e, output):
raise AssertionError(