On Nov 26, 2009, at 12:21 AM, Florent Hivert wrote:

>      Hi there,
>
> On Wed, Nov 25, 2009 at 09:38:23PM -0800, William Stein wrote:
>> On Wed, Nov 25, 2009 at 7:26 PM, John H Palmieri <jhpalmier...@gmail.com 
>> > wrote:
>>> In ring.pyx, there is code like this:
>>>
>>>        if proof:
>>>            return NotImplementedError
>>>        else:
>>>            return False
>>>
>>> I would think that the second line should say "raise
>>> NotImplementedError".  (Changing it makes some doctests fail,
>>> though.)  Is there a good reason for doing "return
>>> NotImplementedError"?
>>
>> That's *definitely* a bug (almost certainly my fault).   No question
>> about it.   I made this #7532:
>>
>>   http://trac.sagemath.org/sage_trac/ticket/7532
>>
>> It sounds like you have a fix already, so just let us know when there
>> is a patch up to review.
>
> I suspected that this could be a common mistake. So I did a grep...  
> It seems I
> was right...
>
> Florent
>
> tomahawk-*ge-combinat/sage $ grep  return.\*Error **/*.py*
> categories/enumerated_sets.py:            ``EnumeratedSet()`` it  
> returns `NotImplementedError` since one does
> geometry/polyhedra.py:            return NotImplementedError
> groups/perm_gps/permgroup_named.py:            return ValueError,  
> "Degree must be 2."
> groups/perm_gps/permgroup_named.py:            return ValueError,  
> "Degree must be 2."
> groups/perm_gps/permgroup.py:            return TypeError, "Group  
> must be simple."
> interfaces/gap.py:            return RuntimeError, "Error evaluating  
> %s in %s"%(line, self)
> libs/pari/gen.pyx:        return "PariError(%d)"%self.args[0]
> misc/latex.py:        return "Error"
> misc/latex.py:        return "Error"
> misc/latex.py:            return "Error"
> misc/latex.py:            return "Error"
> misc/latex.py:                            return "Error: dvipng  
> failed."
> misc/latex.py:        return "Error latexing slide."
> misc/typecheck.py:__all__ = ["takes", "InputParameterError",  
> "returns", "ReturnValueError"]
> modular/abvar/finite_subgroup.py:            return ValueError,  
> "self and other must be in the same ambient Jacobian"
> modular/arithgroup/congroup_gammaH.py:            return  
> NotImplementedError
> modular/hecke/module.py:        abstract base class, return  
> NotImplementedError.
> rings/finite_field_element.py:                return  
> ArithmeticError, "Multiplicative order of 0 not defined."
> rings/finite_field_givaro.pyx:                return  
> ArithmeticError, "Multiplicative order of 0 not defined."
> rings/number_field/number_field.py:        If this function returns  
> True (and doesn't raise a ValueError),
> rings/ring.pyx:            return NotImplementedError
> rings/ring.pyx:        The following example returns a  
> ``NotImplementedError`` since the
> server/notebook/twist.py:            return HTMLResponse(stream =  
> 'Error in introspection -- invalid cell id.')
> server/notebook/worksheet.py:            return "print 'Error  
> loading %s -- file not found'"%filename
> server/notebook/worksheet.py:                    return "print  
> r'''Error compiling cython file:\n%s'''"%msg
> structure/element.pyx:            return ArithmeticError,  
> "Multiplicative order of 0 not defined."
> structure/factorization.py:        This method will return a  
> TypeError if the coercion is not
> symbolic/expression_conversions.py:            return  
> NotImplementedError("SymPy function '%s' doesn't exist" % f)
> symbolic/expression.pyx:        return NotImplementedError

Though all of the above look like errors to me, not that there is the  
special value NotImplemented that can be *returned* in certain cases

http://docs.python.org/library/constants.html

- Robert


-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to