Ticket #10340: trac_10340_error_msg.patch

File trac_10340_error_msg.patch, 3.5 KB (added by malb, 11 years ago)
  • sage/rings/polynomial/pbori.pyx

    # HG changeset patch
    # User Martin Albrecht <martinralbrecht@googlemail.com>
    # Date 1290787554 0
    # Node ID 22ffe975998711fec1272491c3c8cf5dcd40e7a1
    # Parent  cc8a8137a48d9920e744c5a4accf46a151db04f1
    fixing the error message if a boolean polynomial ring with zero variables is created (#10340)
    
    diff -r cc8a8137a48d -r 22ffe9759987 sage/rings/polynomial/pbori.pyx
    a b  
    248248        sage: R
    249249        Boolean PolynomialRing in x, y, z
    250250
    251     ::
    252 
    253251        sage: p = x*y + x*z + y*z
    254252        sage: x*p
    255253        x*y*z + x*y + x*z
    256254
    257     ::
    258 
    259255        sage: R.term_order()
    260256        Lexicographic term order
    261257
    262     ::
    263 
    264258        sage: R = BooleanPolynomialRing(5,'x',order='deglex(3),deglex(2)')
    265259        sage: R.term_order()
    266260        deglex(3),deglex(2) term order
    267261
    268     ::
    269 
    270262        sage: R = BooleanPolynomialRing(3,'x',order='degrevlex')
    271263        sage: R.term_order()
    272264        Degree reverse lexicographic term order
    273265
     266        sage: R = BooleanPolynomialRing(0,'x',order='degrevlex')
     267        Traceback (most recent call last):
     268        ...
     269        ValueError: Number of variables must be greater than or equal to 1.
     270
    274271    TESTS::
    275272
    276273        sage: P.<x,y> = BooleanPolynomialRing(2,order='degrevlex')
    277274        sage: x > y
    278275        True
    279276
    280     ::
    281 
    282277        sage: P.<x0, x1, x2, x3> = BooleanPolynomialRing(4,order='degrevlex(2),degrevlex(2)')
    283278        sage: x0 > x1
    284279        True
     
    302297        cdef Py_ssize_t i, j, bstart, bsize
    303298
    304299        if names is None:
    305             raise TypeError, "You must specify the names of the variables."
     300            raise TypeError("You must specify the names of the variables.")
    306301
    307302        if n is None:
    308303            if PY_TYPE_CHECK(names, tuple) or PY_TYPE_CHECK(names, list):
     
    311306        try:
    312307            n = int(n)
    313308        except TypeError, msg:
    314             raise TypeError, "Number of variables must be an integer"
     309            raise TypeError("Number of variables must be an integer")
    315310
    316311        if n < 1:
    317             raise ValueError, "Number of variables must be greater than 1."
     312            raise ValueError("Number of variables must be greater than or equal to 1.")
    318313
    319314        self.pbind = <Py_ssize_t*>sage_malloc(n*sizeof(Py_ssize_t))
    320315        cdef char *_n
     
    324319        try:
    325320            pb_order_code = order_mapping[order[0].singular_str()]
    326321        except KeyError:
    327             raise ValueError, "Only lex, deglex, degrevlex orders are supported."
     322            raise ValueError("Only lex, deglex, degrevlex orders are supported.")
    328323
    329324        if len(order.blocks) > 1:
    330325            if pb_order_code is pblp:
    331                 raise ValueError, "Only deglex and degrevlex are supported for block orders."
     326                raise ValueError("Only deglex and degrevlex are supported for block orders.")
    332327            elif pb_order_code is pbdlex:
    333328                pb_order_code = pbblock_dlex
    334329            elif pb_order_code is pbdp_asc:
    335330                pb_order_code = pbblock_dp_asc
    336331            for i in range(1, len(order.blocks)):
    337332                if order[0] != order[i]:
    338                     raise ValueError, "Each block must have the same order type (deglex or degrevlex) for block orderings."
     333                    raise ValueError("Each block must have the same order type (deglex or degrevlex) for block orderings.")
    339334
    340335        if (pb_order_code is pbdlex) or (pb_order_code is pblp) or \
    341336                (pb_order_code is pbblock_dlex):