Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#5971 closed defect (fixed)

[with patch, positive review] fix dumb error message when modding out by 0: Mod(10,0)

Reported by: was Owned by: somebody
Priority: minor Milestone: sage-4.1
Component: basic arithmetic Keywords:
Cc: Merged in: sage-4.1.alpha2
Authors: Minh Van Nguyen Reviewers: Karl-Dieter Crisman
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

When doing Mod(n,0), either there should be a useful error message, or one should get n back. The following is no good at all -- one shouldn't get an AttributeError?, which is surely due to a bug.

sage: a = Mod(10,0)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

    115     cdef IntegerMod_abstract x
--> 116     x = IntegerMod(integer_mod_ring.IntegerModRing(m), n)
    117     if parent is None:
    118         return x

/Users/wstein/build/sage-3.4.2.rc0/local/lib/python2.5/site-packages/sage/rings/integer_mod.so in sage.rings.integer_mod.IntegerMod (sage/rings/integer_mod.c:2730)()
    132     cdef NativeIntStruct modulus
    133     cdef Py_ssize_t res
--> 134     modulus = parent._pyx_order
    135     if modulus.table is not None:
    136         if PY_TYPE_CHECK(value, sage.rings.integer.Integer) or PY_TYPE_CHECK(value, int) or PY_TYPE_CHECK(value, long):

AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute '_pyx_order'

Attachments (1)

trac_5971.patch (1.0 KB) - added by mvngu 10 years ago.
based on Sage 4.1.alpha1

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by mvngu

  • Authors set to Minh Van Nguyen
  • Summary changed from fix dumb error message when modding out by 0: Mod(10,0) to [with patch, needs review] fix dumb error message when modding out by 0: Mod(10,0)

Changed 10 years ago by mvngu

based on Sage 4.1.alpha1

comment:2 Changed 10 years ago by kcrisman

  • Summary changed from [with patch, needs review] fix dumb error message when modding out by 0: Mod(10,0) to [with patch, positive review] fix dumb error message when modding out by 0: Mod(10,0)

Applies fine to 4.1.alpha1 and does what it says. I like the second doctest. Unless something goes wrong with docbuild due to the #, all is well.

comment:3 Changed 10 years ago by boothby

  • Merged in set to sage-4.1.alpha2
  • Resolution set to fixed
  • Status changed from new to closed

comment:4 Changed 10 years ago by mvngu

  • Reviewers set to Karl-Dieter Crisman
Note: See TracTickets for help on using tickets.