Ticket #13109: trac_number_check.diff

File trac_number_check.diff, 2.5 KB (added by vbraun, 8 years ago)

change in deprecation.patch - for review purposes only

  • sage/misc/superseded.py

    diff --git a/sage/misc/superseded.py b/sage/misc/superseded.py
    a b  
    2626from sage.misc.lazy_attribute import lazy_attribute
    2727
    2828
     29def _check_trac_number(trac_number):
     30    """
     31    Check that the argument is likely to be a valid trac issue number.
     32
     33    INPUT:
     34   
     35    - ``trac_number`` -- anything.
     36
     37    OUTPUT:
     38
     39    This function returns nothing. A ``ValueError`` is raised if the
     40    argument can not be a valid trac number.
     41
     42    EXAMPLES::
     43
     44        sage: from sage.misc.superseded import _check_trac_number
     45        sage: _check_trac_number(1)
     46        sage: _check_trac_number(int(10))
     47        sage: _check_trac_number(long(1000))
     48        sage: _check_trac_number('1')
     49        Traceback (most recent call last):
     50        ...
     51        ValueError: The argument "1" is not a valid trac issue number.
     52    """
     53    from sage.rings.integer import is_Integer
     54    err = ValueError('The argument "'+str(trac_number)+'" is not a valid trac issue number.')
     55    if not (is_Integer(trac_number) or isinstance(trac_number, (int,long))):
     56        raise err
     57    if trac_number < 0:
     58        raise err
    2959
    3060def deprecation(trac_number, message):
    3161    r"""
     
    4777        doctest:1: DeprecationWarning: the function foo is replaced by bar
    4878        See http://trac.sagemath.org/13109 for details.
    4979    """
     80    _check_trac_number(trac_number)
    5081    if trac_number is not None:
    5182        message += '\n'
    5283        message += 'See http://trac.sagemath.org/'+ str(trac_number) + ' for details.'
     
    77108            sage: g.__doc__
    78109            'Deprecated: Use :func:`number_of_partitions` instead.\nSee :trac:`13109` for details.\n\n'
    79110        """
     111        _check_trac_number(trac_number)
    80112        try:
    81113            self.__dict__.update(func.__dict__)
    82114        except AttributeError:
     
    233265     - Florent Hivert (2009-11-23), with the help of Mike Hansen.
    234266     - Luca De Feo (2011-07-11), printing the full module path when different from old path
    235267    """
     268    _check_trac_number(trac_number)
    236269    module_name = inspect.getmodulename(
    237270        inspect.currentframe(1).f_code.co_filename)
    238271    if module_name is None:
     
    294327       See http://trac.sagemath.org/13109 for details.
    295328       True
    296329    """
     330    _check_trac_number(trac_number)
    297331    if message is None:
    298332        message = '\nUsing %(name)s from here is deprecated. ' + \
    299333            'If you need to use it, please import it directly from %(module_name)s.'