diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py index 22e79601ff6..ebfe85f6159 100644 --- a/src/sage/geometry/cone.py +++ b/src/sage/geometry/cone.py @@ -582,14 +582,18 @@ def _ambient_space_point(body, data): def try_base_extend(ring): # Factor out the "try this ring..." code that's repeated four # times. - try: return L.base_extend(ring)(data) - except TypeError: pass + try: + return L.base_extend(ring)(data) + except TypeError: + pass except ValueError as ex: - if str(ex).startswith("Cannot coerce"): pass + if str(ex).startswith("Cannot coerce"): + pass # Special treatment for toric lattice elements p = try_base_extend(ZZ) - if p is not None: return p + if p is not None: + return p if is_ToricLattice(parent(data)): raise TypeError("the point %s and %s have incompatible " "lattices" % (data, body)) @@ -599,7 +603,8 @@ def try_base_extend(ring): # attempt a numerical representation. for ring in [QQ, AA, RR]: p = try_base_extend(ring) - if p is not None: return p + if p is not None: + return p # Raise TypeError with our own message raise TypeError("%s does not represent a valid point in the ambient "