Bug#925316: TypeError: type.__new__(metaclass) is not safe
Kingsley G. Morse Jr.
kingsley at loaner.com
Fri Mar 22 23:18:09 GMT 2019
Package: sagemath
Version: 8.6-6
Severity: important
Dear Maintainer,
Thank you for maintaining sage.
I look forward to using it.
The main reason I'm writing is to report a bug.
I typed...
root$ aptitude install sagemath
on a computer with piecemeal updates from Debian's
unstable distribution, and then
kingsley$ sage
and got .... "kaBOOM!".
The crash traceback is attached.
It reminds me of
https://trac.sagemath.org/ticket/18503
So,
Kingsley
--
Time is the fire in which we all burn.
-- System Information:
Debian Release: stretch/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 4.4.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: systemd (via /run/systemd/system)
Versions of packages sagemath depends on:
ii cysignals-tools 1.8.1+ds-2
ii cython 0.29.2-2
ii ecl 16.1.3+ds-2
ii eclib-tools 20180815-2
ii fflas-ffpack 2.3.2-3
ii flintqs 1:1.0-3
ii gap-atlasrep 1.5.1-2
ii gap-core 4r10p0-7
ii gap-dev 4r10p0-7
ii gap-online-help 4r10p0-7
ii gap-primgrp 3.3.2-1
ii gap-smallgrp 1.3-1
ii gap-table-of-marks 1.2.7-2
ii gap-transgrp 2.0.4-1
ii gfan 0.6.2-2
ii gmp-ecm 7.0.4+ds-5
ii ipython 5.8.0-1
ii iso-codes 3.63-1
ii jmol 14.6.4+2016.11.05+dfsg1-4
ii lcalc 1.23+dfsg-11
ii less 481-2.1
ii libatlas3-base [liblapack.so.3] 3.10.3-5
ii libblas3 [libblas.so.3] 3.7.1-4
ii libbraiding0 1.0-1
ii libbrial-groebner3 1.2.4-2
ii libbrial3 1.2.4-2
ii libc6 2.28-8
ii libcdd-tools 094j-2
ii libcliquer1 1.21-2
ii libec4 20180815-2
ii libecm1 7.0.4+ds-5
ii libflint-2.5.2 2.5.2-3
ii libflint-arb2 1:2.16.0-2
ii libgc1c2 1:7.6.4-0.4
ii libgcc1 1:8.3.0-3
ii libgd3 2.2.5-5.1
ii libgivaro9 4.0.4-2
ii libglpk40 4.65-2
ii libgmp10 2:6.1.2+dfsg-4
ii libgmpxx4ldbl 2:6.1.2+dfsg-4
ii libgomp1 8.3.0-3
ii libgsl23 2.5+dfsg-4
ii libgslcblas0 2.5+dfsg-4
ii libhomfly0 1.02r5-1
ii libiml0 1.0.4-1+b2
ii libjs-mathjax 2.7.4+dfsg-1
ii libjs-three 80+dfsg2-2
ii liblapack3 [liblapack.so.3] 3.7.1-4
ii liblfunction0 1.23+dfsg-11
ii liblinbox-1.5.2-0 1.5.2-2
ii liblinboxsage-1.5.2-0 1.5.2-2
ii liblrcalc1 1.2-2+b1
ii libm4ri-0.0.20140914 20140914-2
ii libm4rie-0.0.20150908 20150908-2
ii libmpc3 1.1.0-1
ii libmpfi0 1.5.3+ds-2
ii libmpfr6 4.0.0-7
ii libntl35 10.5.0-2
ii libpari-gmp-tls6 2.11.1-2
ii libplanarity0 3.0.0.5-3
ii libpng16-16 1.6.36-5
ii libppl14 1:1.2-7
ii libpynac18 0.7.23-2
ii libratpoints-2.1.3 1:2.1.3-1+b2
ii libreadline7 7.0-2
ii librw0 0.8+ds-1
ii libsingular4m1 1:4.1.1-p2+ds-3
ii libstdc++6 8.3.0-3
ii libsymmetrica2 2.0+ds-6
ii libzn-poly-0.9 0.9.1-1
ii maxima-sage 5.41.0+ds-4
ii maxima-sage-share 5.41.0+ds-4
ii nauty 2.6r10+ds-1
ii palp 2.1-5
ii pari-galdata 0.20080411-2
ii pari-gp 2.11.1-2
ii pari-seadata 0.20090618-1
ii python 2.7.15-3
ii python-alabaster 0.7.8-1
ii python-babel 2.4.0+dfsg.1-2
ii python-backports-abc 0.5-2
ii python-backports-shutil-get-terminal-size 1.0.0-3
ii python-backports.functools-lru-cache 1.4-2
ii python-brial 1.2.4-2
ii python-configparser 3.5.0b2-1
ii python-cvxopt 1.1.9+dfsg-3+b1
ii python-cycler 0.10.0-1
ii python-cypari2 1.3.1-2
ii python-cysignals-pari 1.8.1+ds-2
ii python-decorator 4.1.2-1
ii python-docutils 0.12+dfsg-1
ii python-enum34 1.0.4-3
ii python-fpylll 0.4.1+ds1-5
ii python-functools32 3.2.3.2-3
ii python-future 0.16.0-1
ii python-imagesize 0.7.1-1
ii python-ipython-genutils 0.2.0-1
ii python-itsdangerous 0.24+dfsg1-2
ii python-matplotlib 2.1.1-2
ii python-mistune 0.8.4-1
ii python-mpmath 1.1.0-1
ii python-networkx 2.2-1
ii python-numpy [python-numpy-abi9] 1:1.16.2-1
ii python-openid 2.2.5-7
ii python-packaging 19.0-1
ii python-path 11.5.0-3
ii python-pathlib2 2.3.0-1
ii python-pexpect 4.6.0-1
ii python-pickleshare 0.7.4-2
ii python-pil 5.0.0-1
ii python-pip 9.0.1-2
ii python-pkgconfig 1.4.0-1
ii python-prompt-toolkit 1.0.14-1
ii python-psutil 2.2.1-3+b1
ii python-ptyprocess 0.6.0-1
ii python-pygments 2.0.1+dfsg-2
ii python-rpy2 2.8.6-2+b2
ii python-sagenb 1.1.2+ds1-1
ii python-scipy 0.19.1-1
ii python-setuptools 18.4-2
ii python-setuptools-scm 3.2.0-1
ii python-simplegeneric 0.8.1-1
ii python-singledispatch 3.4.0.3-2
ii python-snowballstemmer 1.2.1-1
ii python-sphinx 1.8.4-1
ii python-stemmer 1.3.0+dfsg-1+b9
ii python-subprocess32 3.2.7-2
ii python-sympy 1.3-2
ii python-terminado 0.8.1-4
ii python-tornado 4.2.1-1+b1
ii python-traitlets 4.3.2-1
ii python-twisted 15.2.1-1
ii python-typing 3.6.2-1
ii python-tz 2012c+dfsg-0.1
ii python-vcversioner 2.16.0.0-1
ii python-wcwidth 0.1.7+dfsg1-1
ii python-werkzeug 0.14.1+dfsg1-4
ii python-zmq 14.4.0-4
ii python-zope.interface 4.1.3-1
pn python:any <none>
ii r-base-core 3.5.1-1+b1
ii rubiks 20070912-3
ii sagemath-common 8.6-6
ii sagemath-database-conway-polynomials 0.5-4
ii sagemath-database-elliptic-curves 0.8-2
ii sagemath-database-graphs 20161026+dfsg-2
ii sagemath-database-mutually-combinatorial-designs 20140630-3
ii sagemath-database-polytopes 20170220-2
ii singular 1:4.1.1-p2+ds-3
ii sqlite3 3.26.0-3
ii sympow 2.023.5-2
ii tachyon 0.99~b6+dsx-9
ii xcas 1.4.9.69+dfsg1-2
ii zlib1g 1:1.2.11.dfsg-1
Versions of packages sagemath recommends:
ii maxima-sage-doc 5.41.0+ds-4
ii pari-doc 2.11.1-2
ii python-sagenb-export 3.2-3
ii r-cran-lattice 0.20-35-1+b2
ii sagemath-doc-en 8.6-6
ii sagemath-jupyter 8.6-6
ii sagetex 3.2+ds-2
ii singular-doc 1:4.1.1-p2+ds-3
ii texlive-latex-base 2018.20190227-1
Versions of packages sagemath suggests:
pn dot2tex <none>
pn gap-design <none>
ii gap-factint 1.6.2+ds-1
pn gap-grape <none>
pn gap-guava <none>
pn gap-laguna <none>
pn gap-sonata <none>
pn gap-toric <none>
-- no debconf information
-------------- next part --------------
***************************************************************************
IPython post-mortem report
{'commit_hash': u'033ab93c7',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/usr/lib/python2.7/dist-packages/IPython',
'ipython_version': '5.8.0',
'os_name': 'posix',
'platform': 'Linux-4.4.0-1-686-pae-i686-with-debian-stretch-sid',
'sys_executable': '/usr/bin/python2',
'sys_platform': 'linux2',
'sys_version': '2.7.15+ (default, Feb 1 2019, 07:18:31) \n[GCC 8.2.0]'}
***************************************************************************
***************************************************************************
Crash traceback:
---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeError Python 2.7.15+: /usr/bin/python2
Fri Mar 22 15:59:55 2019
A problem occurred executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/share/sagemath/bin/sage-ipython in <module>()
1 #!/usr/bin/env sage-python23
2 # -*- coding: utf-8 -*-
3 """
4 Sage IPython startup script.
5 """
6
7 # Display startup banner. Do this before anything else to give the user
8 # early feedback that Sage is starting.
9 from sage.misc.banner import banner
10 banner()
11
12 from sage.repl.interpreter import SageTerminalApp
13
14 app = SageTerminalApp.instance()
---> 15 app.initialize()
global app.initialize = <bound method SageTerminalApp.initialize of <sage.repl.interpreter.SageTerminalApp object at 0xb72a61cc>>
16 app.start()
<decorator-gen-110> in initialize(self=<sage.repl.interpreter.SageTerminalApp object>, argv=None)
/usr/lib/python2.7/dist-packages/traitlets/config/application.pyc in catch_config_error(method=<function initialize>, app=<sage.repl.interpreter.SageTerminalApp object>, *args=(None,), **kwargs={})
72 TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = False
73 else:
74 raise ValueError("Unsupported value for environment variable: 'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar )
75
76
77 @decorator
78 def catch_config_error(method, app, *args, **kwargs):
79 """Method decorator for catching invalid config (Trait/ArgumentErrors) during init.
80
81 On a TraitError (generally caused by bad config), this will print the trait's
82 message, and exit the app.
83
84 For use on init methods, to prevent invoking excepthook on invalid input.
85 """
86 try:
---> 87 return method(app, *args, **kwargs)
method = <function initialize at 0xb6566a04>
app = <sage.repl.interpreter.SageTerminalApp object at 0xb72a61cc>
args = (None,)
kwargs = {}
88 except (TraitError, ArgumentError) as e:
89 app.print_help()
90 app.log.fatal("Bad config encountered during initialization:")
91 app.log.fatal(str(e))
92 app.log.debug("Config at the time: %s", app.config)
93 app.exit(1)
94
95
96 class ApplicationError(Exception):
97 pass
98
99
100 class LevelFormatter(logging.Formatter):
101 """Formatter with additional `highlevel` record
102
/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.pyc in initialize(self=<sage.repl.interpreter.SageTerminalApp object>, argv=None)
301
302 return super(TerminalIPythonApp, self).parse_command_line(argv)
303
304 @catch_config_error
305 def initialize(self, argv=None):
306 """Do actions after construct, but before starting the app."""
307 super(TerminalIPythonApp, self).initialize(argv)
308 if self.subapp is not None:
309 # don't bother initializing further, starting subapp
310 return
311 # print self.extra_args
312 if self.extra_args and not self.something_to_run:
313 self.file_to_run = self.extra_args[0]
314 self.init_path()
315 # create the shell
--> 316 self.init_shell()
self.init_shell = <bound method SageTerminalApp.init_shell of <sage.repl.interpreter.SageTerminalApp object at 0xb72a61cc>>
317 # and draw the banner
318 self.init_banner()
319 # Now a variety of things that happen after the banner is printed.
320 self.init_gui_pylab()
321 self.init_extensions()
322 self.init_code()
323
324 def init_shell(self):
325 """initialize the InteractiveShell instance"""
326 # Create an InteractiveShell instance.
327 # shell.display_banner should always be False for the terminal
328 # based app, because we call shell.show_banner() by hand below
329 # so the banner shows *before* all extension loading stuff.
330 self.shell = self.interactive_shell_class.instance(parent=self,
331 profile_dir=self.profile_dir,
/usr/lib/python2.7/dist-packages/sage/repl/interpreter.pyc in init_shell(self=<sage.repl.interpreter.SageTerminalApp object>)
745 self.shell.has_sage_extensions = SAGE_EXTENSION in self.extensions
746
747 # Load the %lprun extension if available
748 try:
749 import line_profiler
750 except ImportError:
751 pass
752 else:
753 self.extensions.append('line_profiler')
754
755 if self.shell.has_sage_extensions:
756 self.extensions.remove(SAGE_EXTENSION)
757
758 # load sage extension here to get a crash if
759 # something is wrong with the sage library
--> 760 self.shell.extension_manager.load_extension(SAGE_EXTENSION)
self.shell.extension_manager.load_extension = <bound method ExtensionManager.load_extension of <IPython.core.extensions.ExtensionManager object at 0xb5a3e92c>>
global SAGE_EXTENSION = 'sage'
761
762
/usr/lib/python2.7/dist-packages/IPython/core/extensions.pyc in load_extension(self=<IPython.core.extensions.ExtensionManager object>, module_str='sage')
70
71 Returns the string "already loaded" if the extension is already loaded,
72 "no load function" if the module doesn't have a load_ipython_extension
73 function, or None if it succeeded.
74 """
75 if module_str in self.loaded:
76 return "already loaded"
77
78 from IPython.utils.syspathcontext import prepended_to_syspath
79
80 with self.shell.builtin_trap:
81 if module_str not in sys.modules:
82 with prepended_to_syspath(self.ipython_extension_dir):
83 __import__(module_str)
84 mod = sys.modules[module_str]
---> 85 if self._call_load_ipython_extension(mod):
self._call_load_ipython_extension = <bound method ExtensionManager._call_load_ipython_extension of <IPython.core.extensions.ExtensionManager object at 0xb5a3e92c>>
mod = <module 'sage' from '/usr/lib/python2.7/dist-packages/sage/__init__.pyc'>
86 self.loaded.add(module_str)
87 else:
88 return "no load function"
89
90 def unload_extension(self, module_str):
91 """Unload an IPython extension by its module name.
92
93 This function looks up the extension's name in ``sys.modules`` and
94 simply calls ``mod.unload_ipython_extension(self)``.
95
96 Returns the string "no unload function" if the extension doesn't define
97 a function to unload itself, "not loaded" if the extension isn't loaded,
98 otherwise None.
99 """
100 if module_str not in self.loaded:
/usr/lib/python2.7/dist-packages/IPython/core/extensions.pyc in _call_load_ipython_extension(self=<IPython.core.extensions.ExtensionManager object>, mod=<module 'sage' from '/usr/lib/python2.7/dist-packages/sage/__init__.pyc'>)
117 """
118 from IPython.utils.syspathcontext import prepended_to_syspath
119
120 if (module_str in self.loaded) and (module_str in sys.modules):
121 self.unload_extension(module_str)
122 mod = sys.modules[module_str]
123 with prepended_to_syspath(self.ipython_extension_dir):
124 reload(mod)
125 if self._call_load_ipython_extension(mod):
126 self.loaded.add(module_str)
127 else:
128 self.load_extension(module_str)
129
130 def _call_load_ipython_extension(self, mod):
131 if hasattr(mod, 'load_ipython_extension'):
--> 132 mod.load_ipython_extension(self.shell)
mod.load_ipython_extension = <function load_ipython_extension at 0xb73b2ca4>
self.shell = <sage.repl.interpreter.SageTerminalInteractiveShell object at 0xb6580bcc>
133 return True
134
135 def _call_unload_ipython_extension(self, mod):
136 if hasattr(mod, 'unload_ipython_extension'):
137 mod.unload_ipython_extension(self.shell)
138 return True
139
140 def install_extension(self, url, filename=None):
141 """Download and install an IPython extension.
142
143 If filename is given, the file will be so named (inside the extension
144 directory). Otherwise, the name from the URL will be used. The file must
145 have a .py or .zip extension; otherwise, a ValueError will be raised.
146
147 Returns the full path to the installed file.
/usr/lib/python2.7/dist-packages/sage/__init__.pyc in load_ipython_extension(*args=(<sage.repl.interpreter.SageTerminalInteractiveShell object>,))
1 __all__ = ['all']
2
3 # Set sage.__version__ to the current version number. This is analogous
4 # to many other Python packages.
5 from sage.version import version as __version__
6
7 # Make sure that the correct zlib library is loaded. This is needed
8 # to prevent the system zlib to be loaded instead of the Sage one.
9 # See https://trac.sagemath.org/ticket/23122
10 import zlib
11
12 # IPython calls this when starting up
13 def load_ipython_extension(*args):
14 import sage.repl.ipython_extension
---> 15 sage.repl.ipython_extension.load_ipython_extension(*args)
sage.repl.ipython_extension.load_ipython_extension = <function load_ipython_extension at 0xb57c14fc>
args = (<sage.repl.interpreter.SageTerminalInteractiveShell object at 0xb6580bcc>,)
16
17
18 # Monkey-patch inspect.isfunction() to support Cython functions.
19 def isfunction(obj):
20 """
21 Check whether something is a function.
22
23 We assume that anything which has a genuine ``__code__``
24 attribute (not using ``__getattr__`` overrides) is a function.
25 This is meant to support Cython functions.
26
27 EXAMPLES::
28
29 sage: from inspect import isfunction
30 sage: def f(): pass
31 sage: isfunction(f)
/usr/lib/python2.7/dist-packages/sage/repl/ipython_extension.pyc in wrapper(*args=(<sage.repl.interpreter.SageTerminalInteractiveShell object>,), **kwargs={})
547 ....: if work:
548 ....: return 'foo worked'
549 ....: raise RuntimeError("foo didn't work")
550 sage: foo(False)
551 Traceback (most recent call last):
552 ...
553 RuntimeError: foo didn't work
554 sage: foo(True)
555 'foo worked'
556 sage: foo(False)
557 sage: foo(True)
558 """
559 @wraps(func)
560 def wrapper(*args, **kwargs):
561 if not wrapper.has_run:
--> 562 result = func(*args, **kwargs)
result = undefined
global func = undefined
args = (<sage.repl.interpreter.SageTerminalInteractiveShell object at 0xb6580bcc>,)
kwargs = {}
563 wrapper.has_run = True
564 return result
565 wrapper.has_run = False
566 return wrapper
567
568
569 @run_once
570 def load_ipython_extension(ip):
571 """
572 Load the extension in IPython.
573 """
574 # this modifies ip
575 SageCustomizations(shell=ip)
/usr/lib/python2.7/dist-packages/sage/repl/ipython_extension.pyc in load_ipython_extension(ip=<sage.repl.interpreter.SageTerminalInteractiveShell object>)
560 def wrapper(*args, **kwargs):
561 if not wrapper.has_run:
562 result = func(*args, **kwargs)
563 wrapper.has_run = True
564 return result
565 wrapper.has_run = False
566 return wrapper
567
568
569 @run_once
570 def load_ipython_extension(ip):
571 """
572 Load the extension in IPython.
573 """
574 # this modifies ip
--> 575 SageCustomizations(shell=ip)
global SageCustomizations = <class 'sage.repl.ipython_extension.SageCustomizations'>
global shell = undefined
ip = <sage.repl.interpreter.SageTerminalInteractiveShell object at 0xb6580bcc>
/usr/lib/python2.7/dist-packages/sage/repl/ipython_extension.pyc in __init__(self=<sage.repl.ipython_extension.SageCustomizations object>, shell=<sage.repl.interpreter.SageTerminalInteractiveShell object>)
418 def __init__(self, shell=None):
419 """
420 Initialize the Sage plugin.
421 """
422 self.shell = shell
423
424 self.auto_magics = SageMagics(shell)
425 self.shell.register_magics(self.auto_magics)
426
427 import sage.misc.edit_module as edit_module
428 self.shell.set_hook('editor', edit_module.edit_devel)
429
430 self.init_inspector()
431 self.init_line_transforms()
432
--> 433 import sage.all # until sage's import hell is fixed
sage.all = undefined
434
435 self.shell.verbose_quit = True
436 self.set_quit_hook()
437
438 self.register_interface_magics()
439
440 if SAGE_IMPORTALL == 'yes':
441 self.init_environment()
442
443 def register_interface_magics(self):
444 """
445 Register magics for each of the Sage interfaces
446 """
447 from sage.repl.interface_magic import InterfaceMagic
448 InterfaceMagic.register_all(self.shell)
/usr/lib/python2.7/dist-packages/sage/all.py in <module>()
68 import math
69
70 from sage.env import SAGE_ROOT, SAGE_SRC, SAGE_DOC_SRC, SAGE_LOCAL, DOT_SAGE, SAGE_ENV
71
72
73 ###################################################################
74
75 # This import also sets up the interrupt handler
76 from cysignals.signals import (AlarmInterrupt, SignalError,
77 sig_on_reset as sig_on_count)
78
79 from time import sleep
80 from functools import reduce # in order to keep reduce in python3
81
82 import sage.misc.lazy_import
---> 83 from sage.misc.all import * # takes a while
global sage.misc.all = undefined
84 from sage.typeset.all import *
85 from sage.repl.all import *
86
87 from sage.misc.sh import sh
88
89 from sage.libs.all import *
90 from sage.data_structures.all import *
91 from sage.doctest.all import *
92
93 from sage.structure.all import *
94 from sage.rings.all import *
95 from sage.arith.all import *
96 from sage.matrix.all import *
97
98 from sage.symbolic.all import *
/usr/lib/python2.7/dist-packages/sage/misc/all.py in <module>()
69
70 from .defaults import (set_default_variable_name,
71 series_precision, set_series_precision)
72
73 from .sage_eval import sage_eval, sageobj
74
75 from .sage_input import sage_input
76
77 lazy_import("sage.misc.cython", ["cython_lambda", "cython_create_local_so"])
78 lazy_import("sage.misc.cython", "cython_compile", "cython")
79
80 from .persist import save, load, dumps, loads, db, db_save
81
82 from .func_persist import func_persist
83
---> 84 from .functional import (additive_order,
global functional = undefined
global additive_order = undefined
global base_ring = undefined
global base_field = undefined
global basis = undefined
global category = undefined
global charpoly = undefined
global characteristic_polynomial = undefined
global coerce = undefined
global cyclotomic_polynomial = undefined
global decomposition = undefined
global denominator = undefined
global det = undefined
global dimension = undefined
global dim = undefined
global discriminant = undefined
global disc = undefined
global eta = undefined
global fcp = undefined
global gen = undefined
global gens = undefined
global hecke_operator = undefined
global image = undefined
global integral = undefined
global integrate = undefined
global integral_closure = undefined
global interval = undefined
global xinterval = undefined
global is_commutative = undefined
global is_even = undefined
global is_integrally_closed = undefined
global is_field = undefined
global is_odd = undefined
global kernel = undefined
global krull_dimension = undefined
global lift = undefined
global log = undefined
global log_b = undefined
global minimal_polynomial = undefined
global minpoly = undefined
global multiplicative_order = undefined
global ngens = undefined
global norm = undefined
global numerator = undefined
global numerical_approx = undefined
global n = undefined
global N = undefined
global objgens = undefined
global objgen = undefined
global order = undefined
global rank = undefined
global regulator = undefined
global round = undefined
global quotient = undefined
global quo = undefined
global isqrt = undefined
global squarefree_part = undefined
global symbolic_sum = undefined
global sum = undefined
global symbolic_prod = undefined
global product = undefined
global transpose = undefined
85 base_ring,
86 base_field,
87 basis,
88 category,
89 charpoly,
90 characteristic_polynomial,
91 coerce,
92 cyclotomic_polynomial,
93 decomposition,
94 denominator,
95 det,
96 dimension,
97 dim,
98 discriminant,
99 disc,
/usr/lib/python2.7/dist-packages/sage/misc/functional.py in <module>()
12 - David Joyner (2005-12-20): More Examples
13 """
14 #*****************************************************************************
15 # Copyright (C) 2004 William Stein <wstein at gmail.com>
16 #
17 # This program is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation, either version 2 of the License, or
20 # (at your option) any later version.
21 # http://www.gnu.org/licenses/
22 #*****************************************************************************
23 from __future__ import absolute_import
24 from six.moves import range, builtins
25 from six import integer_types
26
---> 27 from sage.rings.complex_double import CDF
global sage.rings.complex_double = undefined
global CDF = undefined
28 from sage.rings.real_double import RDF, RealDoubleElement
29 from sage.rings.integer_ring import ZZ
30 from sage.rings.integer import Integer
31 from sage.misc.superseded import deprecation
32
33 ##############################################################################
34 # There are many functions on elements of a ring, which mathematicians
35 # usually write f(x), e.g., it is weird to write x.log() and natural
36 # to write log(x). The functions below allow for the more familiar syntax.
37 ##############################################################################
38
39
40 def additive_order(x):
41 """
42 Return the additive order of ``x``.
/usr/lib/python2.7/dist-packages/sage/rings/complex_double.pyx in init sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:22356)()
----> 1 r"""
2 Double Precision Complex Numbers
3
4 Sage supports arithmetic using double-precision complex numbers. A
5 double-precision complex number is a complex number ``x + I*y`` with
6 `x`, `y` 64-bit (8 byte) floating point numbers (double precision).
7
8 The field :class:`ComplexDoubleField` implements the field
9 of all double-precision complex numbers. You can refer to this
10 field by the shorthand CDF. Elements of this field are of type
11 :class:`ComplexDoubleElement`. If `x` and `y` are coercible to
12 doubles, you can create a complex double element using
13 ``ComplexDoubleElement(x,y)``. You can coerce more
14 general objects `z` to complex doubles by typing either
15 ``ComplexDoubleField(x)`` or ``CDF(x)``.
16
17 EXAMPLES::
18
19 sage: ComplexDoubleField()
20 Complex Double Field
21 sage: CDF
22 Complex Double Field
23 sage: type(CDF.0)
24 <type 'sage.rings.complex_double.ComplexDoubleElement'>
25 sage: ComplexDoubleElement(sqrt(2),3)
26 1.4142135623730951 + 3.0*I
27 sage: parent(CDF(-2))
28 Complex Double Field
29
30 ::
31
/usr/lib/python2.7/dist-packages/sage/rings/ring.pyx in init sage.rings.ring (build/cythonized/sage/rings/ring.c:22311)()
----> 1 """
2 Rings
3
4 This module provides the abstract base class :class:`Ring` from which
5 all rings in Sage (used to) derive, as well as a selection of more
6 specific base classes.
7
8 .. WARNING::
9
10 Those classes, except maybe for the lowest ones like :class:`Ring`,
11 :class:`CommutativeRing`, :class:`Algebra` and :class:`CommutativeAlgebra`,
12 are being progressively deprecated in favor of the corresponding
13 categories. which are more flexible, in particular with respect to multiple
14 inheritance.
15
16 The class inheritance hierarchy is:
17
18 - :class:`Ring`
19
20 - :class:`Algebra`
21 - :class:`CommutativeRing`
22
23 - :class:`NoetherianRing`
24 - :class:`CommutativeAlgebra`
25 - :class:`IntegralDomain`
26
27 - :class:`DedekindDomain`
28 - :class:`PrincipalIdealDomain`
29
30 Subclasses of :class:`PrincipalIdealDomain` are
31
/usr/lib/python2.7/dist-packages/sage/structure/parent_gens.pyx in init sage.structure.parent_gens (build/cythonized/sage/structure/parent_gens.c:5388)()
----> 1 r"""
2 Base class for old-style parent objects with generators
3
4 .. NOTE::
5
6 This class is being deprecated, see
7 ``sage.structure.parent.Parent`` and
8 ``sage.structure.category_object.CategoryObject`` for the new
9 model.
10
11 Many parent objects in Sage are equipped with generators, which are
12 special elements of the object. For example, the polynomial ring
13 `\ZZ[x,y,z]` is generated by `x`, `y`, and `z`. In Sage the `i^{th}`
14 generator of an object ``X`` is obtained using the notation
15 ``X.gen(i)``. From the Sage interactive prompt, the shorthand
16 notation ``X.i`` is also allowed.
17
18 REQUIRED: A class that derives from ParentWithGens *must* define
19 the ngens() and gen(i) methods.
20
21 OPTIONAL: It is also good if they define gens() to return all gens,
22 but this is not necessary.
23
24 The ``gens`` function returns a tuple of all generators, the
25 ``ngens`` function returns the number of generators.
26
27 The ``_assign_names`` functions is for internal use only, and is
28 called when objects are created to set the generator names. It can
29 only be called once.
30
31 The following examples illustrate these functions in the context of
/usr/lib/python2.7/dist-packages/sage/structure/parent_base.pyx in init sage.structure.parent_base (build/cythonized/sage/structure/parent_base.c:2543)()
----> 1 r"""
2 Base class for old-style parent objects with a base ring
3 """
4
5 #*****************************************************************************
6 # Copyright (C) 2006 William Stein <wstein at gmail.com>
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 2 of the License, or
11 # (at your option) any later version.
12 # http://www.gnu.org/licenses/
13 #*****************************************************************************
14
15 from __future__ import absolute_import
16
17 cimport sage.structure.parent as parent
18
19 from .coerce_exceptions import CoercionException
20
21 cdef inline check_old_coerce(parent.Parent p):
22 if p._element_constructor is not None:
23 raise RuntimeError("%s still using old coercion framework" % p)
24
25
26 def is_ParentWithBase(x):
27 """
28 Return True if x is a parent object with base.
29 """
30 return isinstance(x, ParentWithBase)
31
/usr/lib/python2.7/dist-packages/sage/structure/parent_old.pyx in init sage.structure.parent_old (build/cythonized/sage/structure/parent_old.c:8649)()
----> 1 r"""
2 Base class for old-style parent objects
3
4 CLASS HIERARCHY:
5
6 SageObject
7 Parent
8 ParentWithBase
9 ParentWithGens
10
11
12 TESTS:
13
14 This came up in some subtle bug once.
15 ::
16
17 sage: gp(2) + gap(3)
18 5
19 """
20
21 #*****************************************************************************
22 # Copyright (C) 2006 William Stein <wstein at gmail.com>
23 #
24 # This program is free software: you can redistribute it and/or modify
25 # it under the terms of the GNU General Public License as published by
26 # the Free Software Foundation, either version 2 of the License, or
27 # (at your option) any later version.
28 # http://www.gnu.org/licenses/
29 #*****************************************************************************
30 from __future__ import absolute_import, print_function
31
/usr/lib/python2.7/dist-packages/sage/structure/parent.pyx in init sage.structure.parent (build/cythonized/sage/structure/parent.c:27339)()
----> 1 r"""
2 Base class for parent objects
3
4 CLASS HIERARCHY::
5
6 SageObject
7 CategoryObject
8 Parent
9
10 A simple example of registering coercions::
11
12 sage: class A_class(Parent):
13 ....: def __init__(self, name):
14 ....: Parent.__init__(self)
15 ....: self._populate_coercion_lists_()
16 ....: self.rename(name)
17 ....:
18 ....: def category(self):
19 ....: return Sets()
20 ....:
21 ....: def _element_constructor_(self, i):
22 ....: assert(isinstance(i, (int, Integer)))
23 ....: return ElementWrapper(self, i)
24 sage: A = A_class("A")
25 sage: B = A_class("B")
26 sage: C = A_class("C")
27
28 sage: def f(a):
29 ....: return B(a.value+1)
30 sage: class MyMorphism(Morphism):
31 ....: def __init__(self, domain, codomain):
/usr/lib/python2.7/dist-packages/sage/structure/category_object.pyx in init sage.structure.category_object (build/cythonized/sage/structure/category_object.c:9657)()
47 ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))
48 """
49
50 #*****************************************************************************
51 # This program is free software: you can redistribute it and/or modify
52 # it under the terms of the GNU General Public License as published by
53 # the Free Software Foundation, either version 2 of the License, or
54 # (at your option) any later version.
55 # http://www.gnu.org/licenses/
56 #*****************************************************************************
57
58 from __future__ import absolute_import, division, print_function
59
60 from sage.cpython.getattr import dir_with_other_class
61 from sage.cpython.getattr cimport getattr_from_other_class
---> 62 from sage.categories.category import Category
global sage.categories.category = undefined
global Category = undefined
63 from sage.structure.debug_options cimport debug
64 from sage.misc.cachefunc import cached_method
65 from sage.structure.dynamic_class import DynamicMetaclass
66
67
68 cpdef inline check_default_category(default_category, category):
69 ## The resulting category is guaranteed to be
70 ## a sub-category of the default.
71 if category is None:
72 return default_category
73 return default_category.join([default_category,category])
74
75
76 cdef class CategoryObject(SageObject):
77 """
/usr/lib/python2.7/dist-packages/sage/categories/category.py in <module>()
95 #*****************************************************************************
96 # Copyright (C) 2005 David Kohel <kohel at maths.usyd.edu> and
97 # William Stein <wstein at math.ucsd.edu>
98 # 2008-2014 Nicolas M. Thiery <nthiery at users.sf.net>
99 #
100 # Distributed under the terms of the GNU General Public License (GPL)
101 # http://www.gnu.org/licenses/
102 #*****************************************************************************
103
104 import inspect
105 from warnings import warn
106 from sage.misc.abstract_method import abstract_method, abstract_methods_of_class
107 from sage.misc.cachefunc import cached_method, cached_function
108 from sage.misc.c3_controlled import _cmp_key, _cmp_key_named, C3_sorted_merge
109 from sage.misc.lazy_attribute import lazy_attribute
--> 110 from sage.misc.unknown import Unknown
global sage.misc.unknown = undefined
global Unknown = undefined
111 from sage.misc.weak_dict import WeakValueDictionary
112
113 from sage.structure.sage_object import SageObject
114 from sage.structure.unique_representation import UniqueRepresentation
115 from sage.structure.dynamic_class import DynamicMetaclass, dynamic_class
116
117 from sage.categories.category_cy_helper import category_sort_key, _sort_uniq, _flatten_categories, join_as_tuple
118
119 _join_cache = WeakValueDictionary()
120
121 class Category(UniqueRepresentation, SageObject):
122 r"""
123 The base class for modeling mathematical categories, like for example:
124
125 - ``Groups()``: the category of groups
/usr/lib/python2.7/dist-packages/sage/misc/unknown.py in <module>()
1 """
2 The Unknown truth value
3
4 AUTHORS:
5
6 - Florent Hivert (2010): initial version.
7 """
8 from __future__ import print_function
9
10 from sage.structure.sage_object import SageObject
---> 11 from sage.structure.unique_representation import UniqueRepresentation
global sage.structure.unique_representation = undefined
global UniqueRepresentation = undefined
12 from sage.structure.richcmp import richcmp_method, rich_to_bool
13
14
15 @richcmp_method
16 class UnknownClass(UniqueRepresentation, SageObject):
17 """
18 TESTS::
19
20 sage: TestSuite(Unknown).run()
21 """
22 def __init__(self):
23 """
24 The ``Unknown`` truth value
25
26 EXAMPLES::
27
28 sage: l = [False, Unknown, True]
29 sage: for a in l: print([a and b for b in l])
30 [False, False, False]
31 [Unknown, Unknown, Unknown]
/usr/lib/python2.7/dist-packages/sage/structure/unique_representation.py in <module>()
555 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
556 # General Public License for more details.
557 #
558 # The full text of the GPL is available at:
559 #
560 # https://www.gnu.org/licenses/
561 #******************************************************************************
562 from __future__ import print_function
563
564 from sage.misc import six
565 from sage.misc.cachefunc import weak_cached_function
566 from sage.misc.classcall_metaclass import ClasscallMetaclass, typecall
567 from sage.misc.fast_methods import WithEqualityById
568
569
--> 570 class CachedRepresentation(six.with_metaclass(ClasscallMetaclass)):
global CachedRepresentation = undefined
global six.with_metaclass = undefined
global ClasscallMetaclass = None
571 """
572 Classes derived from CachedRepresentation inherit a weak cache for their
573 instances.
574
575 .. NOTE::
576
577 If this class is used as a base class, then instances are (weakly)
578 cached, according to the arguments used to create the instance.
579 Pickling is provided, of course by using the cache.
580
581 .. NOTE::
582
583 Using this class, one can have arbitrary hash and comparison.
584 Hence, *unique* representation behaviour is *not* provided.
585
/usr/lib/python2.7/dist-packages/six.pyc in with_metaclass(meta=<type 'sage.misc.classcall_metaclass.ClasscallMetaclass'>, *bases=())
794 return f
795 return wrapper
796 else:
797 wraps = functools.wraps
798
799
800 def with_metaclass(meta, *bases):
801 """Create a base class with a metaclass."""
802 # This requires a bit of explanation: the basic idea is to make a dummy
803 # metaclass for one level of class instantiation that replaces itself with
804 # the actual metaclass.
805 class metaclass(meta):
806
807 def __new__(cls, name, this_bases, d):
808 return meta(name, bases, d)
--> 809 return type.__new__(metaclass, 'temporary_class', (), {})
global type.__new__ = undefined
metaclass = <class 'six.metaclass'>
810
811
812 def add_metaclass(metaclass):
813 """Class decorator for creating a class with a metaclass."""
814 def wrapper(cls):
815 orig_vars = cls.__dict__.copy()
816 slots = orig_vars.get('__slots__')
817 if slots is not None:
818 if isinstance(slots, str):
819 slots = [slots]
820 for slots_var in slots:
821 orig_vars.pop(slots_var)
822 orig_vars.pop('__dict__', None)
823 orig_vars.pop('__weakref__', None)
824 return metaclass(cls.__name__, cls.__bases__, orig_vars)
TypeError: type.__new__(metaclass) is not safe, use sage.misc.classcall_metaclass.ClasscallMetaclass.__new__()
***************************************************************************
History of session input:
*** Last line of input (may not be in above history):
More information about the debian-science-maintainers
mailing list