Skip to content

Commit

Permalink
Trac #30184: Support Python 3.9
Browse files Browse the repository at this point in the history
We should support Python 3.9 (expected to be released 2020-10-05) in
Sage 9.2.

The present ticket is for the patches necessary to support Python 3.9 in
addition to 3.7 and 3.8.

It does not include the actual upgrade to Python 3.9 - to test, merge
#30589.

- [https://www.python.org/dev/peps/pep-0596/ Python 3.9 release
schedule]
- [https://docs.python.org/3.9/whatsnew/3.9.html What's new in Python
3.9]
- #30384 Adopt the “time window-based” policy for support of Python
versions from NEP 29

URL: https://trac.sagemath.org/30184
Reported by: slelievre
Ticket author(s): Matthias Koeppe
Reviewer(s): John Palmieri, Dima Pasechnik
  • Loading branch information
Release Manager committed Oct 3, 2020
2 parents a1810d5 + 9d06080 commit 91eac29
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 27 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=2d1d5ab6f12d7181f246eacec7b2fb1e1338b9ed
md5=4c9d6a5ed4f1b2494187fe043a15214b
cksum=3219488233
sha1=855a9093485a5f2c04054f4d30251b5bb4e92306
md5=e4b0af774d072208429fefcb2d367123
cksum=4201841578
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
be1a62b3bc99666c909f3672a8bf7baf32a15404
68799277f8eeb04a1201472378e1f71f4f016d71
2 changes: 1 addition & 1 deletion build/pkgs/python3/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SAGE_SPKG_CONFIGURE([python3], [
dnl instead of building our own copy.
check_modules="sqlite3, ctypes, math, hashlib, crypt, readline, socket, zlib, distutils.core"
m4_pushdef([MIN_VERSION], [3.6.0])
m4_pushdef([LT_VERSION], [3.9.0])
m4_pushdef([LT_VERSION], [3.10.0])
AC_CACHE_CHECK([for python3 >= ]MIN_VERSION[, < ]LT_VERSION[ with modules $check_modules], [ac_cv_path_PYTHON3], [
AS_IF([test x"$ac_path_PYTHON3" != x], [dnl checking explicitly specified $with_python
AC_MSG_RESULT([])
Expand Down
5 changes: 5 additions & 0 deletions src/sage/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
# However, be sure to keep OUR deprecation warnings
warnings.filterwarnings('default', category=DeprecationWarning,
message=r'[\s\S]*See https\?://trac\.sagemath\.org/[0-9]* for details.')

# Ignore Python 3.9 deprecation warnings
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='.*ast')

################ end setup warnings ###############################


Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/root_system/pieri_factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def elements(self):
EXAMPLES::
sage: PF = WeylGroup(['A',3]).pieri_factors()
sage: [w.reduced_word() for w in PF.elements()]
[[3, 2, 1], [2, 1], [3, 1], [3, 2], [2], [1], [3], []]
sage: sorted(w.reduced_word() for w in PF.elements())
[[], [1], [2], [2, 1], [3], [3, 1], [3, 2], [3, 2, 1]]
.. SEEALSO:: :meth:`maximal_elements`
Expand Down
10 changes: 10 additions & 0 deletions src/sage/cpython/debugimpl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include <stdio.h>

#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 9

static void _type_debug(PyTypeObject* tp)
{
printf("Not implemented for CPython >= 3.9\n");
}

#else

#define HAVE_WEAKREFS(tp) (1)
#define HAVE_CLASS(tp) (1)
Expand Down Expand Up @@ -340,3 +348,5 @@ static void _type_debug(PyTypeObject* tp)
printf(" tp_version_tag: %lu\n", (unsigned long)tp->tp_version_tag);
}
}

#endif
4 changes: 2 additions & 2 deletions src/sage/geometry/polyhedron/palp_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _palp_Popen(self):
sage: from sage.geometry.polyhedron.palp_database import PALPreader
sage: polygons = PALPreader(2)
sage: polygons._palp_Popen()
<subprocess.Popen object at 0x...>
<...Popen...>
"""

return Popen(["class.x", "-b2a", "-di", self._data_basename],
Expand Down Expand Up @@ -458,7 +458,7 @@ def _palp_Popen(self):
sage: from sage.geometry.polyhedron.palp_database import Reflexive4dHodge
sage: polygons = Reflexive4dHodge(1, 101) # optional - polytopes_db_4d
sage: polygons._palp_Popen() # optional - polytopes_db_4d
<subprocess.Popen object at 0x...>
<...Popen...>
"""

return Popen(['class-4d.x', '-He',
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def has_latex_attr(x):
sage: T._latex_()
Traceback (most recent call last):
...
TypeError: descriptor '_latex_' of 'sage.matrix.matrix0.Matrix' object needs an argument
TypeError: ..._latex_... needs an argument
sage: has_latex_attr(T)
False
"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class SageArgSpecVisitor(ast.NodeVisitor):
sage: sorted(v.items(), key=lambda x: str(x[0]))
[(37.0, 'temp'), ('a', ('e', 2, [None, ({False: True}, 'pi')]))]
sage: v = ast.parse("jc = ['veni', 'vidi', 'vici']").body[0]; v
<_ast.Assign object at ...>
<...ast.Assign object at ...>
sage: attrs = [x for x in dir(v) if not x.startswith('__')]
sage: '_attributes' in attrs and '_fields' in attrs and 'col_offset' in attrs
True
Expand Down Expand Up @@ -2273,7 +2273,7 @@ def sage_getsourcelines(obj):
' def __cinit__(self):\n',
...)
sage: sage_getsourcelines(I)
(['class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \\\n',
([...'class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \\\n',
...)
sage: x = var('x')
sage: sage_getsourcelines(x)
Expand Down Expand Up @@ -2318,7 +2318,7 @@ class Element(object):
sage: P.<x,y> = QQ[]
sage: I = P*[x,y]
sage: sage_getsourcelines(I)
(['class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \\\n',
([...'class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \\\n',
' MPolynomialIdeal_macaulay2_repr, \\\n',
' MPolynomialIdeal_magma_repr, \\\n',
' Ideal_generic ):\n',
Expand Down
16 changes: 2 additions & 14 deletions src/sage/symbolic/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ from sage.rings.all import RR, CC, ZZ

import keyword
import operator
import parser

# Do not allow any of these keywords as identifiers for symbolic variables
KEYWORDS = set(keyword.kwlist).union(['exec', 'print', 'None', 'True',
Expand Down Expand Up @@ -1380,7 +1379,7 @@ def isidentifier(x):
Boolean. Whether the string ``x`` can be used as a variable name.
This function should return ``False`` for keywords, so we can not
just use the ``isidentifier`` method of strings (in Python 3),
just use the ``isidentifier`` method of strings,
because, for example, it returns ``True`` for "def" and for "None".
EXAMPLES::
Expand Down Expand Up @@ -1409,15 +1408,4 @@ def isidentifier(x):
"""
if x in KEYWORDS:
return False
try:
if not x.isidentifier(): # py3
return False
except AttributeError:
pass # py2

try:
code = parser.expr(x).compile()
except (MemoryError, OverflowError, SyntaxError,
SystemError, parser.ParserError):
return False
return len(code.co_names) == 1 and code.co_names[0] == x
return x.isidentifier()

0 comments on commit 91eac29

Please sign in to comment.