Skip to content

Errors should be raised, not returned. #7535

@simon-king-jena

Description

@simon-king-jena

The following issue was considered in at least two threads, the latest at http://groups.google.com/group/sage-devel/browse_thread/thread/3661fde739474fdb.

There are several places in the Sage code where errors are not raised but returned. A hopefully exhaustive search brought up the following:

sage: import exceptions
sage: for E in dir(exceptions):
....:     if not E.startswith('__'):
....:         s = search_src("return "+E)
....:         if s:
....:             print s
....:
rings/finite_field_element.py:384:                return ArithmeticError, "Multiplicative order of 0 not defined."
rings/finite_field_givaro.pyx:1956:                return ArithmeticError, "Multiplicative order of 0 not defined."
structure/element.pyx:2601:            return ArithmeticError, "Multiplicative order of 0 not defined."

rings/ring.pyx:687:            return NotImplementedError
modular/hecke/module.py:706:        abstract base class, return NotImplementedError.
modular/arithgroup/congroup_gammaH.py:928:            return NotImplementedError
geometry/polyhedra.py:1068:            return NotImplementedError
symbolic/expression.pyx:1524:        return NotImplementedError
symbolic/expression_conversions.py:638:            return NotImplementedError("SymPy function '%s' doesn't exist" % f)

interfaces/gap.py:580:            return RuntimeError, "Error evaluating %s in %s"%(line, self)

modular/abvar/finite_subgroup.py:280:            return ValueError, "self and other must be in the same ambient Jacobian"
groups/perm_gps/permgroup_named.py:945:            return ValueError, "Degree must be 2."
groups/perm_gps/permgroup_named.py:988:            return ValueError, "Degree must be 2."

Of course, if an error is returned it can't be catched, which implies obvious problems.

I have no idea what component that ticket should be associated with. "Performance" seemed the least inappropriate description to me.

Is there any of the above cases in which the error should really be returned, not raised?

Component: misc

Keywords: error return

Author: Tim Dumol

Reviewer: John Palmieri

Merged: sage-4.3.2.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/7535

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions