# 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
|
|
1016 | 1016 | def version(self): |
1017 | 1017 | """ |
1018 | 1018 | EXAMPLES: |
| 1019 | |
| 1020 | sage: singular.version() |
| 1021 | ((3, ..., ...), 'Singular for ...') |
1019 | 1022 | """ |
1020 | 1023 | return singular_version() |
1021 | 1024 | |
… |
… |
|
1891 | 1894 | def singular_version(): |
1892 | 1895 | """ |
1893 | 1896 | Returns the version of Singular being used. |
| 1897 | |
| 1898 | OUTPUT: |
| 1899 | |
| 1900 | - 3-tuple |
| 1901 | - Version string |
1894 | 1902 | |
1895 | 1903 | EXAMPLES: |
| 1904 | |
| 1905 | |
| 1906 | sage: singular_version() |
| 1907 | ((3, ..., ...), 'Singular for ...') |
1896 | 1908 | """ |
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) |
1898 | 1922 | |
1899 | 1923 | |
1900 | 1924 | |