[sagemath] 01/03: Revert a sage commit, fixing some docbuild segfaults

Ximin Luo infinity0 at debian.org
Sat Oct 1 13:14:41 UTC 2016


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

infinity0 pushed a commit to branch _wip_docbuild
in repository sagemath.

commit bc0befdbdd0ca4637c2321ed292787d180bd6371
Author: Ximin Luo <infinity0 at debian.org>
Date:   Thu Sep 29 02:46:43 2016 +0200

    Revert a sage commit, fixing some docbuild segfaults
---
 ...ert-lazy-import-dependent-on-python-patch.patch | 178 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 179 insertions(+)

diff --git a/debian/patches/fixsage-revert-lazy-import-dependent-on-python-patch.patch b/debian/patches/fixsage-revert-lazy-import-dependent-on-python-patch.patch
new file mode 100644
index 0000000..f31ba45
--- /dev/null
+++ b/debian/patches/fixsage-revert-lazy-import-dependent-on-python-patch.patch
@@ -0,0 +1,178 @@
+Description: Revert sage commit 308fa0258773ac7a9b3d797aab268febaa09846e
+ This is dependent on a python patch that hasn't landed upstream or in Debian
+ yet. This fixes segfaults in the docbuild. TODO: ask Debian Python maintainer
+ to apply the patch from #25750 below, and drop this patch.
+Bug: https://trac.sagemath.org/ticket/19633
+Bug-Python: https://bugs.python.org/issue25750
+Author: Ximin Luo <infinity0 at debian.org>
+Forwarded: not-needed
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/sage/src/sage/misc/lazy_import.pyx
++++ b/sage/src/sage/misc/lazy_import.pyx
+@@ -45,14 +45,19 @@
+ #*****************************************************************************
+ #       Copyright (C) 2009 Robert Bradshaw <robertwb at math.washington.edu>
+ #
+-# This program is free software: you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation, either version 2 of the License, or
+-# (at your option) any later version.
++#  Distributed under the terms of the GNU General Public License (GPL)
++#
++#    This code is distributed in the hope that it will be useful,
++#    but WITHOUT ANY WARRANTY; without even the implied warranty of
++#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++#    General Public License for more details.
++#
++#  The full text of the GPL is available at:
++#
+ #                  http://www.gnu.org/licenses/
+ #*****************************************************************************
+ 
+-from cpython.object cimport PyObject_RichCompare
++from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+ 
+ import os, cPickle as pickle, operator
+ import inspect
+@@ -70,7 +75,6 @@
+ # boolean to determine whether Sage is still starting up
+ cdef bint startup_guard = True
+ 
+-
+ cpdef finish_startup():
+     """
+     This function must be called exactly once at the end of the Sage
+@@ -172,7 +176,9 @@
+         self._at_startup = at_startup
+         self._deprecation = deprecation
+ 
+-    cpdef _get_object(self, owner=None):
++    # Due to a bug in Cython-0.19, this must not be a cpdef method.
++    # See http://trac.sagemath.org/sage_trac/ticket/14452
++    def _get_object(self, owner=None):
+         """
+         Return the wrapped object, importing it if necessary.
+ 
+@@ -231,41 +237,39 @@
+                sage: type(Foo.__dict__['plot'])
+                <type '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)
+-        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
+-        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)
+-            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
++        if self._object is None:
++            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
++            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
++            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)
++                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
+         return self._object
+ 
+     def _get_deprecation_ticket(self):
+@@ -465,7 +469,18 @@
+             left = (<LazyImport>left)._get_object()
+         if isinstance(right, LazyImport):
+             right = (<LazyImport>right)._get_object()
+-        return PyObject_RichCompare(left, right, op)
++        if op == Py_LT:
++            return left <  right
++        elif op == Py_LE:
++            return left <= right
++        elif op == Py_EQ:
++            return left == right
++        elif op == Py_NE:
++            return left != right
++        elif op == Py_GT:
++            return left >  right
++        elif op == Py_GE:
++            return left >= right
+ 
+     def __len__(self):
+         """
+@@ -511,7 +526,7 @@
+         documentation of :meth:`_get_object` for an explanation of
+         this.
+         """
+-        obj = self._get_object(owner)
++        obj = self._get_object(owner=owner)
+         if hasattr(obj, "__get__"):
+             return obj.__get__(instance, owner)
+         return obj
+@@ -537,7 +552,7 @@
+             sage: type(foo)
+             <type 'sage.misc.lazy_import.LazyImport'>
+             sage: foo[1] = 100
+-            sage: print(foo)
++            sage: print foo
+             [0, 100, 2, 3, 4, 5, 6, 7, 8, 9]
+         """
+         self._get_object()[key] = value
+@@ -551,7 +566,7 @@
+             sage: type(foo)
+             <type 'sage.misc.lazy_import.LazyImport'>
+             sage: del foo[1]
+-            sage: print(foo)
++            sage: print foo
+             [0, 2, 3, 4, 5, 6, 7, 8, 9]
+         """
+         del self._get_object()[key]
diff --git a/debian/patches/series b/debian/patches/series
index 49f8d45..6a11029 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -8,6 +8,7 @@ fixsage-mpfi.patch
 fixsage-sphinx.patch
 fixsage-libgap-systemwide.patch
 fixsage-use-lexists-not-exists.patch
+fixsage-revert-lazy-import-dependent-on-python-patch.patch
 
 # due to us using a different version of a dependency than what Sage uses
 # we'll probably drop these when importing the next version of Sage

-- 
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