diff -up build/pkgs/sagetex/src/remote-sagetex.py.orig build/pkgs/sagetex/src/remote-sagetex.py --- build/pkgs/sagetex/src/remote-sagetex.py.orig 2020-08-12 02:35:31.000000000 -0600 +++ build/pkgs/sagetex/src/remote-sagetex.py 2020-10-30 14:03:01.286904419 -0600 @@ -24,12 +24,11 @@ ## You should have received a copy of the GNU General Public License along ## with this program. If not, see . ## -from __future__ import print_function import json import sys import time import re -import urllib +import urllib.request, urllib.parse, urllib.error import hashlib import os import os.path @@ -156,7 +155,7 @@ class RemoteSage: '\n*(?P.*)', re.DOTALL) self._404 = re.compile('404 Not Found') self._session = self._get_url('login', - urllib.urlencode({'username': user, + urllib.parse.urlencode({'username': user, 'password': password}))['session'] self._codewrap = """try: @@ -176,18 +175,18 @@ except: _p_.save(filename=plotfilename, **kwargs)""") def _encode(self, d): - return 'session={0}&'.format(self._session) + urllib.urlencode(d) + return 'session={0}&'.format(self._session) + urllib.parse.urlencode(d) def _get_url(self, action, u): - with closing(urllib.urlopen(self._srv + '/simple/' + action + - '?' + u)) as h: + with closing(urllib.request.urlopen(self._srv + '/simple/' + action + + '?' + u)) as h: data = self._response.match(h.read()) result = json.loads(data.group('header')) result['output'] = data.group('output').rstrip() return result def _get_file(self, fn, cell, ofn=None): - with closing(urllib.urlopen(self._srv + '/simple/' + 'file' + '?' + + with closing(urllib.request.urlopen(self._srv + '/simple/' + 'file' + '?' + self._encode({'cell': cell, 'file': fn}))) as h: myfn = ofn if ofn else fn data = h.read() @@ -277,13 +276,13 @@ if login_info_file: password = get_val(line) if not server: - server = raw_input('Enter server: ') + server = input('Enter server: ') if not server.startswith('http'): server = 'https://' + server if not username: - username = raw_input('Enter username: ') + username = input('Enter username: ') if not password: from getpass import getpass diff -up build/pkgs/sagetex/src/sagetexparse.py.orig build/pkgs/sagetex/src/sagetexparse.py --- build/pkgs/sagetex/src/sagetexparse.py.orig 2020-08-12 02:35:31.000000000 -0600 +++ build/pkgs/sagetex/src/sagetexparse.py 2020-10-30 14:03:01.286904419 -0600 @@ -132,7 +132,7 @@ class SageCodeExtractor(): def plotout(self, s, l, t): self.result += '# \\sageplot{} from line %s:\n' % lineno(l, s) - if t.format is not '': + if t.format != '': self.result += '# format: %s' % t.format[0][1:-1] + '\n' self.result += t.code[1:-1] + '\n\n' diff -up src/sage/cpython/debugimpl.c.orig src/sage/cpython/debugimpl.c --- src/sage/cpython/debugimpl.c.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/cpython/debugimpl.c 2020-10-30 14:03:01.299904398 -0600 @@ -148,6 +148,7 @@ static void _type_debug(PyTypeObject* tp printf(" tp_basicsize: %ld\n", (long)tp->tp_basicsize); printf(" tp_itemsize: %ld\n", (long)tp->tp_itemsize); printf(" tp_dictoffset: %ld\n", (long)tp->tp_dictoffset); + printf(" tp_vectorcall_offset: %ld\n", (long)tp->tp_vectorcall_offset); if HAVE_WEAKREFS(tp) { printf(" tp_weaklistoffset: %ld\n", (long)tp->tp_weaklistoffset); @@ -178,7 +179,6 @@ static void _type_debug(PyTypeObject* tp attr_pointer(tp_free); attr_pointer_meth(tp_repr, "__repr__"); - attr_pointer(tp_print); attr_pointer_meth(tp_hash, "__hash__"); attr_pointer_meth(tp_call, "__call__"); attr_pointer_meth(tp_str, "__str__"); diff -up src/sage/cpython/debug.pyx.orig src/sage/cpython/debug.pyx --- src/sage/cpython/debug.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/cpython/debug.pyx 2020-10-30 14:03:01.300904396 -0600 @@ -232,6 +232,7 @@ def type_debug(cls): tp_basicsize: 16 tp_itemsize: 0 tp_dictoffset: 0 + tp_vectorcall_offset: 0 tp_weaklistoffset: 0 tp_base (__base__): NULL tp_bases (__bases__): tuple: @@ -259,7 +260,6 @@ def type_debug(cls): tp_dealloc (__dealloc__): 0x7fc57d757010 tp_free: PyObject_Del tp_repr (__repr__): 0x7fc57d75b990 - tp_print: NULL tp_hash (__hash__): _Py_HashPointer tp_call (__call__): NULL tp_str (__str__): 0x7fc57d757020 diff -up src/sage/geometry/triangulation/point_configuration.py.orig src/sage/geometry/triangulation/point_configuration.py --- src/sage/geometry/triangulation/point_configuration.py.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/geometry/triangulation/point_configuration.py 2020-10-30 14:03:01.301904394 -0600 @@ -619,11 +619,11 @@ class PointConfiguration(UniqueRepresent ['{{0,1,2,4},{1,2,3,4}}'] """ timeout = 600 - proc = pexpect.spawn(executable, timeout=timeout) + proc = pexpect.spawn(executable, timeout=timeout, encoding='utf-8') proc.expect(r'Evaluating Commandline Options \.\.\.') proc.expect(r'\.\.\. done\.') proc.setecho(0) - assert proc.readline().strip() == b'' + assert proc.readline().strip() == '' if verbose: print("#### TOPCOM input ####") diff -up src/sage/interfaces/frobby.py.orig src/sage/interfaces/frobby.py --- src/sage/interfaces/frobby.py.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/interfaces/frobby.py 2020-10-30 14:03:02.534902319 -0600 @@ -79,7 +79,7 @@ class Frobby: print("Frobby command: ", repr(command)) print("Frobby input:\n", input) - process = Popen(command, stdin = PIPE, stdout = PIPE, stderr = PIPE) + process = Popen(command, stdin = PIPE, stdout = PIPE, stderr = PIPE, encoding='utf-8') if input: frinput = str_to_bytes(input) else: diff -up src/sage/interfaces/gfan.py.orig src/sage/interfaces/gfan.py --- src/sage/interfaces/gfan.py.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/interfaces/gfan.py 2020-10-30 14:11:30.550047499 -0600 @@ -62,7 +62,7 @@ class Gfan(object): print("gfan input:\n%s" % I) gfan_processes = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, - encoding='latin-1') + encoding='utf-8') ans, err = gfan_processes.communicate(input=I) # sometimes, gfan outputs stuff to stderr even though everything is fine diff -up src/sage/interfaces/latte.py.orig src/sage/interfaces/latte.py --- src/sage/interfaces/latte.py.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/interfaces/latte.py 2020-10-30 14:03:03.974899895 -0600 @@ -152,6 +152,7 @@ def count(arg, ehrhart_polynomial=False, latte_proc = Popen(args, stdin=PIPE, stdout=PIPE, stderr=(None if verbose else PIPE), + encoding='utf-8', cwd=str(SAGE_TMP)) ans, err = latte_proc.communicate(arg) @@ -364,6 +365,7 @@ def integrate(arg, polynomial=None, algo latte_proc = Popen(args, stdin=PIPE, stdout=PIPE, stderr=(None if verbose else PIPE), + encoding='utf-8', cwd=str(SAGE_TMP)) ans, err = latte_proc.communicate(arg) diff -up src/sage/interfaces/sagespawn.pyx.orig src/sage/interfaces/sagespawn.pyx --- src/sage/interfaces/sagespawn.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/interfaces/sagespawn.pyx 2020-10-30 14:03:03.975899894 -0600 @@ -1,6 +1,6 @@ """ Sage wrapper around pexpect's ``spawn`` class and -the ptyprocess's ``PtyProcess`` class. +the ptyprocess's ``PtyProcessUnicode`` class. AUTHOR: @@ -21,7 +21,7 @@ AUTHOR: #***************************************************************************** from pexpect import * -from ptyprocess import PtyProcess +from ptyprocess import PtyProcessUnicode from cpython.ref cimport Py_INCREF from libc.signal cimport * @@ -30,7 +30,6 @@ from posix.unistd cimport getpid, getpgi from time import sleep -from sage.cpython.string cimport str_to_bytes from sage.interfaces.process cimport ContainChildren @@ -173,7 +172,7 @@ class SageSpawn(spawn): return ret -class SagePtyProcess(PtyProcess): +class SagePtyProcess(PtyProcessUnicode): def close(self, force=None): """ Quit the child process: send the quit string, close the @@ -194,11 +193,7 @@ class SagePtyProcess(PtyProcess): if self.quit_string is not None: try: # This can fail if the process already exited - # PtyProcess.write takes bytes; ideally we would use - # an encoding picked specifically for the target process - # but the default (UTF-8) will do now, since I don't - # think we have any non-ASCII quit_strings anyways. - self.write(str_to_bytes(self.quit_string)) + self.write(self.quit_string) except (OSError, IOError): pass self.fileobj.close() diff -up src/sage/libs/coxeter3/coxeter.pyx.orig src/sage/libs/coxeter3/coxeter.pyx --- src/sage/libs/coxeter3/coxeter.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/libs/coxeter3/coxeter.pyx 2020-10-30 14:03:03.976899892 -0600 @@ -37,7 +37,7 @@ cdef class String: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import String # optional - coxeter3 - sage: s = String("hello"); s # optional - coxeter3 + sage: s = String(b"hello"); s # optional - coxeter3 hello sage: del s # optional - coxeter3 """ @@ -48,11 +48,11 @@ cdef class String: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import String # optional - coxeter3 - sage: s = String('Hi') # optional - coxeter3 + sage: s = String(b'Hi') # optional - coxeter3 sage: s # optional - coxeter3 Hi """ - return bytes_to_str(self.x.ptr()) + return self.x.ptr().decode('utf-8') def __hash__(self): """ @@ -64,7 +64,7 @@ cdef class String: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import String # optional - coxeter3 - sage: s = String('hello') # optional - coxeter3 + sage: s = String(b'hello') # optional - coxeter3 sage: hash(s) == hash('hello') # optional - coxeter3 True """ @@ -75,9 +75,9 @@ cdef class String: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import String # optional - coxeter3 - sage: ta1 = String('A') # optional - coxeter3 - sage: ta2 = String('A') # optional - coxeter3 - sage: tb = String('b') # optional - coxeter3 + sage: ta1 = String(b'A') # optional - coxeter3 + sage: ta2 = String(b'A') # optional - coxeter3 + sage: tb = String(b'b') # optional - coxeter3 sage: ta1 == ta2 # optional - coxeter3 True sage: tb != ta1 # optional - coxeter3 @@ -113,7 +113,7 @@ cdef class String: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import String # optional - coxeter3 - sage: s = String('Hi') # optional - coxeter3 + sage: s = String(b'Hi') # optional - coxeter3 sage: len(s) # optional - coxeter3 2 """ @@ -124,7 +124,7 @@ cdef class String: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import String # optional - coxeter3 - sage: s = String('Hi') # optional - coxeter3 + sage: s = String(b'Hi') # optional - coxeter3 sage: TestSuite(s).run() # optional - coxeter3 """ return (String, (repr(self),) ) @@ -138,7 +138,7 @@ cdef class Type: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import Type # optional - coxeter3 - sage: t = Type('A'); t # optional - coxeter3 + sage: t = Type(b'A'); t # optional - coxeter3 A sage: del t # optional - coxeter3 """ @@ -149,7 +149,7 @@ cdef class Type: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import Type # optional - coxeter3 - sage: t = Type('A'); t # optional - coxeter3 + sage: t = Type(b'A'); t # optional - coxeter3 A """ return bytes_to_str(self.x.name().ptr()) @@ -159,7 +159,7 @@ cdef class Type: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import Type # optional - coxeter3 - sage: t = Type('A') # optional - coxeter3 + sage: t = Type(b'A') # optional - coxeter3 sage: t.name() # optional - coxeter3 A """ @@ -175,8 +175,8 @@ cdef class Type: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import Type # optional - coxeter3 - sage: a = Type('A') # optional - coxeter3 - sage: b = Type('B') # optional - coxeter3 + sage: a = Type(b'A') # optional - coxeter3 + sage: b = Type(b'B') # optional - coxeter3 sage: hash(a) == hash(b) # optional - coxeter3 False sage: d = {a: 1, b: 2} # optional - coxeter3 @@ -188,9 +188,9 @@ cdef class Type: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import Type # optional - coxeter3 - sage: ta1 = Type('A') # optional - coxeter3 - sage: ta2 = Type('A') # optional - coxeter3 - sage: tb = Type('b') # optional - coxeter3 + sage: ta1 = Type(b'A') # optional - coxeter3 + sage: ta2 = Type(b'A') # optional - coxeter3 + sage: tb = Type(b'b') # optional - coxeter3 sage: ta1 == ta2 # optional - coxeter3 True sage: tb != ta1 # optional - coxeter3 @@ -224,7 +224,7 @@ cdef class Type: EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import Type # optional - coxeter3 - sage: t = Type('A') # optional - coxeter3 + sage: t = Type(b'A') # optional - coxeter3 sage: TestSuite(t).run() # optional - coxeter3 """ return (Type, (repr(self), )) @@ -268,7 +268,7 @@ cdef class CoxGroup(SageObject): pass type = type.lower() - type = 'B' if type == 'C' else type + type = b'B' if type == 'C' else type.encode('utf-8') if rank == 0: raise NotImplementedError("Coxeter group of type ['A',0] using Coxeter 3 not yet implemented") diff -up src/sage/misc/sageinspect.py.orig src/sage/misc/sageinspect.py --- src/sage/misc/sageinspect.py.orig 2020-11-01 10:38:08.203022437 -0700 +++ src/sage/misc/sageinspect.py 2020-11-01 10:43:43.355143620 -0700 @@ -463,12 +463,9 @@ class SageArgSpecVisitor(ast.NodeVisitor """ return node.id - def visit_NameConstant(self, node): - """ - Visit a Python AST :class:`ast.NameConstant` node. - - This is an optimization added in Python 3.4 for the special cases - of True, False, and None. + def visit_Constant(self, node): + r""" + Visit a Python AST :class:`ast.Constant` node. INPUT: @@ -476,17 +473,21 @@ class SageArgSpecVisitor(ast.NodeVisitor OUTPUT: - - None, True, False. + - the boolean, number, or string the ``node`` represents EXAMPLES:: - sage: import ast, sage.misc.sageinspect as sms # py3 - sage: visitor = sms.SageArgSpecVisitor() # py3 - sage: vis = lambda x: visitor.visit_NameConstant(ast.parse(x).body[0].value) # py3 - sage: [vis(n) for n in ['True', 'False', 'None']] # py3 + sage: import ast, sage.misc.sageinspect as sms + sage: visitor = sms.SageArgSpecVisitor() + sage: vis = lambda x: visitor.visit_Constant(ast.parse(x).body[0].value) + sage: [vis(n) for n in ['True', 'False', 'None']] [True, False, None] - sage: [type(vis(n)) for n in ['True', 'False', 'None']] # py3 + sage: [type(vis(n)) for n in ['True', 'False', 'None']] [, , ] + sage: [vis(s) for s in ['"abstract"', "u'syntax'", r'''r"tr\ee"''']] + ['abstract', u'syntax', 'tr\\ee'] + sage: [vis(n) for n in ['123', '0.0']] + [123, 0.0] """ return node.value @@ -520,57 +521,6 @@ class SageArgSpecVisitor(ast.NodeVisitor """ return node.arg - def visit_Num(self, node): - """ - Visit a Python AST :class:`ast.Num` node. - - INPUT: - - - ``node`` - the node instance to visit - - OUTPUT: - - - the number the ``node`` represents - - EXAMPLES:: - - sage: import ast, sage.misc.sageinspect as sms - sage: visitor = sms.SageArgSpecVisitor() - sage: vis = lambda x: visitor.visit_Num(ast.parse(x).body[0].value) - sage: [vis(n) for n in ['123', '0.0', str(-pi.n())]] # py2 - [123, 0.0, -3.14159265358979] - sage: [vis(n) for n in ['123', '0.0']] # py3 - [123, 0.0] - - .. NOTE:: - - On Python 3 negative numbers are parsed first, for some reason, as - a UnaryOp node. - """ - return node.n - - def visit_Str(self, node): - r""" - Visit a Python AST :class:`ast.Str` node. - - INPUT: - - - ``node`` - the node instance to visit - - OUTPUT: - - - the string the ``node`` represents - - EXAMPLES:: - - sage: import ast, sage.misc.sageinspect as sms - sage: visitor = sms.SageArgSpecVisitor() - sage: vis = lambda x: visitor.visit_Str(ast.parse(x).body[0].value) - sage: [vis(s) for s in ['"abstract"', "u'syntax'", r'''r"tr\ee"''']] - ['abstract', u'syntax', 'tr\\ee'] - """ - return node.s - def visit_List(self, node): """ Visit a Python AST :class:`ast.List` node. diff -up src/sage/plot/plot3d/plot3d.py.orig src/sage/plot/plot3d/plot3d.py --- src/sage/plot/plot3d/plot3d.py.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/plot/plot3d/plot3d.py 2020-10-30 14:24:36.813732073 -0600 @@ -186,7 +186,7 @@ class _Coordinates(object): sage: arb((x+z,y*z,z), z, (x,y)) Arbitrary Coordinates coordinate transform (z in terms of x, y) """ - all_vars = sage_getargspec(self.transform).args[1:] + all_vars = inspect.getfullargspec(self.transform)[0][1:] if set(all_vars) != set(indep_vars + [dep_var]): raise ValueError('variables were specified incorrectly for this coordinate system; incorrect variables were %s'%list(set(all_vars).symmetric_difference(set(indep_vars+[dep_var])))) self.dep_var = dep_var diff -up src/sage/rings/integer.pyx.orig src/sage/rings/integer.pyx --- src/sage/rings/integer.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/rings/integer.pyx 2020-10-30 14:03:05.737896928 -0600 @@ -7093,7 +7093,7 @@ cdef int mpz_set_str_python(mpz_ptr z, c x += 1 # Strip spaces # Disallow a sign here - if x[0] == '-' or x[0] == '+': + if x[0] == c'-' or x[0] == c'+': x = "" # Force an error below assert base >= 2 diff -up src/sage/rings/polynomial/pbori/pbori.pyx.orig src/sage/rings/polynomial/pbori/pbori.pyx --- src/sage/rings/polynomial/pbori/pbori.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/rings/polynomial/pbori/pbori.pyx 2020-11-05 15:44:02.756454276 -0700 @@ -4800,8 +4800,7 @@ cdef class PolynomialConstruct: # So, it is just a conversion. [Simon King] return (ring)._element_constructor_(x) - raise TypeError("Cannot generate Boolean polynomial from %s , %s" % - (type(x), type(ring))) + raise TypeError(f"Cannot generate Boolean polynomial from {type(x)}, {type(ring)}") cdef class MonomialConstruct: diff -up src/sage/rings/real_mpfi.pyx.orig src/sage/rings/real_mpfi.pyx --- src/sage/rings/real_mpfi.pyx.orig 2020-10-30 11:34:28.078977132 -0600 +++ src/sage/rings/real_mpfi.pyx 2020-10-30 14:03:09.088891288 -0600 @@ -1955,12 +1955,12 @@ cdef class RealIntervalFieldElement(Ring cdef long digits digits = strlen(lower_s) - if lower_s[0] == '-': + if lower_s[0] == c'-': digits -= 1 lower_expo -= digits digits = strlen(upper_s) - if upper_s[0] == '-': + if upper_s[0] == c'-': digits -= 1 upper_expo -= digits @@ -2129,7 +2129,7 @@ cdef class RealIntervalFieldElement(Ring raise MemoryError("Unable to allocate memory for the mantissa of an interval") mpz_get_str(tmp_cstr, base, lower_mpz) digits = strlen(tmp_cstr) - if tmp_cstr[0] == '-': + if tmp_cstr[0] == c'-': digits -= 1 mant_string = bytes_to_str(tmp_cstr+1) sign_string = bytes_to_str(b'-') diff -up src/sage/rings/real_mpfr.pyx.orig src/sage/rings/real_mpfr.pyx --- src/sage/rings/real_mpfr.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/rings/real_mpfr.pyx 2020-11-05 15:44:02.769454276 -0700 @@ -2091,7 +2091,7 @@ cdef class RealNumber(sage.structure.ele if s is NULL: raise RuntimeError("unable to convert an mpfr number to a string") # t contains just digits (no sign, decimal point or exponent) - if s[0] == '-': + if s[0] == c'-': sgn = "-" t = char_to_str(s + 1) else: diff -up src/sage/structure/sage_object.pyx.orig src/sage/structure/sage_object.pyx --- src/sage/structure/sage_object.pyx.orig 2020-10-24 11:37:59.000000000 -0600 +++ src/sage/structure/sage_object.pyx 2020-10-30 14:03:09.091891283 -0600 @@ -688,7 +688,7 @@ cdef class SageObject: try: s = self._interface_init_(I) except Exception: - raise NotImplementedError("coercion of object %s to %s not implemented:\n%s\n%s" % (repr(self), I)) + raise NotImplementedError(f"coercion of object {repr(self)} to {I} not implemented") X = I(s) if c: try: diff -up src/sage/symbolic/expression.pyx.orig src/sage/symbolic/expression.pyx --- src/sage/symbolic/expression.pyx.orig 2020-10-30 12:10:19.747169301 -0600 +++ src/sage/symbolic/expression.pyx 2020-10-30 14:03:09.095891276 -0600 @@ -13071,7 +13071,7 @@ cdef class hold_class: sage: SR(2)^5 32 """ - g_set_state('hold', True) + g_set_state(b'hold', True) def __exit__(self, *args): """ @@ -13084,7 +13084,7 @@ cdef class hold_class: sage: SR(2)^5 32 """ - g_set_state('hold', False) + g_set_state(b'hold', False) def start(self): """