[sagemath] 03/03: Revert trac #22755.
Tobias Hansen
thansen at moszumanska.debian.org
Thu Jun 29 12:58:33 UTC 2017
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository sagemath.
commit 7182fbb5ac46c554b1c6050649e808dfd746e568
Author: Tobias Hansen <thansen at debian.org>
Date: Thu Jun 29 08:07:52 2017 +0000
Revert trac #22755.
---
debian/changelog | 2 +
debian/patches/df-revert-lazy-imports-22755.patch | 825 ++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 828 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 5cdb3ad..b88ccf9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -31,6 +31,8 @@ sagemath (8.0~beta12-1) UNRELEASED; urgency=medium
- d0-singular.patch
- d1-install-paths.patch
- d1-sage-env.patch
+ * New patches:
+ - df-revert-lazy-imports-22755.patch
-- Tobias Hansen <thansen at debian.org> Thu, 08 Jun 2017 21:19:49 +0000
diff --git a/debian/patches/df-revert-lazy-imports-22755.patch b/debian/patches/df-revert-lazy-imports-22755.patch
new file mode 100644
index 0000000..9ae4cc6
--- /dev/null
+++ b/debian/patches/df-revert-lazy-imports-22755.patch
@@ -0,0 +1,825 @@
+Bug: https://trac.sagemath.org/ticket/22755
+Author: Tobias Hansen <thansen at debian.org>
+Forwarded: not-needed
+Description: Revert trac #22755
+ Revert this ticket, so that df-revert-lazy-import-dependent-on-python-patch.patch
+ can be applied. This patch contains the following commits:
+
+From 8aac18a6b165bc397ccaeaba0b596797e900b0f1 Mon Sep 17 00:00:00 2001
+From: Jeroen Demeyer <jdemeyer at cage.ugent.be>
+Date: Tue, 4 Apr 2017 13:59:03 +0200
+Subject: Various improvements to lazy imports
+
+---
+ src/sage/dynamics/all.py | 5 +-
+ src/sage/libs/mpmath/utils.pyx | 1 -
+ src/sage/misc/lazy_import.pyx | 258 +++++++++++++++++++++--------------------
+ 3 files changed, 136 insertions(+), 128 deletions(-)
+
+From f3ede0087cb94d2bce0a6edb6d99a22b1f05f8c7 Mon Sep 17 00:00:00 2001
+From: Jeroen Demeyer <jdemeyer at cage.ugent.be>
+Date: Wed, 5 Apr 2017 14:26:55 +0200
+Subject: Use exact type check in obj()
+
+---
+ src/sage/misc/lazy_import.pyx | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+From 7bf2ce87733e143d979abcd79149654c594a615c Mon Sep 17 00:00:00 2001
+From: Jeroen Demeyer <jdemeyer at cage.ugent.be>
+Date: Mon, 10 Apr 2017 19:32:26 +0200
+Subject: Partially inline LazyImport._get_object()
+
+---
+ src/sage/misc/lazy_import.pyx | 79 ++++++++++++++++++++++++-------------------
+ 1 file changed, 45 insertions(+), 34 deletions(-)
+
+
+From 4dda1ae48c5cfcf4a2b0325ae80cb7d6bfb4e2dc Mon Sep 17 00:00:00 2001
+From: Jeroen Demeyer <jdemeyer at cage.ugent.be>
+Date: Fri, 19 May 2017 20:30:52 +0200
+Subject: Fix traceback
+
+---
+ src/sage/misc/lazy_import.pyx | 11 +----------
+ 1 file changed, 1 insertion(+), 10 deletions(-)
+
+--- a/sage/src/sage/dynamics/all.py
++++ b/sage/src/sage/dynamics/all.py
+@@ -1,3 +1,2 @@
+-from sage.misc.lazy_import import lazy_import
+-lazy_import("sage.dynamics.interval_exchanges.all", "*", overwrite=False)
+-lazy_import("sage.dynamics.flat_surfaces.all", "*", overwrite=False)
++from sage.dynamics.interval_exchanges.all import *
++from sage.dynamics.flat_surfaces.all import *
+--- a/sage/src/sage/libs/mpmath/utils.pyx
++++ b/sage/src/sage/libs/mpmath/utils.pyx
+@@ -17,7 +17,6 @@
+ from sage.libs.mpfr cimport *
+ from sage.libs.gmp.all cimport *
+
+-from sage.misc.lazy_import import lazy_import
+ from sage.rings.complex_field import ComplexField
+ from sage.rings.real_mpfr cimport RealField
+
+--- a/sage/src/sage/misc/lazy_import.pyx
++++ b/sage/src/sage/misc/lazy_import.pyx
+@@ -51,24 +51,32 @@
+ # (at your option) any later version.
+ # http://www.gnu.org/licenses/
+ #*****************************************************************************
++
++# Keep OLD division semantics for Python 2 compatibility, such that
++# lazy imports support old and true division.
+ from __future__ import absolute_import
+
++cimport cython
+ from cpython.object cimport PyObject_RichCompare
++from cpython.number cimport PyNumber_TrueDivide, PyNumber_Power, PyNumber_Index
++
++cdef extern from *:
++ int likely(int) nogil # Defined by Cython
+
+ import os
+ from six.moves import cPickle as pickle
+-import operator
+ import inspect
+ from . import sageinspect
+
+ from .lazy_import_cache import get_cache_file
+
+-cdef binop(op, left, right):
+- if isinstance(left, LazyImport):
+- left = (<LazyImport>left)._get_object()
+- if isinstance(right, LazyImport):
+- right = (<LazyImport>right)._get_object()
+- return op(left, right)
++
++cdef inline obj(x):
++ if type(x) is LazyImport:
++ return (<LazyImport>x).get_object()
++ else:
++ return x
++
+
+ # boolean to determine whether Sage is still starting up
+ cdef bint startup_guard = True
+@@ -120,18 +128,16 @@
+ sage: from sage.misc.lazy_import import lazy_import
+ sage: lazy_import('sage.rings.all', 'ZZ', 'my_ZZ')
+ sage: my_ZZ(123)
+- -------------------------------------------------------------------------------
+- Resolving lazy import ZZ during startup
+- Calling stack:
++ Traceback (most recent call last):
+ ...
+- -------------------------------------------------------------------------------
+- 123
++ RuntimeError: resolving lazy import ZZ during startup
+ sage: sage.misc.lazy_import.finish_startup()
+ """
+ global startup_guard
+ startup_guard = True
+
+
++ at cython.final
+ cdef class LazyImport(object):
+ """
+ EXAMPLES::
+@@ -147,16 +153,15 @@
+ ...
+ TypeError: no conversion of this rational to integer
+ """
+-
+- cdef readonly _object
++ cdef readonly _object # The actual object if imported, None otherwise
+ cdef _module
+ cdef _name
+ cdef _as_name
+ cdef _namespace
+- cdef _at_startup
++ cdef bint _at_startup
+ cdef _deprecation
+
+- def __init__(self, module, name, as_name=None, namespace=None, at_startup=False, deprecation=None):
++ def __init__(self, module, name, as_name=None, at_startup=False, namespace=None, deprecation=None):
+ """
+ EXAMPLES::
+
+@@ -167,25 +172,25 @@
+ sage: my_isprime(55)
+ False
+ """
++ self._object = None
+ self._module = module
+ self._name = name
+- self._object = None
+- self._as_name = as_name
++ self._as_name = name if as_name is None else as_name
+ self._namespace = namespace
+ self._at_startup = at_startup
+ self._deprecation = deprecation
+
+- cpdef _get_object(self, owner=None):
++ cdef inline get_object(self):
+ """
+- Return the wrapped object, importing it if necessary.
+-
+- INPUT:
++ Faster, Cython-only partially-inlined version of ``_get_object``.
++ """
++ if likely(self._object is not None):
++ return self._object
++ return self._get_object()
+
+- - ``owner`` -- ``None`` or the class (or subclass thereof)
+- which contains this :class:`LazyImport` object in its
+- ``__dict__``.
+- - ``at_startup`` -- a boolean (default: False)
+- whether the lazy import is supposed to be resolved at startup time.
++ cpdef _get_object(self):
++ """
++ Return the wrapped object, importing it if necessary.
+
+ OUTPUT:
+
+@@ -205,70 +210,30 @@
+ sage: my_integer_ring
+ Option ``at_startup=True`` for lazy import ZZ not needed anymore
+ Integer Ring
+-
+- .. NOTE::
+-
+- For a :class:`LazyImport` object that appears in a class
+- namespace, we need to do something special. Indeed, the
+- class namespace dictionary at the time of the class
+- definition is not the one that actually gets used. Thus,
+- when this function is called, :meth:`__get__`, ``owner``
+- should be set to the ``owner`` class passed into
+- ``__get__``::
+-
+- sage: class Foo(object):
+- ....: lazy_import('sage.all', 'plot')
+- sage: class Bar(Foo):
+- ....: pass
+- sage: type(Foo.__dict__['plot'])
+- <type 'sage.misc.lazy_import.LazyImport'>
+-
+- Here is how :meth:`_get_object` is called internally upon
+- ``Bar.plot``::
+-
+- sage: Foo.__dict__['plot']._get_object(Bar)
+- <function plot at ...>
+-
+- Now ``Bar`` has been replaced in the dictionary of ``Foo``::
+-
+- sage: type(Foo.__dict__['plot'])
+- <... 'function'>
+ """
+ if self._object is not None:
+ return self._object
+
+ if startup_guard and not self._at_startup:
+- import sys, traceback
+- print('-' * 79)
+- print('Resolving lazy import {0} during startup'.format(self._name))
+- print('Calling stack:')
+- traceback.print_stack(None, None, sys.stdout)
+- print('-' * 79)
++ raise RuntimeError(f"resolving lazy import {self._name} during startup")
+ elif self._at_startup and not startup_guard:
+ print('Option ``at_startup=True`` for lazy import {0} not needed anymore'.format(self._name))
+ self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name)
+- alias = self._as_name or self._name
++ name = self._as_name
+ if self._deprecation is not None:
+ from sage.misc.superseded import deprecation
+ try:
+ trac_number, message = self._deprecation
+ except TypeError:
+ trac_number = self._deprecation
+- message = None
+- if message is None:
+ message = ('\nImporting {name} from here is deprecated. ' +
+ 'If you need to use it, please import it directly from' +
+- ' {module_name}').format(name=alias, module_name=self._module)
++ ' {module_name}').format(name=name, module_name=self._module)
+ deprecation(trac_number, message)
+- if owner is None:
+- if self._namespace and self._namespace[alias] is self:
+- self._namespace[alias] = self._object
+- else:
+- from inspect import getmro
+- for cls in getmro(owner):
+- if cls.__dict__.get(alias, None) is self:
+- setattr(cls, alias, self._object)
+- break
++ # Replace the lazy import in the namespace by the actual object
++ if self._namespace is not None:
++ if self._namespace.get(name) is self:
++ self._namespace[name] = self._object
+ return self._object
+
+ def _get_deprecation_ticket(self):
+@@ -314,7 +279,7 @@
+ sage: 'A subset of the real line' in RealSet.__doc__
+ True
+ """
+- return sageinspect.sage_getdoc_original(self._get_object())
++ return sageinspect.sage_getdoc_original(self.get_object())
+
+ def _sage_src_(self):
+ """
+@@ -327,7 +292,7 @@
+ sage: 'def is_prime(' in my_isprime._sage_src_()
+ True
+ """
+- return sageinspect.sage_getsource(self._get_object())
++ return sageinspect.sage_getsource(self.get_object())
+
+ def _sage_argspec_(self):
+ """
+@@ -340,7 +305,7 @@
+ sage: rm._sage_argspec_()
+ ArgSpec(args=['ring', 'nrows', 'ncols', 'algorithm'], varargs='args', keywords='kwds', defaults=(None, 'randomize'))
+ """
+- return sageinspect.sage_getargspec(self._get_object())
++ return sageinspect.sage_getargspec(self.get_object())
+
+ def __getattr__(self, attr):
+ """
+@@ -354,7 +319,7 @@
+ sage: my_integer.sqrt is Integer.sqrt
+ True
+ """
+- return getattr(self._get_object(), attr)
++ return getattr(self.get_object(), attr)
+
+ # We need to wrap all the slot methods, as they are not forwarded
+ # via getattr.
+@@ -371,7 +336,7 @@
+ sage: dir(my_ZZ) == dir(ZZ)
+ True
+ """
+- return dir(self._get_object())
++ return dir(self.get_object())
+
+ def __call__(self, *args, **kwds):
+ """
+@@ -386,7 +351,7 @@
+ sage: my_isprime(13)
+ True
+ """
+- return self._get_object()(*args, **kwds)
++ return self.get_object()(*args, **kwds)
+
+ def __repr__(self):
+ """
+@@ -400,7 +365,7 @@
+ sage: repr(lazy_ZZ)
+ 'Integer Ring'
+ """
+- return repr(self._get_object())
++ return repr(self.get_object())
+
+ def __str__(self):
+ """
+@@ -410,7 +375,7 @@
+ sage: str(lazy_ZZ)
+ 'Integer Ring'
+ """
+- return str(self._get_object())
++ return str(self.get_object())
+
+ def __unicode__(self):
+ """
+@@ -420,7 +385,7 @@
+ sage: unicode(lazy_ZZ)
+ u'Integer Ring'
+ """
+- return unicode(self._get_object())
++ return unicode(self.get_object())
+
+ def __nonzero__(self):
+ """
+@@ -430,7 +395,7 @@
+ sage: not lazy_ZZ
+ True
+ """
+- return not self._get_object()
++ return not self.get_object()
+
+ def __hash__(self):
+ """
+@@ -440,7 +405,7 @@
+ sage: hash(lazy_ZZ) == hash(1.parent())
+ True
+ """
+- return hash(self._get_object())
++ return hash(self.get_object())
+
+ def __cmp__(left, right):
+ """
+@@ -467,11 +432,7 @@
+ sage: lazy_ZZ == 1.parent()
+ True
+ """
+- if isinstance(left, LazyImport):
+- left = (<LazyImport>left)._get_object()
+- if isinstance(right, LazyImport):
+- right = (<LazyImport>right)._get_object()
+- return PyObject_RichCompare(left, right, op)
++ return PyObject_RichCompare(obj(left), obj(right), op)
+
+ def __len__(self):
+ """
+@@ -483,7 +444,7 @@
+ sage: len(version_info)
+ 5
+ """
+- return len(self._get_object())
++ return len(self.get_object())
+
+ def __get__(self, instance, owner):
+ """
+@@ -516,11 +477,49 @@
+ :class:`LazyImport` object with the actual object. See the
+ documentation of :meth:`_get_object` for an explanation of
+ this.
++
++ .. NOTE::
++
++ For a :class:`LazyImport` object that appears in a class
++ namespace, we need to do something special. Indeed, the
++ class namespace dictionary at the time of the class
++ definition is not the one that actually gets used. Thus,
++ ``__get__`` needs to manually modify the class dict::
++
++ sage: class Foo(object):
++ ....: lazy_import('sage.all', 'plot')
++ sage: class Bar(Foo):
++ ....: pass
++ sage: type(Foo.__dict__['plot'])
++ <type 'sage.misc.lazy_import.LazyImport'>
++
++ We access the ``plot`` method::
++
++ sage: Bar.plot
++ <unbound method Bar.plot>
++
++ Now ``plot`` has been replaced in the dictionary of ``Foo``::
++
++ sage: type(Foo.__dict__['plot'])
++ <... 'function'>
+ """
+- obj = self._get_object(owner)
+- if hasattr(obj, "__get__"):
+- return obj.__get__(instance, owner)
+- return obj
++ # Don't use the namespace of the class definition
++ self._namespace = None
++ obj = self.get_object()
++
++ name = self._as_name
++ for cls in inspect.getmro(owner):
++ if cls.__dict__.get(name) is self:
++ setattr(cls, name, obj)
++ break
++
++ # Check whether the imported object is itself a descriptor
++ try:
++ get = obj.__get__
++ except AttributeError:
++ return obj
++ else:
++ return get(instance, owner)
+
+ def __getitem__(self, key):
+ """
+@@ -532,7 +531,7 @@
+ sage: version_info[0]
+ 2
+ """
+- return self._get_object()[key]
++ return self.get_object()[key]
+
+ def __setitem__(self, key, value):
+ """
+@@ -546,7 +545,7 @@
+ sage: print(foo)
+ [0, 100, 2, 3, 4, 5, 6, 7, 8, 9]
+ """
+- self._get_object()[key] = value
++ self.get_object()[key] = value
+
+ def __delitem__(self, key):
+ """
+@@ -560,7 +559,7 @@
+ sage: print(foo)
+ [0, 2, 3, 4, 5, 6, 7, 8, 9]
+ """
+- del self._get_object()[key]
++ del self.get_object()[key]
+
+ def __iter__(self):
+ """
+@@ -572,7 +571,7 @@
+ sage: iter(version_info)
+ <iterator object at ...>
+ """
+- return iter(self._get_object())
++ return iter(self.get_object())
+
+ def __contains__(self, item):
+ """
+@@ -590,7 +589,7 @@
+ sage: 2000 not in version_info
+ True
+ """
+- return item in self._get_object()
++ return item in self.get_object()
+
+ def __add__(left, right):
+ """
+@@ -603,7 +602,7 @@
+ sage: foo + 1
+ 11
+ """
+- return binop(operator.add, left, right)
++ return obj(left) + obj(right)
+
+ def __sub__(left, right):
+ """
+@@ -616,7 +615,7 @@
+ sage: foo - 1
+ 9
+ """
+- return binop(operator.sub, left, right)
++ return obj(left) - obj(right)
+
+ def __mul__(left, right):
+ """
+@@ -629,7 +628,23 @@
+ sage: foo * 2
+ 20
+ """
+- return binop(operator.mul, left, right)
++ return obj(left) * obj(right)
++
++ def __matmul__(left, right):
++ """
++ TESTS::
++
++ sage: from sympy import Matrix
++ sage: sage.all.foo = Matrix([[1,1],[0,1]])
++ sage: lazy_import('sage.all', 'foo')
++ sage: type(foo)
++ <type 'sage.misc.lazy_import.LazyImport'>
++ sage: foo.__matmul__(foo)
++ Matrix([
++ [1, 2],
++ [0, 1]])
++ """
++ return obj(left) @ obj(right)
+
+ def __div__(left, right):
+ """
+@@ -642,7 +657,7 @@
+ sage: foo / 2
+ 5
+ """
+- return binop(operator.div, left, right)
++ return obj(left) / obj(right)
+
+ def __floordiv__(left, right):
+ """
+@@ -655,7 +670,7 @@
+ sage: foo // 3
+ 3
+ """
+- return binop(operator.floordiv, left, right)
++ return obj(left) // obj(right)
+
+ def __truediv__(left, right):
+ """
+@@ -668,7 +683,7 @@
+ sage: operator.truediv(foo, 3)
+ 10/3
+ """
+- return binop(operator.truediv, left, right)
++ return PyNumber_TrueDivide(obj(left), obj(right))
+
+ def __pow__(left, right, mod):
+ """
+@@ -681,14 +696,7 @@
+ sage: foo ** 2
+ 100
+ """
+- if isinstance(left, LazyImport):
+- left = (<LazyImport>left)._get_object()
+- if isinstance(right, LazyImport):
+- right = (<LazyImport>right)._get_object()
+- if mod is None:
+- return left ** right
+- else:
+- return left.__pow__(right, mod)
++ return PyNumber_Power(obj(left), obj(right), obj(mod))
+
+ def __mod__(left, right):
+ """
+@@ -701,7 +709,7 @@
+ sage: foo % 7
+ 3
+ """
+- return binop(operator.mod, left, right)
++ return obj(left) % obj(right)
+
+ def __lshift__(left, right):
+ """
+@@ -714,7 +722,7 @@
+ sage: foo << 3
+ 80
+ """
+- return binop(operator.lshift, left, right)
++ return obj(left) << obj(right)
+
+ def __rshift__(left, right):
+ """
+@@ -727,7 +735,7 @@
+ sage: foo >> 2
+ 2
+ """
+- return binop(operator.rshift, left, right)
++ return obj(left) >> obj(right)
+
+ def __and__(left, right):
+ """
+@@ -740,7 +748,7 @@
+ sage: foo & 7
+ 2
+ """
+- return binop(operator.and_, left, right)
++ return obj(left) & obj(right)
+
+ def __or__(left, right):
+ """
+@@ -753,7 +761,7 @@
+ sage: foo | 7
+ 15
+ """
+- return binop(operator.or_, left, right)
++ return obj(left) | obj(right)
+
+ def __xor__(left, right):
+ """
+@@ -766,7 +774,7 @@
+ sage: foo ^^ 7
+ 13
+ """
+- return binop(operator.xor, left, right)
++ return obj(left) ^ obj(right)
+
+ def __neg__(self):
+ """
+@@ -779,7 +787,7 @@
+ sage: -foo
+ -10
+ """
+- return -self._get_object()
++ return -self.get_object()
+
+ def __pos__(self):
+ """
+@@ -792,7 +800,7 @@
+ sage: +foo
+ 10
+ """
+- return +self._get_object()
++ return +self.get_object()
+
+ def __abs__(self):
+ """
+@@ -805,7 +813,7 @@
+ sage: abs(foo)
+ 1000
+ """
+- return abs(self._get_object())
++ return abs(self.get_object())
+
+ def __invert__(self):
+ """
+@@ -818,7 +826,7 @@
+ sage: ~foo
+ 1/10
+ """
+- return ~self._get_object()
++ return ~self.get_object()
+
+ def __complex__(self):
+ """
+@@ -831,7 +839,7 @@
+ sage: complex(foo)
+ (10+0j)
+ """
+- return complex(self._get_object())
++ return complex(self.get_object())
+
+ def __int__(self):
+ """
+@@ -844,7 +852,7 @@
+ sage: int(foo)
+ 10
+ """
+- return int(self._get_object())
++ return int(self.get_object())
+
+ def __long__(self):
+ """
+@@ -857,7 +865,7 @@
+ sage: long(foo)
+ 10L
+ """
+- return long(self._get_object())
++ return long(self.get_object())
+
+ def __float__(self):
+ """
+@@ -870,7 +878,7 @@
+ sage: float(foo)
+ 10.0
+ """
+- return float(self._get_object())
++ return float(self.get_object())
+
+ def __oct__(self):
+ """
+@@ -883,7 +891,7 @@
+ sage: oct(foo)
+ '12'
+ """
+- return oct(self._get_object())
++ return oct(self.get_object())
+
+ def __hex__(self):
+ """
+@@ -896,7 +904,7 @@
+ sage: hex(foo)
+ 'a'
+ """
+- return hex(self._get_object())
++ return hex(self.get_object())
+
+ def __index__(self):
+ """
+@@ -909,7 +917,7 @@
+ sage: list(range(100))[foo]
+ 10
+ """
+- return operator.index(self._get_object())
++ return PyNumber_Index(self.get_object())
+
+ def __copy__(self):
+ """
+@@ -924,7 +932,7 @@
+ sage: copy(foo)
+ 10
+ """
+- return self._get_object()
++ return self.get_object()
+
+ def __deepcopy__(self, memo=None):
+ """
+@@ -939,7 +947,7 @@
+ sage: deepcopy(foo)
+ 10
+ """
+- return self._get_object()
++ return self.get_object()
+
+ def __instancecheck__(self, x):
+ """
+@@ -951,7 +959,7 @@
+ sage: isinstance(QQ, RationalField)
+ True
+ """
+- return isinstance(x, self._get_object())
++ return isinstance(x, self.get_object())
+
+ def __subclasscheck__(self, x):
+ """
+@@ -963,10 +971,11 @@
+ sage: issubclass(RationalField, Parent)
+ True
+ """
+- return issubclass(x, self._get_object())
++ return issubclass(x, self.get_object())
+
+
+-def lazy_import(module, names, _as=None, namespace=None, bint overwrite=True, at_startup=False, deprecation=None):
++def lazy_import(module, names, as_=None, *,
++ at_startup=False, namespace=None, overwrite=None, deprecation=None):
+ """
+ Create a lazy import object and inject it into the caller's global
+ namespace. For the purposes of introspection and calling, this is
+@@ -980,18 +989,16 @@
+ - ``names`` -- a string or list of strings representing the names to
+ import from module
+
+- - ``_as`` -- (optional) a string or list of strings representing the
+- aliases of the names imported
+-
+- - ``namespace`` -- the namespace where importing the names; by default,
+- import the names to current namespace
+-
+- - ``overwrite`` -- (default: ``True``) if set to ``True`` and a name is
+- already in the namespace, overwrite it with the lazy_import-ed name
++ - ``as_`` -- (optional) a string or list of strings representing the
++ names of the objects in the importing module. This is analogous to
++ ``from ... import ... as ...``.
+
+ - ``at_startup`` -- a boolean (default: ``False``);
+ whether the lazy import is supposed to be resolved at startup time
+
++ - ``namespace`` -- the namespace where importing the names; by default,
++ import the names to current namespace
++
+ - ``deprecation`` -- (optional) if not ``None``, a deprecation warning
+ will be issued when the object is actually imported;
+ ``deprecation`` should be either a trac number (integer) or a
+@@ -1060,21 +1067,26 @@
+ See http://trac.sagemath.org/14275 for details.
+ 5-adic Field with capped relative precision 20
+ """
+- if _as is None:
+- _as = names
+- if isinstance(names, str):
++ if overwrite is not None:
++ from sage.misc.superseded import deprecation
++ deprecation(22755, "lazy_import(overwrite=False) is no longer supported")
++ if as_ is None:
++ as_ = names
++ if isinstance(names, basestring):
+ names = [names]
+- _as = [_as]
++ as_ = [as_]
++ else:
++ names = list(names)
++ as_ = list(as_)
+ if namespace is None:
+ namespace = inspect.currentframe().f_locals
+ if "*" in names:
+ ix = names.index("*")
+- names[ix:ix+1] = get_star_imports(module)
+- _as[ix:ix+1] = [None] * (len(names) - len(_as) + 1)
+- for name, alias in zip(names, _as):
+- if not overwrite and (alias or name) in namespace:
+- continue
+- namespace[alias or name] = LazyImport(module, name, alias, namespace, at_startup, deprecation)
++ all = get_star_imports(module)
++ names[ix:ix+1] = all
++ as_[ix:ix+1] = all
++ for name, alias in zip(names, as_):
++ namespace[alias] = LazyImport(module, name, alias, at_startup, namespace, deprecation)
+
+
+ star_imports = None
diff --git a/debian/patches/series b/debian/patches/series
index 9c9e93c..256cc08 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -52,6 +52,7 @@ d1-disable-post-install-tests.patch
# Potentially controversial fixes
# We had to do these to make things work, at some time in the past
# It may be possible to drop these now or in the future; test that first.
+df-revert-lazy-imports-22755.patch -R
df-revert-lazy-import-dependent-on-python-patch.patch
df-revert-minor-feature-dependent-on-python-patch.patch
df-disable-custom-sphinx-logger.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagemath.git
More information about the debian-science-commits
mailing list