[Python-checkins] gh-109653: Speedup import of threading module (#114509)
https://github.com/python/cpython/commit/5e390a0fc825f21952beb158e2bda3c5e007fac9
commit: 5e390a0fc825f21952beb158e2bda3c5e007fac9
branch: main
author: Daniel Hollas
committer: AlexWaygood
date: 2024-01-31T09:29:44Z
summary:
gh-109653: Speedup import of threading module (#114509)
Avoiding an import of functools leads to 50% speedup of import time.
Co-authored-by: Alex Waygood
files:
A Misc/NEWS.d/next/Library/2024-01-23-23-13-47.gh-issue-109653.KLBHmT.rst
M Lib/threading.py
diff --git a/Lib/threading.py b/Lib/threading.py
index 00b95f8d92a1f0..75a08e5aac97d6 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -3,7 +3,6 @@
import os as _os
import sys as _sys
import _thread
-import functools
import warnings
from time import monotonic as _time
@@ -1630,8 +1629,7 @@ def _register_atexit(func, *arg, **kwargs):
if _SHUTTING_DOWN:
raise RuntimeError("can't register atexit after shutdown")
-call = functools.partial(func, *arg, **kwargs)
-_threading_atexits.append(call)
+_threading_atexits.append(lambda: func(*arg, **kwargs))
from _thread import stack_size
diff --git
a/Misc/NEWS.d/next/Library/2024-01-23-23-13-47.gh-issue-109653.KLBHmT.rst
b/Misc/NEWS.d/next/Library/2024-01-23-23-13-47.gh-issue-109653.KLBHmT.rst
new file mode 100644
index 00..76074df9c76fa6
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-23-23-13-47.gh-issue-109653.KLBHmT.rst
@@ -0,0 +1 @@
+Reduce the import time of :mod:`threading` module by ~50%. Patch by Daniel
Hollas.
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] [3.11] gh-101100: Fix references in csv docs (GH-114658) (GH-114773)
https://github.com/python/cpython/commit/a38bc7cad613b604671764d893873d291269c61f commit: a38bc7cad613b604671764d893873d291269c61f branch: 3.11 author: Skip Montanaro committer: serhiy-storchaka date: 2024-01-31T09:32:12Z summary: [3.11] gh-101100: Fix references in csv docs (GH-114658) (GH-114773) Co-authored-by: Hugo van Kemenade <[email protected]> (cherry picked from commit 3911b42cc0d404e0eac87fce30b740b08618ff06) files: M Doc/library/csv.rst M Doc/tools/.nitignore diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 8004d66e6f4e7d..e82c7de5fc223c 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -88,7 +88,7 @@ The :mod:`csv` module defines the following functions: Return a writer object responsible for converting the user's data into delimited strings on the given file-like object. *csvfile* can be any object with a - :func:`write` method. If *csvfile* is a file object, it should be opened with + :meth:`~io.TextIOBase.write` method. If *csvfile* is a file object, it should be opened with ``newline=''`` [1]_. An optional *dialect* parameter can be given which is used to define a set of parameters specific to a particular CSV dialect. It may be an instance of a subclass of the @@ -195,10 +195,10 @@ The :mod:`csv` module defines the following classes: Create an object which operates like a regular writer but maps dictionaries onto output rows. The *fieldnames* parameter is a :mod:`sequence ` of keys that identify the order in which values in the - dictionary passed to the :meth:`writerow` method are written to file + dictionary passed to the :meth:`~csvwriter.writerow` method are written to file *f*. The optional *restval* parameter specifies the value to be written if the dictionary is missing a key in *fieldnames*. If the - dictionary passed to the :meth:`writerow` method contains a key not found in + dictionary passed to the :meth:`~csvwriter.writerow` method contains a key not found in *fieldnames*, the optional *extrasaction* parameter indicates what action to take. If it is set to ``'raise'``, the default value, a :exc:`ValueError` @@ -352,8 +352,8 @@ Dialects and Formatting Parameters To make it easier to specify the format of input and output records, specific formatting parameters are grouped together into dialects. A dialect is a -subclass of the :class:`Dialect` class having a set of specific methods and a -single :meth:`validate` method. When creating :class:`reader` or +subclass of the :class:`Dialect` class containing various attributes +describing the format of the CSV file. When creating :class:`reader` or :class:`writer` objects, the programmer can specify a string or a subclass of the :class:`Dialect` class as the dialect parameter. In addition to, or instead of, the *dialect* parameter, the programmer can also specify individual @@ -470,9 +470,9 @@ DictReader objects have the following public attribute: Writer Objects -- -:class:`Writer` objects (:class:`DictWriter` instances and objects returned by +:class:`writer` objects (:class:`DictWriter` instances and objects returned by the :func:`writer` function) have the following public methods. A *row* must be -an iterable of strings or numbers for :class:`Writer` objects and a dictionary +an iterable of strings or numbers for :class:`writer` objects and a dictionary mapping fieldnames to strings or numbers (by passing them through :func:`str` first) for :class:`DictWriter` objects. Note that complex numbers are written out surrounded by parens. This may cause some problems for other programs which diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 266f1c7b32b6d7..c2f800715af308 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -27,7 +27,6 @@ Doc/library/asyncio-subprocess.rst Doc/library/bdb.rst Doc/library/collections.rst Doc/library/copy.rst -Doc/library/csv.rst Doc/library/ctypes.rst Doc/library/dbm.rst Doc/library/decimal.rst ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-101100: Fix references in csv docs (GH-114658) (GH-114771)
https://github.com/python/cpython/commit/bb578f6286f6255b61e393a56f345c07fc9e2f7f commit: bb578f6286f6255b61e393a56f345c07fc9e2f7f branch: 3.12 author: Skip Montanaro committer: serhiy-storchaka date: 2024-01-31T09:32:25Z summary: [3.12] gh-101100: Fix references in csv docs (GH-114658) (GH-114771) Co-authored-by: Hugo van Kemenade <[email protected]> (cherry picked from commit 3911b42cc0d404e0eac87fce30b740b08618ff06) files: M Doc/library/csv.rst M Doc/tools/.nitignore diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 07f38f5690bb54..66888c22b7cc28 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -88,7 +88,7 @@ The :mod:`csv` module defines the following functions: Return a writer object responsible for converting the user's data into delimited strings on the given file-like object. *csvfile* can be any object with a - :func:`write` method. If *csvfile* is a file object, it should be opened with + :meth:`~io.TextIOBase.write` method. If *csvfile* is a file object, it should be opened with ``newline=''`` [1]_. An optional *dialect* parameter can be given which is used to define a set of parameters specific to a particular CSV dialect. It may be an instance of a subclass of the @@ -197,10 +197,10 @@ The :mod:`csv` module defines the following classes: Create an object which operates like a regular writer but maps dictionaries onto output rows. The *fieldnames* parameter is a :mod:`sequence ` of keys that identify the order in which values in the - dictionary passed to the :meth:`writerow` method are written to file + dictionary passed to the :meth:`~csvwriter.writerow` method are written to file *f*. The optional *restval* parameter specifies the value to be written if the dictionary is missing a key in *fieldnames*. If the - dictionary passed to the :meth:`writerow` method contains a key not found in + dictionary passed to the :meth:`~csvwriter.writerow` method contains a key not found in *fieldnames*, the optional *extrasaction* parameter indicates what action to take. If it is set to ``'raise'``, the default value, a :exc:`ValueError` @@ -374,8 +374,8 @@ Dialects and Formatting Parameters To make it easier to specify the format of input and output records, specific formatting parameters are grouped together into dialects. A dialect is a -subclass of the :class:`Dialect` class having a set of specific methods and a -single :meth:`validate` method. When creating :class:`reader` or +subclass of the :class:`Dialect` class containing various attributes +describing the format of the CSV file. When creating :class:`reader` or :class:`writer` objects, the programmer can specify a string or a subclass of the :class:`Dialect` class as the dialect parameter. In addition to, or instead of, the *dialect* parameter, the programmer can also specify individual @@ -492,9 +492,9 @@ DictReader objects have the following public attribute: Writer Objects -- -:class:`Writer` objects (:class:`DictWriter` instances and objects returned by +:class:`writer` objects (:class:`DictWriter` instances and objects returned by the :func:`writer` function) have the following public methods. A *row* must be -an iterable of strings or numbers for :class:`Writer` objects and a dictionary +an iterable of strings or numbers for :class:`writer` objects and a dictionary mapping fieldnames to strings or numbers (by passing them through :func:`str` first) for :class:`DictWriter` objects. Note that complex numbers are written out surrounded by parens. This may cause some problems for other programs which diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 46a4f4e48e0e2a..5205627f6c2b25 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -34,7 +34,6 @@ Doc/library/cgi.rst Doc/library/chunk.rst Doc/library/collections.rst Doc/library/copy.rst -Doc/library/csv.rst Doc/library/dbm.rst Doc/library/decimal.rst Doc/library/email.charset.rst ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-101100: Fix class reference in library/test.rst (GH-114769)
https://github.com/python/cpython/commit/7a93db44257c0404dc407ff2ddc997f4bb8890ed commit: 7a93db44257c0404dc407ff2ddc997f4bb8890ed branch: main author: Skip Montanaro committer: serhiy-storchaka date: 2024-01-31T11:33:10+02:00 summary: gh-101100: Fix class reference in library/test.rst (GH-114769) The text clearly seems to be referencing `TestFuncAcceptsSequencesMixin`, for which no target is available. Name the class properly and suppress the dangling reference. files: M Doc/library/test.rst diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 9173db07fd0071..cad1023021a512 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -143,7 +143,7 @@ guidelines to be followed: arg = (1, 2, 3) When using this pattern, remember that all classes that inherit from - :class:`unittest.TestCase` are run as tests. The :class:`Mixin` class in the example above + :class:`unittest.TestCase` are run as tests. The :class:`!TestFuncAcceptsSequencesMixin` class in the example above does not have any data and so can't be run by itself, thus it does not inherit from :class:`unittest.TestCase`. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-101100: Fix class reference in library/test.rst (GH-114769) (GH-114794)
https://github.com/python/cpython/commit/0536bbb192c5ecca5e21385f82b0ac86f2e7e34c commit: 0536bbb192c5ecca5e21385f82b0ac86f2e7e34c branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka date: 2024-01-31T09:41:10Z summary: [3.12] gh-101100: Fix class reference in library/test.rst (GH-114769) (GH-114794) The text clearly seems to be referencing `TestFuncAcceptsSequencesMixin`, for which no target is available. Name the class properly and suppress the dangling reference. (cherry picked from commit 7a93db44257c0404dc407ff2ddc997f4bb8890ed) Co-authored-by: Skip Montanaro files: M Doc/library/test.rst diff --git a/Doc/library/test.rst b/Doc/library/test.rst index 9173db07fd0071..cad1023021a512 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -143,7 +143,7 @@ guidelines to be followed: arg = (1, 2, 3) When using this pattern, remember that all classes that inherit from - :class:`unittest.TestCase` are run as tests. The :class:`Mixin` class in the example above + :class:`unittest.TestCase` are run as tests. The :class:`!TestFuncAcceptsSequencesMixin` class in the example above does not have any data and so can't be run by itself, thus it does not inherit from :class:`unittest.TestCase`. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] gh-101100: Fix class reference in library/test.rst (GH-114769) (GH-114793)
https://github.com/python/cpython/commit/ad6233396a323c0a6e90edd3c9b2b832928acb92 commit: ad6233396a323c0a6e90edd3c9b2b832928acb92 branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka date: 2024-01-31T09:41:00Z summary: [3.11] gh-101100: Fix class reference in library/test.rst (GH-114769) (GH-114793) The text clearly seems to be referencing `TestFuncAcceptsSequencesMixin`, for which no target is available. Name the class properly and suppress the dangling reference. (cherry picked from commit 7a93db44257c0404dc407ff2ddc997f4bb8890ed) Co-authored-by: Skip Montanaro files: M Doc/library/test.rst diff --git a/Doc/library/test.rst b/Doc/library/test.rst index a0db28a718e000..c942685310f78a 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -143,7 +143,7 @@ guidelines to be followed: arg = (1, 2, 3) When using this pattern, remember that all classes that inherit from - :class:`unittest.TestCase` are run as tests. The :class:`Mixin` class in the example above + :class:`unittest.TestCase` are run as tests. The :class:`!TestFuncAcceptsSequencesMixin` class in the example above does not have any data and so can't be run by itself, thus it does not inherit from :class:`unittest.TestCase`. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114685: Check flags in PyObject_GetBuffer() (GH-114707)
https://github.com/python/cpython/commit/b7688ef71eddcaf14f71b1c22ff2f164f34b2c74 commit: b7688ef71eddcaf14f71b1c22ff2f164f34b2c74 branch: main author: Serhiy Storchaka committer: serhiy-storchaka date: 2024-01-31T13:11:35+02:00 summary: gh-114685: Check flags in PyObject_GetBuffer() (GH-114707) PyObject_GetBuffer() now raises a SystemError if called with PyBUF_READ or PyBUF_WRITE as flags. These flags should only be used with the PyMemoryView_* C API. files: A Misc/NEWS.d/next/C API/2024-01-29-12-13-24.gh-issue-114685.B07RME.rst M Lib/test/test_buffer.py M Modules/_testcapi/buffer.c M Objects/abstract.c diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 72a06d6af450e3..535b795f508a24 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -4585,6 +4585,12 @@ def test_c_buffer(self): buf.__release_buffer__(mv) self.assertEqual(buf.references, 0) [email protected](_testcapi is None, "requires _testcapi") +def test_c_buffer_invalid_flags(self): +buf = _testcapi.testBuf() +self.assertRaises(SystemError, buf.__buffer__, PyBUF_READ) +self.assertRaises(SystemError, buf.__buffer__, PyBUF_WRITE) + def test_inheritance(self): class A(bytearray): def __buffer__(self, flags): diff --git a/Misc/NEWS.d/next/C API/2024-01-29-12-13-24.gh-issue-114685.B07RME.rst b/Misc/NEWS.d/next/C API/2024-01-29-12-13-24.gh-issue-114685.B07RME.rst new file mode 100644 index 00..55b02d1d8e1e9f --- /dev/null +++ b/Misc/NEWS.d/next/C API/2024-01-29-12-13-24.gh-issue-114685.B07RME.rst @@ -0,0 +1,3 @@ +:c:func:`PyObject_GetBuffer` now raises a :exc:`SystemError` if called with +:c:macro:`PyBUF_READ` or :c:macro:`PyBUF_WRITE` as flags. These flags should +only be used with the ``PyMemoryView_*`` C API. diff --git a/Modules/_testcapi/buffer.c b/Modules/_testcapi/buffer.c index 942774156c6c47..7e2f6e5e29482c 100644 --- a/Modules/_testcapi/buffer.c +++ b/Modules/_testcapi/buffer.c @@ -54,8 +54,10 @@ static int testbuf_getbuf(testBufObject *self, Py_buffer *view, int flags) { int buf = PyObject_GetBuffer(self->obj, view, flags); -Py_SETREF(view->obj, Py_NewRef(self)); -self->references++; +if (buf == 0) { +Py_SETREF(view->obj, Py_NewRef(self)); +self->references++; +} return buf; } diff --git a/Objects/abstract.c b/Objects/abstract.c index 1ec5c5b8c3dc2f..daf04eb4ab2cda 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -425,6 +425,12 @@ PyObject_AsWriteBuffer(PyObject *obj, int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { +if (flags != PyBUF_SIMPLE) { /* fast path */ +if (flags == PyBUF_READ || flags == PyBUF_WRITE) { +PyErr_BadInternalCall(); +return -1; +} +} PyBufferProcs *pb = Py_TYPE(obj)->tp_as_buffer; if (pb == NULL || pb->bf_getbuffer == NULL) { ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755)
https://github.com/python/cpython/commit/66f95ea6a65deff547cab0d312b8c8c8a4cf8beb
commit: 66f95ea6a65deff547cab0d312b8c8c8a4cf8beb
branch: main
author: Sam Gross
committer: serhiy-storchaka
date: 2024-01-31T13:22:24+02:00
summary:
gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755)
Prior to gh-114269, the iterator returned by ElementTree.iterparse was
initialized with the root attribute as None. This restores the previous
behavior.
files:
M Lib/test/test_xml_etree.py
M Lib/xml/etree/ElementTree.py
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index b9e7937b0bbc00..221545b315fa44 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -536,7 +536,9 @@ def test_iterparse(self):
iterparse = ET.iterparse
context = iterparse(SIMPLE_XMLFILE)
+self.assertIsNone(context.root)
action, elem = next(context)
+self.assertIsNone(context.root)
self.assertEqual((action, elem.tag), ('end', 'element'))
self.assertEqual([(action, elem.tag) for action, elem in context], [
('end', 'element'),
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index ae6575028be11c..bb7362d1634a72 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1256,8 +1256,8 @@ def __del__(self):
source.close()
it = IterParseIterator()
+it.root = None
wr = weakref.ref(it)
-del IterParseIterator
return it
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] Remove Alex Waygood as an Argument Clinic CODEOWNER (#114796)
https://github.com/python/cpython/commit/25ce7f872df661de9392122df17111c75c77dee0 commit: 25ce7f872df661de9392122df17111c75c77dee0 branch: main author: Alex Waygood committer: AlexWaygood date: 2024-01-31T11:28:23Z summary: Remove Alex Waygood as an Argument Clinic CODEOWNER (#114796) files: M .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f4d0411504a832..7933d319550576 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -230,8 +230,8 @@ Doc/c-api/stable.rst @encukou **/*zipfile/_path/* @jaraco # Argument Clinic -/Tools/clinic/** @erlend-aasland @AlexWaygood -/Lib/test/test_clinic.py @erlend-aasland @AlexWaygood +/Tools/clinic/** @erlend-aasland +/Lib/test/test_clinic.py @erlend-aasland Doc/howto/clinic.rst @erlend-aasland # Subinterpreters ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114790: Do not execute `workflows/require-pr-label.yml` on forks (#114791)
https://github.com/python/cpython/commit/1c2ea8b33c6b1f995db0aca0b223a9cc22426708 commit: 1c2ea8b33c6b1f995db0aca0b223a9cc22426708 branch: main author: Nikita Sobolev committer: hugovk <[email protected]> date: 2024-01-31T13:32:27+02:00 summary: gh-114790: Do not execute `workflows/require-pr-label.yml` on forks (#114791) Co-authored-by: Hugo van Kemenade <[email protected]> files: M .github/workflows/require-pr-label.yml diff --git a/.github/workflows/require-pr-label.yml b/.github/workflows/require-pr-label.yml index 080204bcfd3b94..ff5cbdf3eda749 100644 --- a/.github/workflows/require-pr-label.yml +++ b/.github/workflows/require-pr-label.yml @@ -11,6 +11,7 @@ permissions: jobs: label: name: DO-NOT-MERGE / unresolved review +if: github.repository_owner == 'python' runs-on: ubuntu-latest timeout-minutes: 10 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) (GH-114798)
https://github.com/python/cpython/commit/5d7b90db0cd463e69d15acf5498232b9bc2bfeaa commit: 5d7b90db0cd463e69d15acf5498232b9bc2bfeaa branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka date: 2024-01-31T11:59:58Z summary: [3.12] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) (GH-114798) Prior to gh-114269, the iterator returned by ElementTree.iterparse was initialized with the root attribute as None. This restores the previous behavior. (cherry picked from commit 66f95ea6a65deff547cab0d312b8c8c8a4cf8beb) Co-authored-by: Sam Gross files: M Lib/test/test_xml_etree.py M Lib/xml/etree/ElementTree.py diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 53a4e9f821d6dd..b50898f1d18b58 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -536,7 +536,9 @@ def test_iterparse(self): iterparse = ET.iterparse context = iterparse(SIMPLE_XMLFILE) +self.assertIsNone(context.root) action, elem = next(context) +self.assertIsNone(context.root) self.assertEqual((action, elem.tag), ('end', 'element')) self.assertEqual([(action, elem.tag) for action, elem in context], [ ('end', 'element'), diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index ae6575028be11c..bb7362d1634a72 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1256,8 +1256,8 @@ def __del__(self): source.close() it = IterParseIterator() +it.root = None wr = weakref.ref(it) -del IterParseIterator return it ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) (GH-114799)
https://github.com/python/cpython/commit/3982049a3054b0503b09d9b9d2a1735a3195048c commit: 3982049a3054b0503b09d9b9d2a1735a3195048c branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka date: 2024-01-31T12:03:08Z summary: [3.11] gh-114737: Revert change to ElementTree.iterparse "root" attribute (GH-114755) (GH-114799) Prior to gh-114269, the iterator returned by ElementTree.iterparse was initialized with the root attribute as None. This restores the previous behavior. (cherry picked from commit 66f95ea6a65deff547cab0d312b8c8c8a4cf8beb) Co-authored-by: Sam Gross files: M Lib/test/test_xml_etree.py M Lib/xml/etree/ElementTree.py diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 57f5de34fdc108..267982a8233c92 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -536,7 +536,9 @@ def test_iterparse(self): iterparse = ET.iterparse context = iterparse(SIMPLE_XMLFILE) +self.assertIsNone(context.root) action, elem = next(context) +self.assertIsNone(context.root) self.assertEqual((action, elem.tag), ('end', 'element')) self.assertEqual([(action, elem.tag) for action, elem in context], [ ('end', 'element'), diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index d4b259e31a7de7..fce0c2963a28d5 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -1271,8 +1271,8 @@ def __del__(self): source.close() it = IterParseIterator() +it.root = None wr = weakref.ref(it) -del IterParseIterator return it ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-114790: Do not execute `workflows/require-pr-label.yml` on forks (GH-114791) (#114800)
https://github.com/python/cpython/commit/3e06cce36ad4ff8f35e6a6c05ee1afb5ee1f8031 commit: 3e06cce36ad4ff8f35e6a6c05ee1afb5ee1f8031 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2024-01-31T12:27:12Z summary: [3.12] gh-114790: Do not execute `workflows/require-pr-label.yml` on forks (GH-114791) (#114800) Co-authored-by: Nikita Sobolev Co-authored-by: Hugo van Kemenade <[email protected]> files: M .github/workflows/require-pr-label.yml diff --git a/.github/workflows/require-pr-label.yml b/.github/workflows/require-pr-label.yml index 6efd31162ebab6..5b3fd76dc8bee2 100644 --- a/.github/workflows/require-pr-label.yml +++ b/.github/workflows/require-pr-label.yml @@ -11,6 +11,7 @@ permissions: jobs: label: name: DO-NOT-MERGE / unresolved review +if: github.repository_owner == 'python' runs-on: ubuntu-latest timeout-minutes: 10 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] gh-114790: Do not execute `workflows/require-pr-label.yml` on forks (GH-114791) (#114801)
https://github.com/python/cpython/commit/8e323cb68bae9681dcd38a6aa8c37bc0f50de05c commit: 8e323cb68bae9681dcd38a6aa8c37bc0f50de05c branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2024-01-31T12:32:50Z summary: [3.11] gh-114790: Do not execute `workflows/require-pr-label.yml` on forks (GH-114791) (#114801) Co-authored-by: Nikita Sobolev Co-authored-by: Hugo van Kemenade <[email protected]> files: M .github/workflows/require-pr-label.yml diff --git a/.github/workflows/require-pr-label.yml b/.github/workflows/require-pr-label.yml index 080204bcfd3b94..ff5cbdf3eda749 100644 --- a/.github/workflows/require-pr-label.yml +++ b/.github/workflows/require-pr-label.yml @@ -11,6 +11,7 @@ permissions: jobs: label: name: DO-NOT-MERGE / unresolved review +if: github.repository_owner == 'python' runs-on: ubuntu-latest timeout-minutes: 10 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-59013: Set breakpoint on the first executable line of function when using `break func` in pdb (#112470)
https://github.com/python/cpython/commit/765b9ce9fb357bdb79a50ce51207c827fbd13dd8 commit: 765b9ce9fb357bdb79a50ce51207c827fbd13dd8 branch: main author: Tian Gao committer: iritkatriel <[email protected]> date: 2024-01-31T13:03:05Z summary: gh-59013: Set breakpoint on the first executable line of function when using `break func` in pdb (#112470) files: A Misc/NEWS.d/next/Library/2023-11-27-19-54-43.gh-issue-59013.chpQ0e.rst M Lib/pdb.py M Lib/test/test_pdb.py diff --git a/Lib/pdb.py b/Lib/pdb.py index 6f7719eb9ba6c5..0754e8b628cf57 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -97,17 +97,47 @@ class Restart(Exception): __all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace", "post_mortem", "help"] + +def find_first_executable_line(code): +""" Try to find the first executable line of the code object. + +Equivalently, find the line number of the instruction that's +after RESUME + +Return code.co_firstlineno if no executable line is found. +""" +prev = None +for instr in dis.get_instructions(code): +if prev is not None and prev.opname == 'RESUME': +if instr.positions.lineno is not None: +return instr.positions.lineno +return code.co_firstlineno +prev = instr +return code.co_firstlineno + def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try: fp = tokenize.open(filename) except OSError: return None +funcdef = "" +funcstart = None # consumer of this info expects the first line to be 1 with fp: for lineno, line in enumerate(fp, start=1): if cre.match(line): -return funcname, filename, lineno +funcstart, funcdef = lineno, line +elif funcdef: +funcdef += line + +if funcdef: +try: +funccode = compile(funcdef, filename, 'exec').co_consts[0] +except SyntaxError: +continue +lineno_offset = find_first_executable_line(funccode) +return funcname, filename, funcstart + lineno_offset - 1 return None def lasti2lineno(code, lasti): @@ -975,7 +1005,7 @@ def do_break(self, arg, temporary = 0): #use co_name to identify the bkpt (function names #could be aliased, but co_name is invariant) funcname = code.co_name -lineno = self._find_first_executable_line(code) +lineno = find_first_executable_line(code) filename = code.co_filename except: # last thing to try @@ -1078,23 +1108,6 @@ def checkline(self, filename, lineno): return 0 return lineno -def _find_first_executable_line(self, code): -""" Try to find the first executable line of the code object. - -Equivalently, find the line number of the instruction that's -after RESUME - -Return code.co_firstlineno if no executable line is found. -""" -prev = None -for instr in dis.get_instructions(code): -if prev is not None and prev.opname == 'RESUME': -if instr.positions.lineno is not None: -return instr.positions.lineno -return code.co_firstlineno -prev = instr -return code.co_firstlineno - def do_enable(self, arg): """enable bpnumber [bpnumber ...] diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index c64df62c761471..b2283cff6cb462 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -2661,7 +2661,7 @@ def quux(): pass """.encode(), 'bœr', -('bœr', 4), +('bœr', 5), ) def test_find_function_found_with_encoding_cookie(self): @@ -2678,7 +2678,7 @@ def quux(): pass """.encode('iso-8859-15'), 'bœr', -('bœr', 5), +('bœr', 6), ) def test_find_function_found_with_bom(self): @@ -2688,9 +2688,34 @@ def bœr(): pass """.encode(), 'bœr', -('bœr', 1), +('bœr', 2), ) +def test_find_function_first_executable_line(self): +code = textwrap.dedent("""\ +def foo(): pass + +def bar(): +pass # line 4 + +def baz(): +# comment +pass # line 8 + +def mul(): +# code on multiple lines +code = compile( # line 12 +'def f()', +'', +'exec', +) +""").encode() + +self._assert_find_function(code, 'foo', ('foo', 1)) +self._assert_find_function(code, 'bar', ('bar', 4)) +self._assert_find_function(code
[Python-checkins] gh-111741: Recognise image/webp as a standard format in the mimetypes module (GH-111742)
https://github.com/python/cpython/commit/b905fad83819ec9102ecfb97e3d8ab0aaddd9784 commit: b905fad83819ec9102ecfb97e3d8ab0aaddd9784 branch: main author: Nachtalb <[email protected]> committer: serhiy-storchaka date: 2024-01-31T17:33:46+02:00 summary: gh-111741: Recognise image/webp as a standard format in the mimetypes module (GH-111742) Previously it was supported as a non-standard type. files: A Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst M Lib/mimetypes.py M Lib/test/test_mimetypes.py diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 37228de4828de5..51b99701c9d727 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -528,6 +528,7 @@ def _default_mime_types(): '.tiff' : 'image/tiff', '.tif': 'image/tiff', '.ico': 'image/vnd.microsoft.icon', +'.webp' : 'image/webp', '.ras': 'image/x-cmu-raster', '.pnm': 'image/x-portable-anymap', '.pbm': 'image/x-portable-bitmap', @@ -587,7 +588,6 @@ def _default_mime_types(): '.pict': 'image/pict', '.pct' : 'image/pict', '.pic' : 'image/pict', -'.webp': 'image/webp', '.xul' : 'text/xul', } diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index d64aee71fc48b1..01bba0ac2eed5a 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -96,14 +96,12 @@ def test_non_standard_types(self): # First try strict eq(self.db.guess_type('foo.xul', strict=True), (None, None)) eq(self.db.guess_extension('image/jpg', strict=True), None) -eq(self.db.guess_extension('image/webp', strict=True), None) # And then non-strict eq(self.db.guess_type('foo.xul', strict=False), ('text/xul', None)) eq(self.db.guess_type('foo.XUL', strict=False), ('text/xul', None)) eq(self.db.guess_type('foo.invalid', strict=False), (None, None)) eq(self.db.guess_extension('image/jpg', strict=False), '.jpg') eq(self.db.guess_extension('image/JPG', strict=False), '.jpg') -eq(self.db.guess_extension('image/webp', strict=False), '.webp') def test_filename_with_url_delimiters(self): # bpo-38449: URL delimiters cases should be handled also. @@ -183,6 +181,7 @@ def check_extensions(): self.assertEqual(mimetypes.guess_extension('application/xml'), '.xsl') self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3') self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif') +self.assertEqual(mimetypes.guess_extension('image/webp'), '.webp') self.assertEqual(mimetypes.guess_extension('image/jpeg'), '.jpg') self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff') self.assertEqual(mimetypes.guess_extension('message/rfc822'), '.eml') diff --git a/Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst b/Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst new file mode 100644 index 00..e43f93a270ce9c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-11-04-22-32-27.gh-issue-111741.f1ufr8.rst @@ -0,0 +1 @@ +Recognise ``image/webp`` as a standard format in the :mod:`mimetypes` module. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-113939: Frame clear, clear locals (#113940)
https://github.com/python/cpython/commit/78c254582b1757c15098ae65e97a2589ae663cd7 commit: 78c254582b1757c15098ae65e97a2589ae663cd7 branch: main author: Albert Zeyer committer: iritkatriel <[email protected]> date: 2024-01-31T19:14:44Z summary: gh-113939: Frame clear, clear locals (#113940) files: A Misc/NEWS.d/next/Core and Builtins/2024-01-12-16-40-07.gh-issue-113939.Yi3L-e.rst M Lib/test/test_frame.py M Objects/frameobject.c diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py index 7f17666a8d9697..244ce8af7cdf08 100644 --- a/Lib/test/test_frame.py +++ b/Lib/test/test_frame.py @@ -55,6 +55,28 @@ class C: # The reference was released by .clear() self.assertIs(None, wr()) +def test_clear_locals_after_f_locals_access(self): +# see gh-113939 +class C: +pass + +wr = None +def inner(): +nonlocal wr +c = C() +wr = weakref.ref(c) +1/0 + +try: +inner() +except ZeroDivisionError as exc: +support.gc_collect() +self.assertIsNotNone(wr()) +print(exc.__traceback__.tb_next.tb_frame.f_locals) +exc.__traceback__.tb_next.tb_frame.clear() +support.gc_collect() +self.assertIsNone(wr()) + def test_clear_does_not_clear_specials(self): class C: pass diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-01-12-16-40-07.gh-issue-113939.Yi3L-e.rst b/Misc/NEWS.d/next/Core and Builtins/2024-01-12-16-40-07.gh-issue-113939.Yi3L-e.rst new file mode 100644 index 00..28b8e4bdda6be4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-01-12-16-40-07.gh-issue-113939.Yi3L-e.rst @@ -0,0 +1,4 @@ +frame.clear(): +Clear frame.f_locals as well, and not only the fast locals. +This is relevant once frame.f_locals was accessed, +which would contain also references to all the locals. diff --git a/Objects/frameobject.c b/Objects/frameobject.c index cafe4ef6141d9a..a914c61aac2fd5 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -926,6 +926,7 @@ frame_tp_clear(PyFrameObject *f) Py_CLEAR(locals[i]); } f->f_frame->stacktop = 0; +Py_CLEAR(f->f_frame->f_locals); return 0; } ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114788: Do not run JIT workflow on unrelated changes (#114789)
https://github.com/python/cpython/commit/b25b7462d520f38049d25888f220f20f759bc077 commit: b25b7462d520f38049d25888f220f20f759bc077 branch: main author: Nikita Sobolev committer: hugovk <[email protected]> date: 2024-01-31T12:51:18-07:00 summary: gh-114788: Do not run JIT workflow on unrelated changes (#114789) Co-authored-by: Hugo van Kemenade <[email protected]> files: M .github/workflows/jit.yml diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml index 3da72919181255..22e0bdba53ffd6 100644 --- a/.github/workflows/jit.yml +++ b/.github/workflows/jit.yml @@ -1,10 +1,19 @@ name: JIT on: pull_request: -paths: '**jit**' +paths: + - '**jit**' + - 'Python/bytecodes.c' push: -paths: '**jit**' +paths: + - '**jit**' + - 'Python/bytecodes.c' workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: jit: name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (#114630)
https://github.com/python/cpython/commit/1836f674c0d86ec3375189a550c8f4a52ff89ae8 commit: 1836f674c0d86ec3375189a550c8f4a52ff89ae8 branch: main author: Bradley Reynolds committer: hauntsaninja <[email protected]> date: 2024-01-31T13:33:28-08:00 summary: Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (#114630) Co-authored-by: Ned Batchelder files: M Doc/library/sys.rst diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index abf2c393a44928..a97a369b77b88a 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1293,7 +1293,10 @@ always available. The list of the original command line arguments passed to the Python executable. - See also :data:`sys.argv`. + The elements of :data:`sys.orig_argv` are the arguments to the Python interpreter, + while the elements of :data:`sys.argv` are the arguments to the user's program. + Arguments consumed by the interpreter itself will be present in :data:`sys.orig_argv` + and missing from :data:`sys.argv`. .. versionadded:: 3.10 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (GH-114630) (#114821)
https://github.com/python/cpython/commit/c8e4c32105aff5c762ee3602426603212dcbcd40 commit: c8e4c32105aff5c762ee3602426603212dcbcd40 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2024-01-31T21:40:11Z summary: [3.12] Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (GH-114630) (#114821) Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (GH-114630) (cherry picked from commit 1836f674c0d86ec3375189a550c8f4a52ff89ae8) Co-authored-by: Bradley Reynolds Co-authored-by: Ned Batchelder files: M Doc/library/sys.rst diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 62783a417e7583..4bd769ea9ae59d 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1279,7 +1279,10 @@ always available. The list of the original command line arguments passed to the Python executable. - See also :data:`sys.argv`. + The elements of :data:`sys.orig_argv` are the arguments to the Python interpreter, + while the elements of :data:`sys.argv` are the arguments to the user's program. + Arguments consumed by the interpreter itself will be present in :data:`sys.orig_argv` + and missing from :data:`sys.argv`. .. versionadded:: 3.10 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (GH-114630) (#114822)
https://github.com/python/cpython/commit/e66ad91f68b68fc8cbdc4b6dacea80636164cdf5 commit: e66ad91f68b68fc8cbdc4b6dacea80636164cdf5 branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2024-01-31T21:40:20Z summary: [3.11] Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (GH-114630) (#114822) Add note to `sys.orig_argv` clarifying the difference from `sys.argv` (GH-114630) (cherry picked from commit 1836f674c0d86ec3375189a550c8f4a52ff89ae8) Co-authored-by: Bradley Reynolds Co-authored-by: Ned Batchelder files: M Doc/library/sys.rst diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 2a1e6fb1a9cf29..e402d8b418b7b0 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1240,7 +1240,10 @@ always available. The list of the original command line arguments passed to the Python executable. - See also :data:`sys.argv`. + The elements of :data:`sys.orig_argv` are the arguments to the Python interpreter, + while the elements of :data:`sys.argv` are the arguments to the user's program. + Arguments consumed by the interpreter itself will be present in :data:`sys.orig_argv` + and missing from :data:`sys.argv`. .. versionadded:: 3.10 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-112087: Make PyList_{Append,Size,GetSlice} to be thread-safe (gh-114651)
https://github.com/python/cpython/commit/7b9d406729e7e7adc482b5b8c920de1874c234d0
commit: 7b9d406729e7e7adc482b5b8c920de1874c234d0
branch: main
author: Donghee Na
committer: corona10
date: 2024-02-01T08:58:08+09:00
summary:
gh-112087: Make PyList_{Append,Size,GetSlice} to be thread-safe (gh-114651)
files:
M Include/internal/pycore_list.h
M Include/object.h
M Objects/listobject.c
diff --git a/Include/internal/pycore_list.h b/Include/internal/pycore_list.h
index 6c29d882335512..4536f90e414493 100644
--- a/Include/internal/pycore_list.h
+++ b/Include/internal/pycore_list.h
@@ -24,12 +24,13 @@ extern void _PyList_Fini(_PyFreeListState *);
extern int
_PyList_AppendTakeRefListResize(PyListObject *self, PyObject *newitem);
+// In free-threaded build: self should be locked by the caller, if it should
be thread-safe.
static inline int
_PyList_AppendTakeRef(PyListObject *self, PyObject *newitem)
{
assert(self != NULL && newitem != NULL);
assert(PyList_Check(self));
-Py_ssize_t len = PyList_GET_SIZE(self);
+Py_ssize_t len = Py_SIZE(self);
Py_ssize_t allocated = self->allocated;
assert((size_t)len + 1 < PY_SSIZE_T_MAX);
if (allocated > len) {
diff --git a/Include/object.h b/Include/object.h
index ef3fb721c2b012..568d315d7606c4 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -428,7 +428,11 @@ static inline void Py_SET_TYPE(PyObject *ob, PyTypeObject
*type) {
static inline void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) {
assert(ob->ob_base.ob_type != &PyLong_Type);
assert(ob->ob_base.ob_type != &PyBool_Type);
+#ifdef Py_GIL_DISABLED
+_Py_atomic_store_ssize_relaxed(&ob->ob_size, size);
+#else
ob->ob_size = size;
+#endif
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b
# define Py_SET_SIZE(ob, size) Py_SET_SIZE(_PyVarObject_CAST(ob), (size))
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 56785e5f37a450..80a1f1da55b8bc 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -30,7 +30,6 @@ get_list_state(void)
}
#endif
-
/* Ensure ob_item has room for at least newsize elements, and set
* ob_size to newsize. If newsize > ob_size on entry, the content
* of the new slots at exit is undefined heap trash; it's the caller's
@@ -221,8 +220,9 @@ PyList_Size(PyObject *op)
PyErr_BadInternalCall();
return -1;
}
-else
-return Py_SIZE(op);
+else {
+return PyList_GET_SIZE(op);
+}
}
static inline int
@@ -328,7 +328,7 @@ PyList_Insert(PyObject *op, Py_ssize_t where, PyObject
*newitem)
int
_PyList_AppendTakeRefListResize(PyListObject *self, PyObject *newitem)
{
-Py_ssize_t len = PyList_GET_SIZE(self);
+Py_ssize_t len = Py_SIZE(self);
assert(self->allocated == -1 || self->allocated == len);
if (list_resize(self, len + 1) < 0) {
Py_DECREF(newitem);
@@ -342,7 +342,11 @@ int
PyList_Append(PyObject *op, PyObject *newitem)
{
if (PyList_Check(op) && (newitem != NULL)) {
-return _PyList_AppendTakeRef((PyListObject *)op, Py_NewRef(newitem));
+int ret;
+Py_BEGIN_CRITICAL_SECTION(op);
+ret = _PyList_AppendTakeRef((PyListObject *)op, Py_NewRef(newitem));
+Py_END_CRITICAL_SECTION();
+return ret;
}
PyErr_BadInternalCall();
return -1;
@@ -473,7 +477,7 @@ static PyObject *
list_item(PyObject *aa, Py_ssize_t i)
{
PyListObject *a = (PyListObject *)aa;
-if (!valid_index(i, Py_SIZE(a))) {
+if (!valid_index(i, PyList_GET_SIZE(a))) {
PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
return NULL;
}
@@ -511,6 +515,8 @@ PyList_GetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t
ihigh)
PyErr_BadInternalCall();
return NULL;
}
+PyObject *ret;
+Py_BEGIN_CRITICAL_SECTION(a);
if (ilow < 0) {
ilow = 0;
}
@@ -523,7 +529,9 @@ PyList_GetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t
ihigh)
else if (ihigh > Py_SIZE(a)) {
ihigh = Py_SIZE(a);
}
-return list_slice((PyListObject *)a, ilow, ihigh);
+ret = list_slice((PyListObject *)a, ilow, ihigh);
+Py_END_CRITICAL_SECTION();
+return ret;
}
static PyObject *
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] gh-109534: fix reference leak when SSL handshake fails (#114074)
https://github.com/python/cpython/commit/80aa7b3688b8fdc85cd53d4113cb5f6ce5500027 commit: 80aa7b3688b8fdc85cd53d4113cb5f6ce5500027 branch: main author: Jamie Phan committer: hauntsaninja <[email protected]> date: 2024-01-31T16:42:17-08:00 summary: gh-109534: fix reference leak when SSL handshake fails (#114074) files: A Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst M Lib/asyncio/selector_events.py M Lib/asyncio/sslproto.py diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index dcd5e0aa345029..10fbdd76e93f79 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -235,6 +235,10 @@ async def _accept_connection2( await waiter except BaseException: transport.close() +# gh-109534: When an exception is raised by the SSLProtocol object the +# exception set in this future can keep the protocol object alive and +# cause a reference cycle. +waiter = None raise # It's now up to the protocol to handle the connection. diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 599e91ba0003d1..fa99d4533aa0a6 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -579,6 +579,7 @@ def _on_handshake_complete(self, handshake_exc): peercert = sslobj.getpeercert() except Exception as exc: +handshake_exc = None self._set_state(SSLProtocolState.UNWRAPPED) if isinstance(exc, ssl.CertificateError): msg = 'SSL handshake failed on verifying the certificate' diff --git a/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst b/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst new file mode 100644 index 00..fc9a765a230037 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst @@ -0,0 +1,3 @@ +Fix a reference leak in +:class:`asyncio.selector_events.BaseSelectorEventLoop` when SSL handshakes +fail. Patch contributed by Jamie Phan. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-111112: Avoid potential confusion in TCP server example. (#111113)
https://github.com/python/cpython/commit/a79a27242f75fc33416d4d135a4a542898d140e5 commit: a79a27242f75fc33416d4d135a4a542898d140e5 branch: main author: Aidan Holm committer: hauntsaninja <[email protected]> date: 2024-01-31T16:42:38-08:00 summary: gh-12: Avoid potential confusion in TCP server example. (#13) Improve misleading TCP server docs and example. socket.recv(), as documented by the Python reference documentation, returns at most `bufsize` bytes, and the underlying TCP protocol means there is no guaranteed correspondence between what is sent by the client and what is received by the server. This conflation could mislead readers into thinking that TCP is datagram-based or has similar semantics, which will likely appear to work for simple cases, but introduce difficult to reproduce bugs. files: M Doc/library/socketserver.rst diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst index 5fd213fa613c8d..864b1dadb78562 100644 --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -494,7 +494,7 @@ This is the server side:: def handle(self): # self.request is the TCP socket connected to the client self.data = self.request.recv(1024).strip() - print("{} wrote:".format(self.client_address[0])) + print("Received from {}:".format(self.client_address[0])) print(self.data) # just send back the same data, but upper-cased self.request.sendall(self.data.upper()) @@ -525,8 +525,9 @@ objects that simplify communication by providing the standard file interface):: The difference is that the ``readline()`` call in the second handler will call ``recv()`` multiple times until it encounters a newline character, while the -single ``recv()`` call in the first handler will just return what has been sent -from the client in one ``sendall()`` call. +single ``recv()`` call in the first handler will just return what has been +received so far from the client's ``sendall()`` call (typically all of it, but +this is not guaranteed by the TCP protocol). This is the client side:: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-111112: Avoid potential confusion in TCP server example. (GH-111113) (#114831)
https://github.com/python/cpython/commit/21b68a1198fbfada3d3c11576c0f9676a4cf5978 commit: 21b68a1198fbfada3d3c11576c0f9676a4cf5978 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2024-02-01T00:50:34Z summary: [3.12] gh-12: Avoid potential confusion in TCP server example. (GH-13) (#114831) gh-12: Avoid potential confusion in TCP server example. (GH-13) Improve misleading TCP server docs and example. socket.recv(), as documented by the Python reference documentation, returns at most `bufsize` bytes, and the underlying TCP protocol means there is no guaranteed correspondence between what is sent by the client and what is received by the server. This conflation could mislead readers into thinking that TCP is datagram-based or has similar semantics, which will likely appear to work for simple cases, but introduce difficult to reproduce bugs. (cherry picked from commit a79a27242f75fc33416d4d135a4a542898d140e5) Co-authored-by: Aidan Holm files: M Doc/library/socketserver.rst diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst index 5fd213fa613c8d..864b1dadb78562 100644 --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -494,7 +494,7 @@ This is the server side:: def handle(self): # self.request is the TCP socket connected to the client self.data = self.request.recv(1024).strip() - print("{} wrote:".format(self.client_address[0])) + print("Received from {}:".format(self.client_address[0])) print(self.data) # just send back the same data, but upper-cased self.request.sendall(self.data.upper()) @@ -525,8 +525,9 @@ objects that simplify communication by providing the standard file interface):: The difference is that the ``readline()`` call in the second handler will call ``recv()`` multiple times until it encounters a newline character, while the -single ``recv()`` call in the first handler will just return what has been sent -from the client in one ``sendall()`` call. +single ``recv()`` call in the first handler will just return what has been +received so far from the client's ``sendall()`` call (typically all of it, but +this is not guaranteed by the TCP protocol). This is the client side:: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] gh-111112: Avoid potential confusion in TCP server example. (GH-111113) (#114832)
https://github.com/python/cpython/commit/fe0f544f33adf6128400f103187ba9f3cee13549 commit: fe0f544f33adf6128400f103187ba9f3cee13549 branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2024-02-01T00:50:58Z summary: [3.11] gh-12: Avoid potential confusion in TCP server example. (GH-13) (#114832) gh-12: Avoid potential confusion in TCP server example. (GH-13) Improve misleading TCP server docs and example. socket.recv(), as documented by the Python reference documentation, returns at most `bufsize` bytes, and the underlying TCP protocol means there is no guaranteed correspondence between what is sent by the client and what is received by the server. This conflation could mislead readers into thinking that TCP is datagram-based or has similar semantics, which will likely appear to work for simple cases, but introduce difficult to reproduce bugs. (cherry picked from commit a79a27242f75fc33416d4d135a4a542898d140e5) Co-authored-by: Aidan Holm files: M Doc/library/socketserver.rst diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst index 7540375b8d1f50..5e92332c5f195c 100644 --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -488,7 +488,7 @@ This is the server side:: def handle(self): # self.request is the TCP socket connected to the client self.data = self.request.recv(1024).strip() - print("{} wrote:".format(self.client_address[0])) + print("Received from {}:".format(self.client_address[0])) print(self.data) # just send back the same data, but upper-cased self.request.sendall(self.data.upper()) @@ -519,8 +519,9 @@ objects that simplify communication by providing the standard file interface):: The difference is that the ``readline()`` call in the second handler will call ``recv()`` multiple times until it encounters a newline character, while the -single ``recv()`` call in the first handler will just return what has been sent -from the client in one ``sendall()`` call. +single ``recv()`` call in the first handler will just return what has been +received so far from the client's ``sendall()`` call (typically all of it, but +this is not guaranteed by the TCP protocol). This is the client side:: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] gh-109534: fix reference leak when SSL handshake fails (GH-114074) (#114830)
https://github.com/python/cpython/commit/ef2ba9a00757cc7bcf8f7b27afd0e9a634967f7c commit: ef2ba9a00757cc7bcf8f7b27afd0e9a634967f7c branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2024-02-01T00:59:17Z summary: [3.11] gh-109534: fix reference leak when SSL handshake fails (GH-114074) (#114830) gh-109534: fix reference leak when SSL handshake fails (GH-114074) (cherry picked from commit 80aa7b3688b8fdc85cd53d4113cb5f6ce5500027) Co-authored-by: Jamie Phan files: A Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst M Lib/asyncio/selector_events.py M Lib/asyncio/sslproto.py diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index 96e61f7c3a4e9f..40df1b7da5c785 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -222,6 +222,10 @@ async def _accept_connection2( await waiter except BaseException: transport.close() +# gh-109534: When an exception is raised by the SSLProtocol object the +# exception set in this future can keep the protocol object alive and +# cause a reference cycle. +waiter = None raise # It's now up to the protocol to handle the connection. diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 4d2cf8224ae4cf..e51669a2ab2af6 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -579,6 +579,7 @@ def _on_handshake_complete(self, handshake_exc): peercert = sslobj.getpeercert() except Exception as exc: +handshake_exc = None self._set_state(SSLProtocolState.UNWRAPPED) if isinstance(exc, ssl.CertificateError): msg = 'SSL handshake failed on verifying the certificate' diff --git a/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst b/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst new file mode 100644 index 00..fc9a765a230037 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst @@ -0,0 +1,3 @@ +Fix a reference leak in +:class:`asyncio.selector_events.BaseSelectorEventLoop` when SSL handshakes +fail. Patch contributed by Jamie Phan. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-109534: fix reference leak when SSL handshake fails (GH-114074) (#114829)
https://github.com/python/cpython/commit/0ee6fbaab6888dc0252c497b13a7ba73f5172931 commit: 0ee6fbaab6888dc0252c497b13a7ba73f5172931 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2024-02-01T01:00:09Z summary: [3.12] gh-109534: fix reference leak when SSL handshake fails (GH-114074) (#114829) gh-109534: fix reference leak when SSL handshake fails (GH-114074) (cherry picked from commit 80aa7b3688b8fdc85cd53d4113cb5f6ce5500027) Co-authored-by: Jamie Phan files: A Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst M Lib/asyncio/selector_events.py M Lib/asyncio/sslproto.py diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index f895750e3cf959..790711f834096b 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -235,6 +235,10 @@ async def _accept_connection2( await waiter except BaseException: transport.close() +# gh-109534: When an exception is raised by the SSLProtocol object the +# exception set in this future can keep the protocol object alive and +# cause a reference cycle. +waiter = None raise # It's now up to the protocol to handle the connection. diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 4d2cf8224ae4cf..e51669a2ab2af6 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -579,6 +579,7 @@ def _on_handshake_complete(self, handshake_exc): peercert = sslobj.getpeercert() except Exception as exc: +handshake_exc = None self._set_state(SSLProtocolState.UNWRAPPED) if isinstance(exc, ssl.CertificateError): msg = 'SSL handshake failed on verifying the certificate' diff --git a/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst b/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst new file mode 100644 index 00..fc9a765a230037 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-01-15-18-42-44.gh-issue-109534.wYaLMZ.rst @@ -0,0 +1,3 @@ +Fix a reference leak in +:class:`asyncio.selector_events.BaseSelectorEventLoop` when SSL handshakes +fail. Patch contributed by Jamie Phan. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] CI: Test on macOS M1 (#114766)
https://github.com/python/cpython/commit/854e2bc42340b22cdeea5d16ac8b1ef3762c6909 commit: 854e2bc42340b22cdeea5d16ac8b1ef3762c6909 branch: main author: Hugo van Kemenade <[email protected]> committer: gpshead date: 2024-01-31T17:35:48-08:00 summary: CI: Test on macOS M1 (#114766) Test on macOS M1 files: M .github/workflows/reusable-macos.yml diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index c24b6e963ddfd6..28e9dc52fd50ee 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -12,20 +12,27 @@ on: jobs: build_macos: name: 'build and test' -runs-on: macos-latest timeout-minutes: 60 env: HOMEBREW_NO_ANALYTICS: 1 HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 PYTHONSTRICTEXTENSIONBUILD: 1 +strategy: + fail-fast: false + matrix: +os: [ + "macos-14", # M1 + "macos-13", # Intel +] +runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Restore config.cache uses: actions/cache@v3 with: path: config.cache -key: ${{ github.job }}-${{ runner.os }}-${{ inputs.config_hash }} +key: ${{ github.job }}-${{ matrix.os }}-${{ inputs.config_hash }} - name: Install Homebrew dependencies run: brew install pkg-config [email protected] xz gdbm tcl-tk - name: Configure CPython ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114811: Change '\*' to '*' in warnings.rst (#114819)
https://github.com/python/cpython/commit/ff8939e5abaad7cd87f4d1f07ca7f6d176090f6c commit: ff8939e5abaad7cd87f4d1f07ca7f6d176090f6c branch: main author: Pradyot Ranjan <[email protected]> committer: terryjreedy date: 2024-01-31T20:48:39-05:00 summary: gh-114811: Change '\*' to '*' in warnings.rst (#114819) Regression in 3.12. files: M Doc/library/warnings.rst diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index a9c469707e8227..500398636e11ae 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -396,7 +396,7 @@ Available Functions --- -.. function:: warn(message, category=None, stacklevel=1, source=None, \*, skip_file_prefixes=None) +.. function:: warn(message, category=None, stacklevel=1, source=None, *, skip_file_prefixes=None) Issue a warning, or maybe ignore it or raise an exception. The *category* argument, if given, must be a :ref:`warning category class `; it ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-114811: Change '\*' to '*' in warnings.rst (GH-114819) (#114837)
https://github.com/python/cpython/commit/3017c27d359a65b60f2ad2523a383a8ecad22460 commit: 3017c27d359a65b60f2ad2523a383a8ecad22460 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: terryjreedy date: 2024-02-01T01:54:25Z summary: [3.12] gh-114811: Change '\*' to '*' in warnings.rst (GH-114819) (#114837) Regression in 3.12. (cherry picked from commit ff8939e5abaad7cd87f4d1f07ca7f6d176090f6c) Co-authored-by: Pradyot Ranjan <[email protected]> files: M Doc/library/warnings.rst diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index 884de08eab1b16..db3534dd632f1d 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -396,7 +396,7 @@ Available Functions --- -.. function:: warn(message, category=None, stacklevel=1, source=None, \*, skip_file_prefixes=None) +.. function:: warn(message, category=None, stacklevel=1, source=None, *, skip_file_prefixes=None) Issue a warning, or maybe ignore it or raise an exception. The *category* argument, if given, must be a :ref:`warning category class `; it ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] CI: Test on macOS M1 (GH-114766) (#114835)
https://github.com/python/cpython/commit/cba5cee0355e3c292791a4714adcf463b3371825 commit: cba5cee0355e3c292791a4714adcf463b3371825 branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: gpshead date: 2024-02-01T01:55:45Z summary: [3.11] CI: Test on macOS M1 (GH-114766) (#114835) Test on macOS M1 (cherry picked from commit 854e2bc42340b22cdeea5d16ac8b1ef3762c6909) Co-authored-by: Hugo van Kemenade <[email protected]> files: M .github/workflows/reusable-macos.yml diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index db42cedd6f9294..ac8fdb8677e2fa 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -12,20 +12,27 @@ on: jobs: build_macos: name: 'build and test' -runs-on: macos-latest timeout-minutes: 60 env: HOMEBREW_NO_ANALYTICS: 1 HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 PYTHONSTRICTEXTENSIONBUILD: 1 +strategy: + fail-fast: false + matrix: +os: [ + "macos-14", # M1 + "macos-13", # Intel +] +runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Restore config.cache uses: actions/cache@v3 with: path: config.cache -key: ${{ github.job }}-${{ runner.os }}-${{ inputs.config_hash }} +key: ${{ github.job }}-${{ matrix.os }}-${{ inputs.config_hash }} - name: Install Homebrew dependencies run: brew install pkg-config [email protected] xz gdbm tcl-tk - name: Configure CPython ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] CI: Test on macOS M1 (GH-114766) (#114836)
https://github.com/python/cpython/commit/203106def212f32d4c4c56b6ea7760811c9ca355 commit: 203106def212f32d4c4c56b6ea7760811c9ca355 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: gpshead date: 2024-02-01T01:57:08Z summary: [3.12] CI: Test on macOS M1 (GH-114766) (#114836) Test on macOS M1 (cherry picked from commit 854e2bc42340b22cdeea5d16ac8b1ef3762c6909) Co-authored-by: Hugo van Kemenade <[email protected]> files: M .github/workflows/reusable-macos.yml diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index db42cedd6f9294..ac8fdb8677e2fa 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -12,20 +12,27 @@ on: jobs: build_macos: name: 'build and test' -runs-on: macos-latest timeout-minutes: 60 env: HOMEBREW_NO_ANALYTICS: 1 HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 PYTHONSTRICTEXTENSIONBUILD: 1 +strategy: + fail-fast: false + matrix: +os: [ + "macos-14", # M1 + "macos-13", # Intel +] +runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Restore config.cache uses: actions/cache@v3 with: path: config.cache -key: ${{ github.job }}-${{ runner.os }}-${{ inputs.config_hash }} +key: ${{ github.job }}-${{ matrix.os }}-${{ inputs.config_hash }} - name: Install Homebrew dependencies run: brew install pkg-config [email protected] xz gdbm tcl-tk - name: Configure CPython ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-67230: Add versionadded notes for QUOTE_NOTNULL and QUOTE_STRINGS (#114816)
https://github.com/python/cpython/commit/586057e9f80d57f16334c0eee8431931e4aa8cff commit: 586057e9f80d57f16334c0eee8431931e4aa8cff branch: main author: Skip Montanaro committer: terryjreedy date: 2024-01-31T22:11:16-05:00 summary: gh-67230: Add versionadded notes for QUOTE_NOTNULL and QUOTE_STRINGS (#114816) As @GPHemsley pointed out, #29469 omitted `versionadded` notes for the 2 new items. files: M Doc/library/csv.rst diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 66888c22b7cc28..fd62b225fcebb8 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -351,6 +351,8 @@ The :mod:`csv` module defines the following constants: Instructs :class:`reader` objects to interpret an empty (unquoted) field as None and to otherwise behave as :data:`QUOTE_ALL`. + .. versionadded:: 3.12 + .. data:: QUOTE_STRINGS Instructs :class:`writer` objects to always place quotes around fields @@ -360,6 +362,8 @@ The :mod:`csv` module defines the following constants: Instructs :class:`reader` objects to interpret an empty (unquoted) string as ``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`. + .. versionadded:: 3.12 + The :mod:`csv` module defines the following exception: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-67230: Add versionadded notes for QUOTE_NOTNULL and QUOTE_STRINGS (GH-114816) (#114840)
https://github.com/python/cpython/commit/c26decab6f96920bfa3a149d93dd50670fdb5a36 commit: c26decab6f96920bfa3a149d93dd50670fdb5a36 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: terryjreedy date: 2024-02-01T03:17:56Z summary: [3.12] gh-67230: Add versionadded notes for QUOTE_NOTNULL and QUOTE_STRINGS (GH-114816) (#114840) As @GPHemsley pointed out, GH-29469 omitted `versionadded` notes for the 2 new items. (cherry picked from commit 586057e9f80d57f16334c0eee8431931e4aa8cff) Co-authored-by: Skip Montanaro files: M Doc/library/csv.rst diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 66888c22b7cc28..fd62b225fcebb8 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -351,6 +351,8 @@ The :mod:`csv` module defines the following constants: Instructs :class:`reader` objects to interpret an empty (unquoted) field as None and to otherwise behave as :data:`QUOTE_ALL`. + .. versionadded:: 3.12 + .. data:: QUOTE_STRINGS Instructs :class:`writer` objects to always place quotes around fields @@ -360,6 +362,8 @@ The :mod:`csv` module defines the following constants: Instructs :class:`reader` objects to interpret an empty (unquoted) string as ``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`. + .. versionadded:: 3.12 + The :mod:`csv` module defines the following exception: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114648: Add IndexError exception to tutorial datastructures list.pop entry (#114681)
https://github.com/python/cpython/commit/57c3e775df5a5ca0982adf15010ed80a158b1b80 commit: 57c3e775df5a5ca0982adf15010ed80a158b1b80 branch: main author: srinivasan committer: terryjreedy date: 2024-01-31T22:46:49-05:00 summary: gh-114648: Add IndexError exception to tutorial datastructures list.pop entry (#114681) Remove redundant explanation of optional argument. files: M Doc/tutorial/datastructures.rst diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 87614d082a1d4e..de2827461e2f24 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -48,10 +48,9 @@ objects: :noindex: Remove the item at the given position in the list, and return it. If no index - is specified, ``a.pop()`` removes and returns the last item in the list. (The - square brackets around the *i* in the method signature denote that the parameter - is optional, not that you should type square brackets at that position. You - will see this notation frequently in the Python Library Reference.) + is specified, ``a.pop()`` removes and returns the last item in the list. + It raises an :exc:`IndexError` if the list is empty or the index is + outside the list range. .. method:: list.clear() ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] gh-114648: Add IndexError exception to tutorial datastructures list.pop entry (GH-114681) (#114841)
https://github.com/python/cpython/commit/09b8b14e05557304ab12870137181685c2dcbe25 commit: 09b8b14e05557304ab12870137181685c2dcbe25 branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: terryjreedy date: 2024-02-01T03:52:58Z summary: [3.12] gh-114648: Add IndexError exception to tutorial datastructures list.pop entry (GH-114681) (#114841) Remove redundant explanation of optional argument. (cherry picked from commit 57c3e775df5a5ca0982adf15010ed80a158b1b80) Co-authored-by: srinivasan files: M Doc/tutorial/datastructures.rst diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 87614d082a1d4e..de2827461e2f24 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -48,10 +48,9 @@ objects: :noindex: Remove the item at the given position in the list, and return it. If no index - is specified, ``a.pop()`` removes and returns the last item in the list. (The - square brackets around the *i* in the method signature denote that the parameter - is optional, not that you should type square brackets at that position. You - will see this notation frequently in the Python Library Reference.) + is specified, ``a.pop()`` removes and returns the last item in the list. + It raises an :exc:`IndexError` if the list is empty or the index is + outside the list range. .. method:: list.clear() ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.11] gh-114648: Add IndexError exception to tutorial datastructures list.pop entry (GH-114681) (#114842)
https://github.com/python/cpython/commit/a9c2801d49de545f6a5bfee46969dc9e20261461 commit: a9c2801d49de545f6a5bfee46969dc9e20261461 branch: 3.11 author: Miss Islington (bot) <[email protected]> committer: terryjreedy date: 2024-02-01T03:53:15Z summary: [3.11] gh-114648: Add IndexError exception to tutorial datastructures list.pop entry (GH-114681) (#114842) Remove redundant explanation of optional argument. (cherry picked from commit 57c3e775df5a5ca0982adf15010ed80a158b1b80) Co-authored-by: srinivasan files: M Doc/tutorial/datastructures.rst diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 87614d082a1d4e..de2827461e2f24 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -48,10 +48,9 @@ objects: :noindex: Remove the item at the given position in the list, and return it. If no index - is specified, ``a.pop()`` removes and returns the last item in the list. (The - square brackets around the *i* in the method signature denote that the parameter - is optional, not that you should type square brackets at that position. You - will see this notation frequently in the Python Library Reference.) + is specified, ``a.pop()`` removes and returns the last item in the list. + It raises an :exc:`IndexError` if the list is empty or the index is + outside the list range. .. method:: list.clear() ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-114364: Fix awkward wording about mmap.mmap.seekable (#114374)
https://github.com/python/cpython/commit/5ce193e65a7e6f239337a8c5305895cf8a4d2726 commit: 5ce193e65a7e6f239337a8c5305895cf8a4d2726 branch: main author: technillogue committer: terryjreedy date: 2024-02-01T06:03:58Z summary: gh-114364: Fix awkward wording about mmap.mmap.seekable (#114374) - Co-authored-by: Kirill Podoprigora Co-authored-by: Terry Jan Reedy Co-authored-by: Erlend E. Aasland files: M Doc/whatsnew/3.13.rst M Misc/NEWS.d/3.13.0a2.rst diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index b33203efbb05c0..6b94a3771406fa 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -259,8 +259,8 @@ mmap * The :class:`mmap.mmap` class now has an :meth:`~mmap.mmap.seekable` method - that can be used where it requires a file-like object with seekable and - the :meth:`~mmap.mmap.seek` method return the new absolute position. + that can be used when a seekable file-like object is required. + The :meth:`~mmap.mmap.seek` method now returns the new absolute position. (Contributed by Donghee Na and Sylvie Liberman in :gh:`111835`.) * :class:`mmap.mmap` now has a *trackfd* parameter on Unix; if it is ``False``, the file descriptor specified by *fileno* will not be duplicated. diff --git a/Misc/NEWS.d/3.13.0a2.rst b/Misc/NEWS.d/3.13.0a2.rst index d4be4fb8a3d3ab..e5841e14c02efb 100644 --- a/Misc/NEWS.d/3.13.0a2.rst +++ b/Misc/NEWS.d/3.13.0a2.rst @@ -565,9 +565,9 @@ part of a :exc:`BaseExceptionGroup`, in addition to the recent support for .. section: Library The :class:`mmap.mmap` class now has an :meth:`~mmap.mmap.seekable` method -that can be used where it requires a file-like object with seekable and the -:meth:`~mmap.mmap.seek` method return the new absolute position. Patch by -Donghee Na. +that can be used when a seekable file-like object is required. +The :meth:`~mmap.mmap.seek` method now returns the new absolute position. +Patch by Donghee Na. .. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
