diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-03-02 23:45:35 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-03-02 23:45:35 +0000 |
| commit | b5050beb73b2e50b122c36e7dcdc06abffd472f2 (patch) | |
| tree | 6679019ff418d6c346d5bd4cdc4aab4a73d9303e /lib/sqlalchemy/ext/associationproxy.py | |
| parent | 2d052d43518a0f4d9751db7e699cfebd3724c1e5 (diff) | |
| parent | 57dc36a01b2b334a996f73f6a78b3bfbe4d9f2ec (diff) | |
| download | sqlalchemy-b5050beb73b2e50b122c36e7dcdc06abffd472f2.tar.gz | |
Merge "Ensure all nested exception throws have a cause"
Diffstat (limited to 'lib/sqlalchemy/ext/associationproxy.py')
| -rw-r--r-- | lib/sqlalchemy/ext/associationproxy.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 41346fc4e..f00b642db 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -244,6 +244,10 @@ class AssociationProxy(interfaces.InspectionAttrInfo): try: inst = class_.__dict__[self.key + "_inst"] except KeyError: + inst = None + + # avoid exception context + if inst is None: owner = self._calc_owner(class_) if owner is not None: inst = AssociationProxyInstance.for_proxy(self, owner, obj) @@ -358,9 +362,12 @@ class AssociationProxyInstance(object): # this was never asserted before but this should be made clear. if not isinstance(prop, orm.RelationshipProperty): - raise NotImplementedError( - "association proxy to a non-relationship " - "intermediary is not supported" + util.raise_( + NotImplementedError( + "association proxy to a non-relationship " + "intermediary is not supported" + ), + replace_context=None, ) target_class = prop.mapper.class_ @@ -1323,10 +1330,13 @@ class _AssociationDict(_AssociationCollection): try: for k, v in seq_or_map: self[k] = v - except ValueError: - raise ValueError( - "dictionary update sequence " - "requires 2-element tuples" + except ValueError as err: + util.raise_( + ValueError( + "dictionary update sequence " + "requires 2-element tuples" + ), + replace_context=err, ) for key, value in kw: |
