Ticket #5994: trac_5994.patch

File trac_5994.patch, 1.6 KB (added by was, 12 years ago)
  • sage/interfaces/singular.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1263819919 28800
    # Node ID 1fdb72354b442658dfb8c60698082888532b1db4
    # Parent  7d50c449439b1109e1efbbdfaad10ee807322910
    trac 5994 -- singular.version() yields an error when first called, has no doctest, and has a strange output imo
    
    diff -r 7d50c449439b -r 1fdb72354b44 sage/interfaces/singular.py
    a b  
    10161016    def version(self):
    10171017        """
    10181018        EXAMPLES:
     1019
     1020            sage: singular.version()
     1021            ((3, ..., ...), 'Singular for ...')
    10191022        """
    10201023        return singular_version()
    10211024
     
    18911894def singular_version():
    18921895    """
    18931896    Returns the version of Singular being used.
     1897
     1898    OUTPUT:
     1899
     1900       - 3-tuple
     1901       - Version string
    18941902   
    18951903    EXAMPLES:
     1904
     1905   
     1906        sage: singular_version()
     1907        ((3, ..., ...), 'Singular for ...')
    18961908    """
    1897     return singular.eval('system("--version");')
     1909    # We have a try/except here, since the interface may rase an error
     1910    # the first time we call system, if the help.cnf file isn't
     1911    # available.  We just call again in that case.
     1912    try:
     1913        s = singular.eval('system("--version");')
     1914    except RuntimeError:
     1915        s = singular.eval('system("--version");')
     1916    s = s.splitlines()[0]
     1917    # Get the actual version string.
     1918    i = s.find('version')
     1919    Z = sage.rings.integer.Integer
     1920    VERSION = tuple([Z(a) for a in s[i:].split()[1].split('-')])
     1921    return (VERSION, s)
    18981922
    18991923
    19001924