Skip to content

Commit

Permalink
Merge branch 'python:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicField authored May 11, 2024
2 parents 0f901c9 + 35c4361 commit 8f5ede6
Show file tree
Hide file tree
Showing 64 changed files with 1,150 additions and 803 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ jobs:
config_hash: ${{ needs.check_source.outputs.config_hash }}
options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
suppressions_path: Tools/tsan/supressions.txt
tsan_logs_artifact_name: tsan-logs-default

build_tsan_free_threading:
name: 'Thread sanitizer (free-threading)'
Expand All @@ -496,6 +497,7 @@ jobs:
config_hash: ${{ needs.check_source.outputs.config_hash }}
options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
suppressions_path: Tools/tsan/suppressions_free_threading.txt
tsan_logs_artifact_name: tsan-logs-free-threading

# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
cifuzz:
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/reusable-tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: 'A repo relative path to the suppressions file'
required: true
type: string
tsan_logs_artifact_name:
description: 'Name of the TSAN logs artifact. Must be unique for each job.'
required: true
type: string

jobs:
build_tsan_reusable:
Expand Down Expand Up @@ -41,7 +45,7 @@ jobs:
sudo sysctl -w vm.mmap_rnd_bits=28
- name: TSAN Option Setup
run: |
echo "TSAN_OPTIONS=suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }}" >> $GITHUB_ENV
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }} handle_segv=0" >> $GITHUB_ENV
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Add ccache to PATH
Expand All @@ -60,3 +64,13 @@ jobs:
run: make pythoninfo
- name: Tests
run: ./python -m test --tsan -j4
- name: Display TSAN logs
if: always()
run: find ${GITHUB_WORKSPACE} -name 'tsan_log.*' | xargs head -n 1000
- name: Archive TSAN logs
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.tsan_logs_artifact_name }}
path: tsan_log.*
if-no-files-found: ignore
4 changes: 4 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@
epub_author = 'Python Documentation Authors'
epub_publisher = 'Python Software Foundation'

# index pages are not valid xhtml
# https://github.com/sphinx-doc/sphinx/issues/12359
epub_use_index = False

# Options for the coverage checker
# --------------------------------

Expand Down
1 change: 0 additions & 1 deletion Doc/library/allos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ but they are available on most other systems as well. Here's an overview:
io.rst
time.rst
argparse.rst
getopt.rst
logging.rst
logging.config.rst
logging.handlers.rst
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/secrets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ randomness that your operating system provides.
sources provided by the operating system. See
:class:`random.SystemRandom` for additional details.

.. function:: choice(sequence)
.. function:: choice(seq)

Return a randomly chosen element from a non-empty sequence.

.. function:: randbelow(n)
.. function:: randbelow(exclusive_upper_bound)

Return a random int in the range [0, *n*).
Return a random int in the range [0, *exclusive_upper_bound*).

.. function:: randbits(k)

Expand Down
22 changes: 2 additions & 20 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -545,26 +545,6 @@ Module constants
.. versionchanged:: 3.11
Set *threadsafety* dynamically instead of hard-coding it to ``1``.

.. data:: version

Version number of this module as a :class:`string <str>`.
This is not the version of the SQLite library.

.. deprecated-removed:: 3.12 3.14
This constant used to reflect the version number of the ``pysqlite``
package, a third-party library which used to upstream changes to
:mod:`!sqlite3`. Today, it carries no meaning or practical value.

.. data:: version_info

Version number of this module as a :class:`tuple` of :class:`integers <int>`.
This is not the version of the SQLite library.

.. deprecated-removed:: 3.12 3.14
This constant used to reflect the version number of the ``pysqlite``
package, a third-party library which used to upstream changes to
:mod:`!sqlite3`. Today, it carries no meaning or practical value.

.. _sqlite3-dbconfig-constants:

.. data:: SQLITE_DBCONFIG_DEFENSIVE
Expand Down Expand Up @@ -597,6 +577,8 @@ Module constants
https://www.sqlite.org/c3ref/c_dbconfig_defensive.html
SQLite docs: Database Connection Configuration Options

.. deprecated-removed:: 3.12 3.14
The :data:`!version` and :data:`!version_info` constants.

.. _sqlite3-connection-objects:

Expand Down
2 changes: 1 addition & 1 deletion Doc/tools/extensions/glossary_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def process_glossary_nodes(app, doctree, fromdocname):
if app.builder.format != 'html':
if app.builder.format != 'html' or app.builder.embedded:
return

terms = {}
Expand Down
2 changes: 2 additions & 0 deletions Doc/tools/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</style>
{{ super() }}

{%- if not embedded %}
<meta name="readthedocs-addons-api-version" content="1">
<script type="text/javascript">
function onSwitch(event) {
Expand Down Expand Up @@ -127,4 +128,5 @@
}
});
</script>
{%- endif %}
{% endblock %}
5 changes: 4 additions & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ mmap
* :class:`mmap.mmap` now has a *trackfd* parameter on Unix; if it is ``False``,
the file descriptor specified by *fileno* will not be duplicated.
(Contributed by Zackery Spytz and Petr Viktorin in :gh:`78502`.)
* :class:`mmap.mmap` is now protected from crashing on Windows when the mapped memory
is inaccessible due to file system errors or access violations.
(Contributed by Jannis Weigend in :gh:`118209`.)

opcode
------
Expand Down Expand Up @@ -1633,7 +1636,7 @@ Pending Removal in Python 3.14

* :mod:`sqlite3`:

* :data:`~sqlite3.version` and :data:`~sqlite3.version_info`.
* :data:`!version` and :data:`!version_info`.

* :meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany`
if :ref:`named placeholders <sqlite3-placeholders>` are used and
Expand Down
48 changes: 37 additions & 11 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,57 @@ Removed
argparse
--------

* The *type*, *choices*, and *metavar* parameters
of :class:`!argparse.BooleanOptionalAction` are removed.
* Remove the *type*, *choices*, and *metavar* parameters
of :class:`!argparse.BooleanOptionalAction`.
They were deprecated since 3.12.

collections.abc
---------------

* Remove :class:`!collections.abc.ByteString`. It had previously raised a
:exc:`DeprecationWarning` since Python 3.12.


email
-----

* The *isdst* parameter has been removed from :func:`email.utils.localtime`.
* Remove the *isdst* parameter from :func:`email.utils.localtime`.
(Contributed by Hugo van Kemenade in :gh:`118798`.)

itertools
---------

* Remove :mod:`itertools` support for copy, deepcopy, and pickle operations.
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
(Contributed by Raymond Hettinger in :gh:`101588`.)

pathlib
-------

* Remove support for passing additional positional arguments to
:meth:`pathlib.PurePath.relative_to` and
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such
arguments are joined onto *other*.

sqlite3
-------

* Remove :data:`!version` and :data:`!version_info` from :mod:`sqlite3`.
(Contributed by Hugo van Kemenade in :gh:`118924`.)

typing
------

* Remove :class:`!typing.ByteString`. It had previously raised a
:exc:`DeprecationWarning` since Python 3.12.

Others
------

* Using :data:`NotImplemented` in a boolean context will now raise a :exc:`TypeError`.
It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed
by Jelle Zijlstra in :gh:`118767`.)

* :class:`!typing.ByteString` and :class:`!collections.abc.ByteString`
are removed. They had previously raised a :exc:`DeprecationWarning`
since Python 3.12.

* :mod:`itertools` support for copy, deepcopy, and pickle operations.
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
(Contributed by Raymond Hettinger in :gh:`101588`.)


Porting to Python 3.14
======================
Expand Down
41 changes: 6 additions & 35 deletions Include/cpython/optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ typedef struct _PyExecutorLinkListNode {

/* Bloom filter with m = 256
* https://en.wikipedia.org/wiki/Bloom_filter */
#define BLOOM_FILTER_WORDS 8
#define _Py_BLOOM_FILTER_WORDS 8

typedef struct _bloom_filter {
uint32_t bits[BLOOM_FILTER_WORDS];
typedef struct {
uint32_t bits[_Py_BLOOM_FILTER_WORDS];
} _PyBloomFilter;

typedef struct {
Expand All @@ -31,11 +31,6 @@ typedef struct {
PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR).
} _PyVMData;

#define UOP_FORMAT_TARGET 0
#define UOP_FORMAT_EXIT 1
#define UOP_FORMAT_JUMP 2
#define UOP_FORMAT_UNUSED 3

/* Depending on the format,
* the 32 bits between the oparg and operand are:
* UOP_FORMAT_TARGET:
Expand Down Expand Up @@ -64,31 +59,7 @@ typedef struct {
uint64_t operand; // A cache entry
} _PyUOpInstruction;

static inline uint32_t uop_get_target(const _PyUOpInstruction *inst)
{
assert(inst->format == UOP_FORMAT_TARGET);
return inst->target;
}

static inline uint16_t uop_get_exit_index(const _PyUOpInstruction *inst)
{
assert(inst->format == UOP_FORMAT_EXIT);
return inst->exit_index;
}

static inline uint16_t uop_get_jump_target(const _PyUOpInstruction *inst)
{
assert(inst->format == UOP_FORMAT_JUMP);
return inst->jump_target;
}

static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst)
{
assert(inst->format != UOP_FORMAT_TARGET);
return inst->error_target;
}

typedef struct _exit_data {
typedef struct {
uint32_t target;
_Py_BackoffCounter temperature;
const struct _PyExecutorObject *executor;
Expand All @@ -109,14 +80,14 @@ typedef struct _PyExecutorObject {
typedef struct _PyOptimizerObject _PyOptimizerObject;

/* Should return > 0 if a new executor is created. O if no executor is produced and < 0 if an error occurred. */
typedef int (*optimize_func)(
typedef int (*_Py_optimize_func)(
_PyOptimizerObject* self, struct _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr, _PyExecutorObject **exec_ptr,
int curr_stackentries);

struct _PyOptimizerObject {
PyObject_HEAD
optimize_func optimize;
_Py_optimize_func optimize;
/* Data needed by the optimizer goes here, but is opaque to the VM */
};

Expand Down
2 changes: 2 additions & 0 deletions Include/cpython/weakrefobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ struct _PyWeakReference {
#endif
};

PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);

Py_DEPRECATED(3.13) static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj)
{
PyWeakReference *ref;
Expand Down
43 changes: 37 additions & 6 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ struct _Py_UopsSymbol {
PyObject *const_val; // Owned reference (!)
};

#define UOP_FORMAT_TARGET 0
#define UOP_FORMAT_EXIT 1
#define UOP_FORMAT_JUMP 2
#define UOP_FORMAT_UNUSED 3

static inline uint32_t uop_get_target(const _PyUOpInstruction *inst)
{
assert(inst->format == UOP_FORMAT_TARGET);
return inst->target;
}

static inline uint16_t uop_get_exit_index(const _PyUOpInstruction *inst)
{
assert(inst->format == UOP_FORMAT_EXIT);
return inst->exit_index;
}

static inline uint16_t uop_get_jump_target(const _PyUOpInstruction *inst)
{
assert(inst->format == UOP_FORMAT_JUMP);
return inst->jump_target;
}

static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst)
{
assert(inst->format != UOP_FORMAT_TARGET);
return inst->error_target;
}

// Holds locals, stack, locals, stack ... co_consts (in that order)
#define MAX_ABSTRACT_INTERP_SIZE 4096

Expand Down Expand Up @@ -64,7 +93,9 @@ typedef struct ty_arena {
} ty_arena;

struct _Py_UOpsContext {
PyObject_HEAD
char done;
char out_of_space;
bool contradiction;
// The current "executing" frame.
_Py_UOpsAbstractFrame *frame;
_Py_UOpsAbstractFrame frames[MAX_ABSTRACT_FRAME_DEPTH];
Expand Down Expand Up @@ -92,16 +123,16 @@ extern _Py_UopsSymbol *_Py_uop_sym_new_const(_Py_UOpsContext *ctx, PyObject *con
extern _Py_UopsSymbol *_Py_uop_sym_new_null(_Py_UOpsContext *ctx);
extern bool _Py_uop_sym_has_type(_Py_UopsSymbol *sym);
extern bool _Py_uop_sym_matches_type(_Py_UopsSymbol *sym, PyTypeObject *typ);
extern bool _Py_uop_sym_set_null(_Py_UopsSymbol *sym);
extern bool _Py_uop_sym_set_non_null(_Py_UopsSymbol *sym);
extern bool _Py_uop_sym_set_type(_Py_UopsSymbol *sym, PyTypeObject *typ);
extern bool _Py_uop_sym_set_const(_Py_UopsSymbol *sym, PyObject *const_val);
extern void _Py_uop_sym_set_null(_Py_UOpsContext *ctx, _Py_UopsSymbol *sym);
extern void _Py_uop_sym_set_non_null(_Py_UOpsContext *ctx, _Py_UopsSymbol *sym);
extern void _Py_uop_sym_set_type(_Py_UOpsContext *ctx, _Py_UopsSymbol *sym, PyTypeObject *typ);
extern void _Py_uop_sym_set_const(_Py_UOpsContext *ctx, _Py_UopsSymbol *sym, PyObject *const_val);
extern bool _Py_uop_sym_is_bottom(_Py_UopsSymbol *sym);
extern int _Py_uop_sym_truthiness(_Py_UopsSymbol *sym);
extern PyTypeObject *_Py_uop_sym_get_type(_Py_UopsSymbol *sym);


extern int _Py_uop_abstractcontext_init(_Py_UOpsContext *ctx);
extern void _Py_uop_abstractcontext_init(_Py_UOpsContext *ctx);
extern void _Py_uop_abstractcontext_fini(_Py_UOpsContext *ctx);

extern _Py_UOpsAbstractFrame *_Py_uop_frame_new(
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_typevarobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern int _Py_initialize_generic(PyInterpreterState *);
extern void _Py_clear_generic_types(PyInterpreterState *);

extern PyTypeObject _PyTypeAlias_Type;
extern PyTypeObject _PyNoDefault_Type;
extern PyObject _Py_NoDefaultStruct;

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 8f5ede6

Please sign in to comment.