[sagemath] 01/01: Unfortunately dpkg-source does not like -R

Ximin Luo infinity0 at debian.org
Wed Jul 5 08:14:50 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository sagemath.

commit 0fd550801c52e4b75c3ad1463c0f2fa7309e7459
Author: Ximin Luo <infinity0 at debian.org>
Date:   Wed Jul 5 10:14:37 2017 +0200

    Unfortunately dpkg-source does not like -R
---
 debian/patches/df-revert-lazy-imports-22755.patch | 767 +++++++++++-----------
 debian/patches/series                             |   2 +-
 2 files changed, 385 insertions(+), 384 deletions(-)

diff --git a/debian/patches/df-revert-lazy-imports-22755.patch b/debian/patches/df-revert-lazy-imports-22755.patch
index 9ae4cc6..fb9dca4 100644
--- a/debian/patches/df-revert-lazy-imports-22755.patch
+++ b/debian/patches/df-revert-lazy-imports-22755.patch
@@ -46,780 +46,781 @@ Subject: Fix traceback
 
 --- 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 *
+@@ -1,2 +1,3 @@
+-from sage.dynamics.interval_exchanges.all import *
+-from sage.dynamics.flat_surfaces.all import *
++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)
 --- a/sage/src/sage/libs/mpmath/utils.pyx
 +++ b/sage/src/sage/libs/mpmath/utils.pyx
-@@ -17,7 +17,6 @@
+@@ -17,6 +17,7 @@
  from sage.libs.mpfr cimport *
  from sage.libs.gmp.all cimport *
  
--from sage.misc.lazy_import import lazy_import
++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 @@
+@@ -51,32 +51,24 @@
  # (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.
+-
+-# Keep OLD division semantics for Python 2 compatibility, such that
+-# lazy imports support old and true division.
  from __future__ import absolute_import
  
-+cimport cython
+-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
+-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 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
-+
+-
+-cdef inline obj(x):
+-    if type(x) is LazyImport:
+-        return (<LazyImport>x).get_object()
+-    else:
+-        return x
+-
++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)
  
  # boolean to determine whether Sage is still starting up
  cdef bint startup_guard = True
-@@ -120,18 +128,16 @@
+@@ -128,16 +120,18 @@
          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):
+-        Traceback (most recent call last):
++        -------------------------------------------------------------------------------
++        Resolving lazy import ZZ during startup
++        Calling stack:
          ...
--        -------------------------------------------------------------------------------
--        123
-+        RuntimeError: resolving lazy import ZZ during startup
+-        RuntimeError: resolving lazy import ZZ during startup
++        -------------------------------------------------------------------------------
++        123
          sage: sage.misc.lazy_import.finish_startup()
      """
      global startup_guard
      startup_guard = True
  
  
-+ at cython.final
+- at cython.final
  cdef class LazyImport(object):
      """
      EXAMPLES::
-@@ -147,16 +153,15 @@
+@@ -153,15 +147,16 @@
          ...
          TypeError: no conversion of this rational to integer
      """
--
--    cdef readonly _object
-+    cdef readonly _object  # The actual object if imported, None otherwise
+-    cdef readonly _object  # The actual object if imported, None otherwise
++
++    cdef readonly _object
      cdef _module
      cdef _name
      cdef _as_name
      cdef _namespace
--    cdef _at_startup
-+    cdef bint _at_startup
+-    cdef bint _at_startup
++    cdef _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):
+-    def __init__(self, module, name, as_name=None, at_startup=False, namespace=None, deprecation=None):
++    def __init__(self, module, name, as_name=None, namespace=None, at_startup=False, deprecation=None):
          """
          EXAMPLES::
  
-@@ -167,25 +172,25 @@
+@@ -172,26 +167,26 @@
              sage: my_isprime(55)
              False
          """
-+        self._object = None
+-        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._as_name = name if as_name is None else as_name
++        self._object = None
++        self._as_name = 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.
+-    cdef inline get_object(self):
+-        """
+-        Faster, Cython-only partially-inlined version of ``_get_object``.
+-        """
+-        if likely(self._object is not None):
+-            return self._object
+-        return self._get_object()
 -
--        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.
+-    cpdef _get_object(self):
++    cpdef _get_object(self, owner=None):
+         """
+         Return the wrapped object, importing it if necessary.
  
++        INPUT:
++
++        - ``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.
++
          OUTPUT:
  
-@@ -205,70 +210,30 @@
+         - the wrapped object
+@@ -210,30 +205,70 @@
              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'>
++
++        .. 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")
+-            raise RuntimeError(f"resolving lazy import {self._name} during 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)
          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
+-        name = self._as_name
++        alias = self._as_name or self._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 = 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)
+-                    ' {module_name}').format(name=name, module_name=self._module)
++                    ' {module_name}').format(name=alias, 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
+-        # 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
++        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
          return self._object
  
      def _get_deprecation_ticket(self):
-@@ -314,7 +279,7 @@
+@@ -279,7 +314,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())
+-        return sageinspect.sage_getdoc_original(self.get_object())
++        return sageinspect.sage_getdoc_original(self._get_object())
  
      def _sage_src_(self):
          """
-@@ -327,7 +292,7 @@
+@@ -292,7 +327,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())
+-        return sageinspect.sage_getsource(self.get_object())
++        return sageinspect.sage_getsource(self._get_object())
  
      def _sage_argspec_(self):
          """
-@@ -340,7 +305,7 @@
+@@ -305,7 +340,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())
+-        return sageinspect.sage_getargspec(self.get_object())
++        return sageinspect.sage_getargspec(self._get_object())
  
      def __getattr__(self, attr):
          """
-@@ -354,7 +319,7 @@
+@@ -319,7 +354,7 @@
              sage: my_integer.sqrt is Integer.sqrt
              True
          """
--        return getattr(self._get_object(), attr)
-+        return getattr(self.get_object(), attr)
+-        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 @@
+@@ -336,7 +371,7 @@
              sage: dir(my_ZZ) == dir(ZZ)
              True
          """
--        return dir(self._get_object())
-+        return dir(self.get_object())
+-        return dir(self.get_object())
++        return dir(self._get_object())
  
      def __call__(self, *args, **kwds):
          """
-@@ -386,7 +351,7 @@
+@@ -351,7 +386,7 @@
              sage: my_isprime(13)
              True
          """
--        return self._get_object()(*args, **kwds)
-+        return self.get_object()(*args, **kwds)
+-        return self.get_object()(*args, **kwds)
++        return self._get_object()(*args, **kwds)
  
      def __repr__(self):
          """
-@@ -400,7 +365,7 @@
+@@ -365,7 +400,7 @@
              sage: repr(lazy_ZZ)
              'Integer Ring'
          """
--        return repr(self._get_object())
-+        return repr(self.get_object())
+-        return repr(self.get_object())
++        return repr(self._get_object())
  
      def __str__(self):
          """
-@@ -410,7 +375,7 @@
+@@ -375,7 +410,7 @@
              sage: str(lazy_ZZ)
              'Integer Ring'
          """
--        return str(self._get_object())
-+        return str(self.get_object())
+-        return str(self.get_object())
++        return str(self._get_object())
  
      def __unicode__(self):
          """
-@@ -420,7 +385,7 @@
+@@ -385,7 +420,7 @@
              sage: unicode(lazy_ZZ)
              u'Integer Ring'
          """
--        return unicode(self._get_object())
-+        return unicode(self.get_object())
+-        return unicode(self.get_object())
++        return unicode(self._get_object())
  
      def __nonzero__(self):
          """
-@@ -430,7 +395,7 @@
+@@ -395,7 +430,7 @@
              sage: not lazy_ZZ
              True
          """
--        return not self._get_object()
-+        return not self.get_object()
+-        return not self.get_object()
++        return not self._get_object()
  
      def __hash__(self):
          """
-@@ -440,7 +405,7 @@
+@@ -405,7 +440,7 @@
              sage: hash(lazy_ZZ) == hash(1.parent())
              True
          """
--        return hash(self._get_object())
-+        return hash(self.get_object())
+-        return hash(self.get_object())
++        return hash(self._get_object())
  
      def __cmp__(left, right):
          """
-@@ -467,11 +432,7 @@
+@@ -432,7 +467,11 @@
              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)
+-        return PyObject_RichCompare(obj(left), obj(right), op)
++        if isinstance(left, LazyImport):
++            left = (<LazyImport>left)._get_object()
++        if isinstance(right, LazyImport):
++            right = (<LazyImport>right)._get_object()
++        return PyObject_RichCompare(left, right, op)
  
      def __len__(self):
          """
-@@ -483,7 +444,7 @@
+@@ -444,7 +483,7 @@
              sage: len(version_info)
              5
          """
--        return len(self._get_object())
-+        return len(self.get_object())
+-        return len(self.get_object())
++        return len(self._get_object())
  
      def __get__(self, instance, owner):
          """
-@@ -516,11 +477,49 @@
+@@ -477,49 +516,11 @@
          :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'>
+-
+-        .. 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)
+-        # 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)
++        obj = self._get_object(owner)
++        if hasattr(obj, "__get__"):
++            return obj.__get__(instance, owner)
++        return obj
  
      def __getitem__(self, key):
          """
-@@ -532,7 +531,7 @@
+@@ -531,7 +532,7 @@
              sage: version_info[0]
              2
          """
--        return self._get_object()[key]
-+        return self.get_object()[key]
+-        return self.get_object()[key]
++        return self._get_object()[key]
  
      def __setitem__(self, key, value):
          """
-@@ -546,7 +545,7 @@
+@@ -545,7 +546,7 @@
              sage: print(foo)
              [0, 100, 2, 3, 4, 5, 6, 7, 8, 9]
          """
--        self._get_object()[key] = value
-+        self.get_object()[key] = value
+-        self.get_object()[key] = value
++        self._get_object()[key] = value
  
      def __delitem__(self, key):
          """
-@@ -560,7 +559,7 @@
+@@ -559,7 +560,7 @@
              sage: print(foo)
              [0, 2, 3, 4, 5, 6, 7, 8, 9]
          """
--        del self._get_object()[key]
-+        del self.get_object()[key]
+-        del self.get_object()[key]
++        del self._get_object()[key]
  
      def __iter__(self):
          """
-@@ -572,7 +571,7 @@
+@@ -571,7 +572,7 @@
              sage: iter(version_info)
              <iterator object at ...>
          """
--        return iter(self._get_object())
-+        return iter(self.get_object())
+-        return iter(self.get_object())
++        return iter(self._get_object())
  
      def __contains__(self, item):
          """
-@@ -590,7 +589,7 @@
+@@ -589,7 +590,7 @@
              sage: 2000 not in version_info
              True
          """
--        return item in self._get_object()
-+        return item in self.get_object()
+-        return item in self.get_object()
++        return item in self._get_object()
  
      def __add__(left, right):
          """
-@@ -603,7 +602,7 @@
+@@ -602,7 +603,7 @@
              sage: foo + 1
              11
          """
--        return binop(operator.add, left, right)
-+        return obj(left) + obj(right)
+-        return obj(left) + obj(right)
++        return binop(operator.add, left, right)
  
      def __sub__(left, right):
          """
-@@ -616,7 +615,7 @@
+@@ -615,7 +616,7 @@
              sage: foo - 1
              9
          """
--        return binop(operator.sub, left, right)
-+        return obj(left) - obj(right)
+-        return obj(left) - obj(right)
++        return binop(operator.sub, left, right)
  
      def __mul__(left, right):
          """
-@@ -629,7 +628,23 @@
+@@ -628,23 +629,7 @@
              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)
+-        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)
++        return binop(operator.mul, left, right)
  
      def __div__(left, right):
          """
-@@ -642,7 +657,7 @@
+@@ -657,7 +642,7 @@
              sage: foo / 2
              5
          """
--        return binop(operator.div, left, right)
-+        return obj(left) / obj(right)
+-        return obj(left) / obj(right)
++        return binop(operator.div, left, right)
  
      def __floordiv__(left, right):
          """
-@@ -655,7 +670,7 @@
+@@ -670,7 +655,7 @@
              sage: foo  // 3
              3
          """
--        return binop(operator.floordiv, left, right)
-+        return obj(left) // obj(right)
+-        return obj(left) // obj(right)
++        return binop(operator.floordiv, left, right)
  
      def __truediv__(left, right):
          """
-@@ -668,7 +683,7 @@
+@@ -683,7 +668,7 @@
              sage: operator.truediv(foo, 3)
              10/3
          """
--        return binop(operator.truediv, left, right)
-+        return PyNumber_TrueDivide(obj(left), obj(right))
+-        return PyNumber_TrueDivide(obj(left), obj(right))
++        return binop(operator.truediv, left, right)
  
      def __pow__(left, right, mod):
          """
-@@ -681,14 +696,7 @@
+@@ -696,7 +681,14 @@
              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))
+-        return PyNumber_Power(obj(left), obj(right), obj(mod))
++        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)
  
      def __mod__(left, right):
          """
-@@ -701,7 +709,7 @@
+@@ -709,7 +701,7 @@
              sage: foo % 7
              3
          """
--        return binop(operator.mod, left, right)
-+        return obj(left) % obj(right)
+-        return obj(left) % obj(right)
++        return binop(operator.mod, left, right)
  
      def __lshift__(left, right):
          """
-@@ -714,7 +722,7 @@
+@@ -722,7 +714,7 @@
              sage: foo << 3
              80
          """
--        return binop(operator.lshift, left, right)
-+        return obj(left) << obj(right)
+-        return obj(left) << obj(right)
++        return binop(operator.lshift, left, right)
  
      def __rshift__(left, right):
          """
-@@ -727,7 +735,7 @@
+@@ -735,7 +727,7 @@
              sage: foo >> 2
              2
          """
--        return binop(operator.rshift, left, right)
-+        return obj(left) >> obj(right)
+-        return obj(left) >> obj(right)
++        return binop(operator.rshift, left, right)
  
      def __and__(left, right):
          """
-@@ -740,7 +748,7 @@
+@@ -748,7 +740,7 @@
              sage: foo & 7
              2
          """
--        return binop(operator.and_, left, right)
-+        return obj(left) & obj(right)
+-        return obj(left) & obj(right)
++        return binop(operator.and_, left, right)
  
      def __or__(left, right):
          """
-@@ -753,7 +761,7 @@
+@@ -761,7 +753,7 @@
              sage: foo | 7
              15
          """
--        return binop(operator.or_, left, right)
-+        return obj(left) | obj(right)
+-        return obj(left) | obj(right)
++        return binop(operator.or_, left, right)
  
      def __xor__(left, right):
          """
-@@ -766,7 +774,7 @@
+@@ -774,7 +766,7 @@
              sage: foo ^^ 7
              13
          """
--        return binop(operator.xor, left, right)
-+        return obj(left) ^ obj(right)
+-        return obj(left) ^ obj(right)
++        return binop(operator.xor, left, right)
  
      def __neg__(self):
          """
-@@ -779,7 +787,7 @@
+@@ -787,7 +779,7 @@
              sage: -foo
              -10
          """
--        return -self._get_object()
-+        return -self.get_object()
+-        return -self.get_object()
++        return -self._get_object()
  
      def __pos__(self):
          """
-@@ -792,7 +800,7 @@
+@@ -800,7 +792,7 @@
              sage: +foo
              10
          """
--        return +self._get_object()
-+        return +self.get_object()
+-        return +self.get_object()
++        return +self._get_object()
  
      def __abs__(self):
          """
-@@ -805,7 +813,7 @@
+@@ -813,7 +805,7 @@
              sage: abs(foo)
              1000
          """
--        return abs(self._get_object())
-+        return abs(self.get_object())
+-        return abs(self.get_object())
++        return abs(self._get_object())
  
      def __invert__(self):
          """
-@@ -818,7 +826,7 @@
+@@ -826,7 +818,7 @@
              sage: ~foo
              1/10
          """
--        return ~self._get_object()
-+        return ~self.get_object()
+-        return ~self.get_object()
++        return ~self._get_object()
  
      def __complex__(self):
          """
-@@ -831,7 +839,7 @@
+@@ -839,7 +831,7 @@
              sage: complex(foo)
              (10+0j)
          """
--        return complex(self._get_object())
-+        return complex(self.get_object())
+-        return complex(self.get_object())
++        return complex(self._get_object())
  
      def __int__(self):
          """
-@@ -844,7 +852,7 @@
+@@ -852,7 +844,7 @@
              sage: int(foo)
              10
          """
--        return int(self._get_object())
-+        return int(self.get_object())
+-        return int(self.get_object())
++        return int(self._get_object())
  
      def __long__(self):
          """
-@@ -857,7 +865,7 @@
+@@ -865,7 +857,7 @@
              sage: long(foo)
              10L
          """
--        return long(self._get_object())
-+        return long(self.get_object())
+-        return long(self.get_object())
++        return long(self._get_object())
  
      def __float__(self):
          """
-@@ -870,7 +878,7 @@
+@@ -878,7 +870,7 @@
              sage: float(foo)
              10.0
          """
--        return float(self._get_object())
-+        return float(self.get_object())
+-        return float(self.get_object())
++        return float(self._get_object())
  
      def __oct__(self):
          """
-@@ -883,7 +891,7 @@
+@@ -891,7 +883,7 @@
              sage: oct(foo)
              '12'
          """
--        return oct(self._get_object())
-+        return oct(self.get_object())
+-        return oct(self.get_object())
++        return oct(self._get_object())
  
      def __hex__(self):
          """
-@@ -896,7 +904,7 @@
+@@ -904,7 +896,7 @@
              sage: hex(foo)
              'a'
          """
--        return hex(self._get_object())
-+        return hex(self.get_object())
+-        return hex(self.get_object())
++        return hex(self._get_object())
  
      def __index__(self):
          """
-@@ -909,7 +917,7 @@
+@@ -917,7 +909,7 @@
              sage: list(range(100))[foo]
              10
          """
--        return operator.index(self._get_object())
-+        return PyNumber_Index(self.get_object())
+-        return PyNumber_Index(self.get_object())
++        return operator.index(self._get_object())
  
      def __copy__(self):
          """
-@@ -924,7 +932,7 @@
+@@ -932,7 +924,7 @@
              sage: copy(foo)
              10
          """
--        return self._get_object()
-+        return self.get_object()
+-        return self.get_object()
++        return self._get_object()
  
      def __deepcopy__(self, memo=None):
          """
-@@ -939,7 +947,7 @@
+@@ -947,7 +939,7 @@
              sage: deepcopy(foo)
              10
          """
--        return self._get_object()
-+        return self.get_object()
+-        return self.get_object()
++        return self._get_object()
  
      def __instancecheck__(self, x):
          """
-@@ -951,7 +959,7 @@
+@@ -959,7 +951,7 @@
              sage: isinstance(QQ, RationalField)
              True
          """
--        return isinstance(x, self._get_object())
-+        return isinstance(x, self.get_object())
+-        return isinstance(x, self.get_object())
++        return isinstance(x, self._get_object())
  
      def __subclasscheck__(self, x):
          """
-@@ -963,10 +971,11 @@
+@@ -971,11 +963,10 @@
              sage: issubclass(RationalField, Parent)
              True
          """
--        return issubclass(x, self._get_object())
-+        return issubclass(x, self.get_object())
+-        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):
+-def lazy_import(module, names, as_=None, *,
+-    at_startup=False, namespace=None, overwrite=None, deprecation=None):
++def lazy_import(module, names, _as=None, namespace=None, bint overwrite=True, at_startup=False, 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 @@
+@@ -989,16 +980,18 @@
      - ``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
+-    - ``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 ...``.
 -
--    - ``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
++    - ``_as`` -- (optional) a string or list of strings representing the
++      aliases of the names imported
  
-     - ``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
  
-+    - ``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
++
++    - ``at_startup`` -- a boolean (default: ``False``);
++      whether the lazy import is supposed to be resolved at startup time
 +
      - ``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 @@
+@@ -1067,26 +1060,21 @@
          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):
+-    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):
++    if _as is None:
++        _as = names
++    if isinstance(names, str):
          names = [names]
--        _as = [_as]
-+        as_ = [as_]
-+    else:
-+        names = list(names)
-+        as_ = list(as_)
+-        as_ = [as_]
+-    else:
+-        names = list(names)
+-        as_ = list(as_)
++        _as = [_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)
+-        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)
++        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)
  
  
  star_imports = None
diff --git a/debian/patches/series b/debian/patches/series
index 381c43e..5cca13b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -53,7 +53,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-imports-22755.patch
 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