-
-
Notifications
You must be signed in to change notification settings - Fork 622
Support python 3.12 on sagemath-standard #36407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dc71bd0
py312: changes in PyLong internals
tornaria 4d35af2
py312: atexit_callback change
tornaria 2f31aa8
py312: disable cython profile=true in one file
tornaria c9c5026
py312: fix issue when including internal python header
tornaria ca63dcf
py312: use new api for ast
tornaria 7710fc0
py312: filter deprecation warnings
tornaria 57a5468
py312: don't use `pkgutil.find_loader()`
tornaria 29e4ebd
py312: fix `sage.misc.dev_tools.load_submodules()`
tornaria 07ee873
py312: sum changed in python 3.12, fix doctest
tornaria 3600123
py312: use dict instead of OrderedDict for consistent printing
tornaria 168063c
py312: fix crash in polyhedron face iterator
tornaria 0a1dd38
py312: fix warning in string literal
tornaria 3a7cd3f
py312: skip a test that fails with python 3.12
tornaria 1cf3634
Merge branch 'develop' into py312
mkoeppe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "Python.h" | ||
#include <stdbool.h> | ||
|
||
#if PY_VERSION_HEX >= 0x030C00A5 | ||
#define ob_digit(o) (((PyLongObject*)o)->long_value.ob_digit) | ||
#else | ||
#define ob_digit(o) (((PyLongObject*)o)->ob_digit) | ||
#endif | ||
|
||
#if PY_VERSION_HEX >= 0x030C00A7 | ||
// taken from cpython:Include/internal/pycore_long.h @ 3.12 | ||
|
||
/* Long value tag bits: | ||
* 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1. | ||
* 2: Reserved for immortality bit | ||
* 3+ Unsigned digit count | ||
*/ | ||
#define SIGN_MASK 3 | ||
#define SIGN_ZERO 1 | ||
#define SIGN_NEGATIVE 2 | ||
#define NON_SIZE_BITS 3 | ||
|
||
static inline bool | ||
_PyLong_IsZero(const PyLongObject *op) | ||
{ | ||
return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO; | ||
} | ||
|
||
static inline bool | ||
_PyLong_IsNegative(const PyLongObject *op) | ||
{ | ||
return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE; | ||
} | ||
|
||
static inline bool | ||
_PyLong_IsPositive(const PyLongObject *op) | ||
{ | ||
return (op->long_value.lv_tag & SIGN_MASK) == 0; | ||
} | ||
|
||
static inline Py_ssize_t | ||
_PyLong_DigitCount(const PyLongObject *op) | ||
{ | ||
assert(PyLong_Check(op)); | ||
return op->long_value.lv_tag >> NON_SIZE_BITS; | ||
} | ||
|
||
#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS)) | ||
|
||
static inline void | ||
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size) | ||
{ | ||
assert(size >= 0); | ||
assert(-1 <= sign && sign <= 1); | ||
assert(sign != 0 || size == 0); | ||
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size); | ||
} | ||
|
||
#else | ||
// fallback for < 3.12 | ||
|
||
static inline bool | ||
_PyLong_IsZero(const PyLongObject *op) | ||
{ | ||
return Py_SIZE(op) == 0; | ||
} | ||
|
||
static inline bool | ||
_PyLong_IsNegative(const PyLongObject *op) | ||
{ | ||
return Py_SIZE(op) < 0; | ||
} | ||
|
||
static inline bool | ||
_PyLong_IsPositive(const PyLongObject *op) | ||
{ | ||
return Py_SIZE(op) > 0; | ||
} | ||
|
||
static inline Py_ssize_t | ||
_PyLong_DigitCount(const PyLongObject *op) | ||
{ | ||
Py_ssize_t size = Py_SIZE(op); | ||
return size < 0 ? -size : size; | ||
} | ||
|
||
static inline void | ||
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size) | ||
{ | ||
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9) | ||
// The function Py_SET_SIZE is defined starting with python 3.9. | ||
Py_SIZE(o) = size; | ||
#else | ||
Py_SET_SIZE(op, sign < 0 ? -size : size); | ||
#endif | ||
} | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from cpython.longintrepr cimport py_long, digit | ||
|
||
cdef extern from "pycore_long.h": | ||
digit* ob_digit(py_long o) | ||
bint _PyLong_IsZero(py_long o) | ||
bint _PyLong_IsNegative(py_long o) | ||
bint _PyLong_IsPositive(py_long o) | ||
Py_ssize_t _PyLong_DigitCount(py_long o) | ||
void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# sage.doctest: optional - sage.rings.finite_rings | ||
# cython: profile=True | ||
""" | ||
Lean matrices | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.