summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40777: Initialize PyDateTime_IsoCalendarDateType.tp_base at run-time ↵Petr Viktorin2020-05-281-3/+10
| | | | | | | (GH-20493) Recent changes to _datetimemodule broke compilation on mingw; see the comments in this change for details. FWIW, @corona10: this issue is why `PyType_FromModuleAndSpec` & friends take the `bases` argument at run time.
* bpo-25920: Remove socket.getaddrinfo() lock on macOS (GH-20177)Victor Stinner2020-05-281-47/+2
| | | | | | | | | On macOS, socket.getaddrinfo() no longer uses an internal lock to prevent race conditions when calling getaddrinfo(). getaddrinfo is thread-safe is macOS 10.5, whereas Python 3.9 requires macOS 10.6 or newer. The lock was also used on FreeBSD older than 5.3, OpenBSD older than 201311 and NetBSD older than 4.
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-2824-112/+86
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-40795: ctypes calls unraisablehook with an exception (GH-20452)Victor Stinner2020-05-272-14/+31
| | | | | | If ctypes fails to convert the result of a callback or if a ctypes callback function raises an exception, sys.unraisablehook is now called with an exception set. Previously, the error was logged into stderr by PyErr_Print().
* bpo-37129: Add os.RWF_APPEND flag for os.pwritev() (GH-20336)YoSTEALTH2020-05-272-2/+7
|
* Fix compiler warnings in _zoneinfo.c (GH-20342)Pablo Galindo2020-05-271-30/+26
| | | | | | | ``` D:\a\cpython\cpython\Modules\_zoneinfo.c(903,52): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data [D:\a\cpython\cpython\PCbuild\_zoneinfo.vcxproj] D:\a\cpython\cpython\Modules\_zoneinfo.c(904,44): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data [D:\a\cpython\cpython\PCbuild\_zoneinfo.vcxproj] D:\a\cpython\cpython\Modules\_zoneinfo.c(1772,31): warning C4244: '=': conversion from 'ssize_t' to 'uint8_t', possible loss of data [D:\a\cpython\cpython\PCbuild\_zoneinfo.vcxproj] ```
* bpo-40791: Use CRYPTO_memcmp() for compare_digest (#20456)Christian Heimes2020-05-273-1/+159
| | | | | | | | hashlib.compare_digest uses OpenSSL's CRYPTO_memcmp() function when OpenSSL is available. Note: The _operator module is a builtin module. I don't want to add libcrypto dependency to libpython. Therefore I duplicated the wrapper function and added a copy to _hashopenssl.c.
* bpo-13097: ctypes: limit callback to 1024 arguments (GH-19914)Sean Gillespie2020-05-271-0/+15
| | | | | | | | | | ctypes now raises an ArgumentError when a callback is invoked with more than 1024 arguments. The ctypes module allocates arguments on the stack in ctypes_callproc() using alloca(), which is problematic when large numbers of arguments are passed. Instead of a stack overflow, this commit raises an ArgumentError if more than 1024 parameters are passed.
* bpo-39573: Convert Py_REFCNT and Py_SIZE to functions (GH-20429)Victor Stinner2020-05-271-2/+2
| | | | | | | | | | | Convert Py_REFCNT() and Py_SIZE() macros to static inline functions. They cannot be used as l-value anymore: use Py_SET_REFCNT() and Py_SET_SIZE() to set an object reference count and size. Replace &Py_SIZE(self) with &((PyVarObject*)self)->ob_size in arraymodule.c. This change is backward incompatible on purpose, to prepare the C API for an opaque PyObject structure.
* bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for ↵Pablo Galindo2020-05-275-0/+6
| | | | | | | | | PyType_FromSpec types (reverts GH-19414) (GH-20264) Heap types now always visit the type in tp_traverse. See added docs for details. This reverts commit 0169d3003be3d072751dd14a5c84748ab63a249f. Automerge-Triggered-By: @encukou
* bpo-40611: Adds MAP_POPULATE to the mmap module (GH-20061)Ethan Steinberg2020-05-261-0/+3
| | | | MAP_POPULATE constant has now been added to the list of exported mmap module flags.
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-2653-2097/+94
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-40737: Fix possible reference leak for sqlite3 initialization (GH-20323)Erlend Egeberg Aasland2020-05-261-8/+12
|
* bpo-40688: Use the correct parser in the peg_generator scripts (GH-20235)Lysandros Nikolaou2020-05-251-52/+81
| | | | | | | The scripts in `Tools/peg_generator/scripts` mostly assume that `ast.parse` and `compile` use the old parser, since this was the state of things, while we were developing them. They need to be updated to always use the correct parser. `_peg_parser` is being extended to support both parsing and compiling with both parsers.
* bpo-40671: Prepare _hashlib for PEP 489 (GH-20180)Christian Heimes2020-05-251-67/+114
|
* bpo-35714: Reject null characters in struct format strings (GH-16928)Zackery Spytz2020-05-251-0/+5
| | | | struct.error is now raised if there is a null character in a struct format string.
* bpo-38580: Document that select() accepts iterables, not just sequences ↵Jakub Stasiak2020-05-252-5/+5
| | | | (GH-16832)
* bpo-40696: Fix a hang that can arise after gen.throw() (GH-20287)Chris Jerdonek2020-05-221-6/+6
| | | | | | | | This updates _PyErr_ChainStackItem() to use _PyErr_SetObject() instead of _PyErr_ChainExceptions(). This prevents a hang in certain circumstances because _PyErr_SetObject() performs checks to prevent cycles in the exception context chain while _PyErr_ChainExceptions() doesn't.
* bpo-40705: Fix use-after-free in _zoneinfo's module_free (GH-20280)Ammar Askar2020-05-221-6/+9
|
* Let the argument clinic do the type checking for heapq (GH-20284)Raymond Hettinger2020-05-222-46/+117
|
* bpo-40630: Add tracemalloc.reset_peak (GH-20102)Huon Wilson2020-05-222-1/+46
| | | | | | | The reset_peak function sets the peak memory size to the current size, representing a resetting of that metric. This allows for recording the peak of specific sections of code, ignoring other code that may have had a higher peak (since the most recent `tracemalloc.start()` or tracemalloc.clear_traces()` call).
* bpo-40714: Remove compile warning from _zoneinfo.c (GH-20291)Dong-hee Na2020-05-211-2/+4
|
* bpo-40645: restrict HMAC key len to INT_MAX (GH-20238)Christian Heimes2020-05-191-1/+7
| | | | | Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: @tiran
* bpo-37616: Handle version information more gracefully in getpath.c (GH-20214)Pablo Galindo2020-05-191-9/+3
|
* bpo-40677: Define IO_REPARSE_TAG_APPEXECLINK explicitly (GH-20206)Minmin Gong2020-05-191-0/+4
| | | This allows building with older versions of the Windows SDK where the value is not defined.
* Python 3.10.0a0 (GH-20198)Pablo Galindo2020-05-191-5/+6
|
* bpo-40653: Move _dirnameW out of #ifdef HAVE_SYMLINK/#endif (GH-20144)Minmin Gong2020-05-181-2/+6
|
* bpo-39148: enable ipv6 for datagrams in Proactor (GH-19121)Kjell Braden2020-05-181-5/+2
| | | | | | Ifdef is not necessary, as AF_INET6 is supported from Windows Vista, and other code in overlapped.c uses AF_INET6 and is not ifdef'd. Change the raised exception so users are not fooled to think it comes from Windows API. Automerge-Triggered-By: @njsmith
* bpo-31033: Improve the traceback for cancelled asyncio tasks (GH-19951)Chris Jerdonek2020-05-182-22/+106
| | | | | When an asyncio.Task is cancelled, the exception traceback now starts with where the task was first interrupted. Previously, the traceback only had "depth one."
* bpo-40665: Use Argument Clinic for the bisect module (GH-20163)Shantanu2020-05-182-131/+411
|
* bpo-37630: Fix spelling shake128 -> shake_128 (GH-20154)Christian Heimes2020-05-172-39/+39
|
* bpo-40645: Implement HMAC in C (GH-20129)Christian Heimes2020-05-172-17/+568
| | | | | | | | | The internal module ``_hashlib`` wraps and exposes OpenSSL's HMAC API. The new code will be used in Python 3.10 after the internal implementation details of the pure Python HMAC module are no longer part of the public API. The code is based on a patch by Petr Viktorin for RHEL and Python 3.6. Co-Authored-By: Petr Viktorin <encukou@gmail.com>
* bpo-39740: Early declare devpoll_methods to support old compilers (GH-19281)Batuhan Taskaya2020-05-161-0/+2
|
* bpo-37630: Use SHA3 and SHAKE XOF from OpenSSL (GH-16049)Christian Heimes2020-05-162-18/+822
| | | | | | | OpenSSL 1.1.1 comes with SHA3 and SHAKE builtin. Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: @tiran
* bpo-24416: Return named tuple from date.isocalendar() (GH-20113)Paul Ganssle2020-05-162-5/+203
| | | | | | | | | | | | | | | | | | | | | | | {date, datetime}.isocalendar() now return a private custom named tuple object IsoCalendarDate rather than a simple tuple. In order to leave IsocalendarDate as a private class and to improve what backwards compatibility is offered for pickling the result of a datetime.isocalendar() call, add a __reduce__ method to the named tuples that reduces them to plain tuples. (This is the part of this PR most likely to cause problems — if it causes major issues, switching to a strucseq or equivalent would be prudent). The pure python implementation of IsoCalendarDate uses positional-only arguments, since it is private and only constructed by position anyway; the equivalent change in the argument clinic on the C side would require us to move the forward declaration of the type above the clinic import for whatever reason, so it seems preferable to hold off on that for now. bpo-24416: https://bugs.python.org/issue24416 Original PR by Dong-hee Na with only minor alterations by Paul Ganssle. Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
* bpo-40192: Use thread_cputime for time.thread_time to improve resolution ↵Batuhan Taskaya2020-05-161-0/+28
| | | | | | | (GH-19381) On AIX, time.thread_time() is now implemented with thread_cputime() which has nanosecond resolution, rather than clock_gettime(CLOCK_THREAD_CPUTIME_ID) which has a resolution of 10 ms.
* bpo-40503: PEP 615: Tests and implementation for zoneinfo (GH-19909)Paul Ganssle2020-05-162-0/+2696
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the initial implementation of PEP 615, the zoneinfo module, ported from the standalone reference implementation (see https://www.python.org/dev/peps/pep-0615/#reference-implementation for a link, which has a more detailed commit history). This includes (hopefully) all functional elements described in the PEP, but documentation is found in a separate PR. This includes: 1. A pure python implementation of the ZoneInfo class 2. A C accelerated implementation of the ZoneInfo class 3. Tests with 100% branch coverage for the Python code (though C code coverage is less than 100%). 4. A compile-time configuration option on Linux (though not on Windows) Differences from the reference implementation: - The module is arranged slightly differently: the accelerated module is `_zoneinfo` rather than `zoneinfo._czoneinfo`, which also necessitates some changes in the test support function. (Suggested by Victor Stinner and Steve Dower.) - The tests are arranged slightly differently and do not include the property tests. The tests live at test/test_zoneinfo/test_zoneinfo.py rather than test/test_zoneinfo.py or test/test_zoneinfo/__init__.py because we may do some refactoring in the future that would likely require this separation anyway; we may: - include the property tests - automatically run all the tests against both pure Python and C, rather than manually constructing C and Python test classes (similar to the way this works with test_datetime.py, which generates C and Python test cases from datetimetester.py). - This includes a compile-time configuration option on Linux (though not on Windows); added with much help from Thomas Wouters. - Integration into the CPython build system is obviously different from building a standalone zoneinfo module wheel. - This includes configuration to install the tzdata package as part of CI, though only on the coverage jobs. Introducing a PyPI dependency as part of the CI build was controversial, and this is seen as less of a major change, since the coverage jobs already depend on pip and PyPI. Additional changes that were introduced as part of this PR, most / all of which were backported to the reference implementation: - Fixed reference and memory leaks With much debugging help from Pablo Galindo - Added smoke tests ensuring that the C and Python modules are built The import machinery can be somewhat fragile, and the "seamlessly falls back to pure Python" nature of this module makes it so that a problem building the C extension or a failure to import the pure Python version might easily go unnoticed. - Adjustments to zoneinfo.__dir__ Suggested by Petr Viktorin. - Slight refactorings as suggested by Steve Dower. - Removed unnecessary if check on std_abbr Discovered this because of a missing line in branch coverage.
* bpo-40457: Support OpenSSL without TLS 1.0/1.1 (GH-19862)Christian Heimes2020-05-161-34/+27
| | | | | | | | | | | OpenSSL can be build without support for TLS 1.0 and 1.1. The ssl module now correctly adheres to OPENSSL_NO_TLS1 and OPENSSL_NO_TLS1_1 flags. Also update multissltest to test with latest OpenSSL and LibreSSL releases. Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: @tiran
* bpo-31033: Add a msg argument to Future.cancel() and Task.cancel() (GH-19979)Chris Jerdonek2020-05-152-27/+148
|
* bpo-40515: Require OPENSSL_THREADS (GH-19953)Christian Heimes2020-05-152-1/+9
| | | | | | | The ``ssl`` and ``hashlib`` modules now actively check that OpenSSL is build with thread support. Python 3.7.0 made thread support mandatory and no longer works safely with a no-thread builds. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-40479: Fix hashlib issue with OpenSSL 3.0.0 (GH-20107)Christian Heimes2020-05-152-8/+17
| | | | | | | | | | OpenSSL 3.0.0-alpha2 was released today. The FIPS_mode() function has been deprecated and removed. It no longer makes sense with the new provider and context system in OpenSSL 3.0.0. EVP_default_properties_is_fips_enabled() is good enough for our needs in unit tests. It's an internal API, too. Signed-off-by: Christian Heimes <christian@python.org>
* Trivial typo fix in _tkinter.c (GH-19622)Andrew York2020-05-151-7/+7
| | | Change spelling of a #define in _tkinter.c from HAVE_LIBTOMMAMTH to HAVE_LIBTOMMATH, since this is used to keep track of tclTomMath.h, not tclTomMamth.h. No other file seems to refer to this variable.
* bpo-40602: _Py_hashtable_set() reports rehash failure (GH-20077)Victor Stinner2020-05-141-5/+9
| | | | If _Py_hashtable_set() fails to grow the hash table (rehash), it now fails rather than ignoring the error.
* bpo-40602: Write unit tests for _Py_hashtable_t (GH-20091)Victor Stinner2020-05-141-0/+88
| | | | | | | Cleanup also hashtable.c. Rename _Py_hashtable_t members: * Rename entries to nentries * Rename num_buckets to nbuckets
* Revert "bpo-32604: [_xxsubinterpreters] Propagate exceptions. (GH-19768)" ↵Victor Stinner2020-05-141-1026/+121
| | | | | | | | | | | (GH-20089) * Revert "bpo-40613: Remove compiler warning from _xxsubinterpretersmodule (GH-20069)" This reverts commit fa0a66e62d087765dbc5c1b89d6149a23ecfb0a6. * Revert "bpo-32604: [_xxsubinterpreters] Propagate exceptions. (GH-19768)" This reverts commit a1d9e0accd33af1d8e90fc48b34c13d7b07dcf57.
* bpo-40549: posixmodule.c uses defining_class (GH-20075)Victor Stinner2020-05-142-137/+132
| | | | | | | | | Pass PEP 573 defining_class to os.DirEntry methods. The module state is now retrieve from defining_class rather than Py_TYPE(self), to support subclasses (even if DirEntry doesn't support subclasses yet). * Pass the module rather than defining_class to DirEntry_fetch_stat(). * Only get the module state once in _posix_clear(), _posix_traverse() and _posixmodule_exec().
* bpo-40521: Add PyInterpreterState.unicode (GH-20081)Victor Stinner2020-05-131-1/+1
| | | | | | | Move PyInterpreterState.fs_codec into a new PyInterpreterState.unicode structure. Give a name to the fs_codec structure and use this structure in unicodeobject.c.
* bpo-40613: Remove compiler warning from _xxsubinterpretersmodule (GH-20069)Dong-hee Na2020-05-131-0/+8
|
* bpo-40609: _Py_hashtable_t values become void* (GH-20065)Victor Stinner2020-05-131-137/+78
| | | | | | | | | | | | | | | | | | | | | _Py_hashtable_t values become regular "void *" pointers. * Add _Py_hashtable_entry_t.data member * Remove _Py_hashtable_t.data_size member * Remove _Py_hashtable_t.get_func member. It is no longer needed to specialize _Py_hashtable_get() for a specific value size, since all entries now have the same size (void*). * Remove the following macros: * _Py_HASHTABLE_GET() * _Py_HASHTABLE_SET() * _Py_HASHTABLE_SET_NODATA() * _Py_HASHTABLE_POP() * Rename _Py_hashtable_pop() to _Py_hashtable_steal() * _Py_hashtable_foreach() callback now gets key and value rather than entry. * Remove _Py_hashtable_value_destroy_func type. value_destroy_func callback now only has a single parameter: data (void*).
* bpo-40609: _tracemalloc allocates traces (GH-20064)Victor Stinner2020-05-131-43/+117
| | | | | | | | | | | | | Rewrite _tracemalloc to store "trace_t*" rather than directly "trace_t" in traces hash tables. Traces are now allocated on the heap memory, outside the hash table. Add tracemalloc_copy_traces() and tracemalloc_copy_domains() helper functions. Remove _Py_hashtable_copy() function since there is no API to copy a key or a value. Remove also _Py_hashtable_delete() function which was commented.