diff options
Diffstat (limited to 'lib/sqlalchemy/orm/exc.py')
-rw-r--r-- | lib/sqlalchemy/orm/exc.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/sqlalchemy/orm/exc.py b/lib/sqlalchemy/orm/exc.py index eb4baa08d..f0aa02e99 100644 --- a/lib/sqlalchemy/orm/exc.py +++ b/lib/sqlalchemy/orm/exc.py @@ -38,6 +38,7 @@ class StaleDataError(sa_exc.SQLAlchemyError): """ + ConcurrentModificationError = StaleDataError @@ -72,16 +73,19 @@ class UnmappedInstanceError(UnmappedError): try: base.class_mapper(type(obj)) name = _safe_cls_name(type(obj)) - msg = ("Class %r is mapped, but this instance lacks " - "instrumentation. This occurs when the instance " - "is created before sqlalchemy.orm.mapper(%s) " - "was called." % (name, name)) + msg = ( + "Class %r is mapped, but this instance lacks " + "instrumentation. This occurs when the instance " + "is created before sqlalchemy.orm.mapper(%s) " + "was called." % (name, name) + ) except UnmappedClassError: msg = _default_unmapped(type(obj)) if isinstance(obj, type): msg += ( - '; was a class (%s) supplied where an instance was ' - 'required?' % _safe_cls_name(obj)) + "; was a class (%s) supplied where an instance was " + "required?" % _safe_cls_name(obj) + ) UnmappedError.__init__(self, msg) def __reduce__(self): @@ -119,11 +123,14 @@ class ObjectDeletedError(sa_exc.InvalidRequestError): object. """ + @util.dependencies("sqlalchemy.orm.base") def __init__(self, base, state, msg=None): if not msg: - msg = "Instance '%s' has been deleted, or its "\ + msg = ( + "Instance '%s' has been deleted, or its " "row is otherwise not present." % base.state_str(state) + ) sa_exc.InvalidRequestError.__init__(self, msg) @@ -145,9 +152,9 @@ class MultipleResultsFound(sa_exc.InvalidRequestError): def _safe_cls_name(cls): try: - cls_name = '.'.join((cls.__module__, cls.__name__)) + cls_name = ".".join((cls.__module__, cls.__name__)) except AttributeError: - cls_name = getattr(cls, '__name__', None) + cls_name = getattr(cls, "__name__", None) if cls_name is None: cls_name = repr(cls) return cls_name |