Skip to content

Commit

Permalink
sagemathgh-37868: sage.misc.misc: Remove deprecated code
Browse files Browse the repository at this point in the history
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Remove code deprecated in
- sagemath#32987 (2022)
- sagemath#33213 (2022)
- sagemath#29869 (2020)
- sagemath#17815 (2020)
- sagemath#29892 (2020)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#37868
Reported by: Matthias Köppe
Reviewer(s): Michael Orlitzky
  • Loading branch information
Release Manager committed May 1, 2024
2 parents b14d3ec + 6d9c5fa commit c46302c
Showing 1 changed file with 0 additions and 156 deletions.
156 changes: 0 additions & 156 deletions src/sage/misc/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@
lazy_import("sage.combinat.subset", ["powerset", "subsets", "uniq"],
deprecation=35564)

lazy_import("sage.misc.call", ["AttrCallObject", "attrcall", "call_method"],
deprecation=29869)

lazy_import("sage.misc.verbose", ["verbose", "set_verbose", "set_verbose_files",
"get_verbose_files", "unset_verbose_files", "get_verbose"],
deprecation=17815)

lazy_import("sage.misc.repr", ["coeff_repr", "repr_lincomb"],
deprecation=29892)

lazy_import("sage.misc.timing", ["cputime", "GlobalCputime", "walltime"],
deprecation=35816)

Expand All @@ -71,44 +61,6 @@
# File and directory utilities
#################################################################


def sage_makedirs(dirname, mode=0o777):
"""
Python version of ``mkdir -p``: try to create a directory, and also
create all intermediate directories as necessary. Succeed silently
if the directory already exists (unlike ``os.makedirs()``).
Raise other errors (like permission errors) normally.
This function is deprecated; use ``os.makedirs(..., exist_ok=True)``
instead.
EXAMPLES::
sage: from sage.misc.misc import sage_makedirs
sage: sage_makedirs(DOT_SAGE) # no output
doctest:warning...
DeprecationWarning: sage_makedirs is deprecated; use os.makedirs(..., exist_ok=True) instead
See https://github.com/sagemath/sage/issues/32987 for details.
The following fails because we are trying to create a directory in
place of an ordinary file::
sage: filename = tmp_filename()
sage: sage_makedirs(filename)
Traceback (most recent call last):
...
FileExistsError: [Errno ...] File exists: ...
"""
from sage.misc.superseded import deprecation
deprecation(32987,
'sage_makedirs is deprecated; use os.makedirs(..., exist_ok=True) instead')
try:
os.makedirs(dirname)
except OSError:
if not os.path.isdir(dirname):
raise


# We create the DOT_SAGE directory (if it does not exist yet; note in particular
# that it may already have been created by the bin/sage script) with
# restrictive permissions, since otherwise possibly just anybody can easily see
Expand Down Expand Up @@ -216,79 +168,6 @@ def try_read(obj, splitlines=False):
return data


#################################################
# Next we create the Sage temporary directory.
#################################################


@lazy_string
def SAGE_TMP():
"""
EXAMPLES::
sage: from sage.misc.misc import SAGE_TMP
sage: SAGE_TMP
doctest:warning...
DeprecationWarning: SAGE_TMP is deprecated; please use python's
"tempfile" module instead.
See https://github.com/sagemath/sage/issues/33213 for details.
l'.../temp/...'
"""
from sage.misc.superseded import deprecation
deprecation(33213, "SAGE_TMP is deprecated; please use python's \"tempfile\" module instead.")
d = os.path.join(DOT_SAGE, 'temp', HOSTNAME, str(os.getpid()))
os.makedirs(d, exist_ok=True)
return d


@lazy_string
def ECL_TMP():
"""
Temporary directory that should be used by ECL interfaces launched from
Sage.
EXAMPLES::
sage: from sage.misc.misc import ECL_TMP
sage: ECL_TMP
doctest:warning...
DeprecationWarning: ECL_TMP is deprecated and is no longer used
by the ECL interface in sage
See https://github.com/sagemath/sage/issues/33213 for details.
...
"""
from sage.misc.superseded import deprecation
deprecation(33213, "ECL_TMP is deprecated and is no longer used by the ECL interface in sage")
import atexit
import tempfile
d = tempfile.TemporaryDirectory()
result = os.path.join(d.name, 'ecl')
atexit.register(lambda: d.cleanup())
return result


@lazy_string
def SPYX_TMP():
r"""
EXAMPLES::
sage: from sage.misc.misc import SPYX_TMP
sage: SPYX_TMP
doctest:warning...
DeprecationWarning: SPYX_TMP is deprecated;
use sage.misc.temporary_file.spyx_tmp instead
See https://github.com/sagemath/sage/issues/33213 for details.
...
"""
from sage.misc.temporary_file import spyx_tmp
from sage.misc.superseded import deprecation
deprecation(33213, "SPYX_TMP is deprecated; use sage.misc.temporary_file.spyx_tmp instead")
return spyx_tmp()


SAGE_DB = os.path.join(DOT_SAGE, 'db')
os.makedirs(SAGE_DB, exist_ok=True)

Expand All @@ -299,41 +178,6 @@ def SPYX_TMP():
pass


def union(x, y=None):
"""
Return the union of x and y, as a list. The resulting list need not
be sorted and can change from call to call.
INPUT:
- ``x`` - iterable
- ``y`` - iterable (may optionally omitted)
OUTPUT: list
EXAMPLES::
sage: answer = union([1,2,3,4], [5,6]); answer
doctest:...: DeprecationWarning: sage.misc.misc.union is deprecated...
See https://github.com/sagemath/sage/issues/32096 for details.
[1, 2, 3, 4, 5, 6]
sage: union([1,2,3,4,5,6], [5,6]) == answer
True
sage: union((1,2,3,4,5,6), [5,6]) == answer
True
sage: union((1,2,3,4,5,6), set([5,6])) == answer
True
"""
from sage.misc.superseded import deprecation
deprecation(32096, "sage.misc.misc.union is deprecated, use 'list(set(x).union(y))' or a more suitable replacement")
if y is None:
return list(set(x))
return list(set(x).union(y))


def exactly_one_is_true(iterable):
r"""
Return whether exactly one element of ``iterable`` evaluates ``True``.
Expand Down

0 comments on commit c46302c

Please sign in to comment.