summaryrefslogtreecommitdiffstats
path: root/Modules/_zoneinfo.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-87526: Remove dead initialization from _zoneinfo parse_abbr() (#24700)Alex Henrie2023-05-121-1/+1
|
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-1/+4
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-241-3/+2
| | | | (in Modules/) (#102196)
* gh-101476: Use _PyType_GetModuleState where applicable (#102188)Erlend E. Aasland2023-02-241-1/+1
|
* gh-99138: Isolate _zoneinfo (#99218)Erlend E. Aasland2023-02-151-184/+335
| | | | * Convert zone info type to heap type and add it to module state * Add global variables to module state
* gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)Victor Stinner2022-11-231-2/+1
| | | Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
* gh-99537: Use Py_CLEAR() function in C code (#99686)Victor Stinner2022-11-221-10/+4
| | | | | | | Replace "Py_XDECREF(var); var = NULL;" with "Py_CLEAR(var);". Don't replace "Py_DECREF(var); var = NULL;" with "Py_CLEAR(var);". It would add an useless "if (var)" test in code path where var cannot be NULL.
* gh-99537: Use Py_SETREF() function in C code (#99656)Victor Stinner2022-11-221-2/+1
| | | | | | | | | | | | | | | Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
* gh-99300: Use Py_NewRef() in Modules/_datetimemodule.c (#99465)Victor Stinner2022-11-141-31/+15
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in Modules/_datetimemodule.c and Modules/_zoneinfo.c
* gh-83004: Clean up refleak in _zoneinfo initialisation (#98842)Shantanu2022-11-061-2/+3
|
* gh-97955: Migrate `zoneinfo` to Argument Clinic (#97958)Nikita Sobolev2022-10-071-36/+48
|
* gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)Serhiy Storchaka2022-06-141-27/+8
| | | | | | It combines PyImport_ImportModule() and PyObject_GetAttrString() and saves 4-6 lines of code on every use. Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
* bpo-46383: Fix signature of zoneinfo module_free function (GH-30607)Christian Heimes2022-01-151-1/+1
|
* bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157)Christian Heimes2021-10-221-0/+4
| | | | | | | | | | | | | | setup.py no longer defines Py_BUILD_CORE_MODULE. Instead every module defines the macro before #include "Python.h" unless Py_BUILD_CORE_BUILTIN is already defined. Py_BUILD_CORE_BUILTIN is defined for every module that is built by Modules/Setup. The PR also simplifies Modules/Setup. Makefile and makesetup already define Py_BUILD_CORE_BUILTIN and include Modules/internal for us. Signed-off-by: Christian Heimes <christian@python.org>
* Fix typos in the Modules directory (GH-28761)Christian Clauss2021-10-071-1/+1
|
* Add more const modifiers. (GH-26691)Serhiy Storchaka2021-06-121-2/+2
|
* bpo-43394: Fix -Wstrict-prototypes warnings (GH-24737)Brandt Bucher2021-03-041-1/+1
|
* bpo-43132: Fix incorrect handling of PyObject_RichCompareBool() in _zoneinfo ↵Zackery Spytz2021-02-051-6/+17
| | | | | | | (GH-24450) PyObject_RichCompareBool() returns -1 on error, but this case is not handled by the find_in_strong_cache() function. Any exception raised by PyObject_RichCompareBool() should be propagated.
* bpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure ↵Hai Shi2021-01-271-0/+3
| | | | | (GH-24333) Importing datetime can fail.
* bpo-43033: Fix the handling of PyObject_SetAttrString() in _zoneinfo.c ↵Zackery Spytz2021-01-271-1/+5
| | | | (GH-24345)
* bpo-41995: Handle allocation failure in _tracemalloc and _zoneinfo (GH-22635)Yunlongs2021-01-201-0/+12
|
* bpo-40686: Fix compiler warnings on _zoneinfo.c (GH-23614)Victor Stinner2020-12-161-10/+4
| | | | | | | | "uint8_t day" is unsigned and so "day < 0" test is always true. Remove the test to fix the following warnings on Windows: modules\_zoneinfo.c(1224): warning C4068: unknown pragma modules\_zoneinfo.c(1225): warning C4068: unknown pragma modules\_zoneinfo.c(1227): warning C4068: unknown pragma
* bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)Victor Stinner2020-10-271-1/+2
| | | | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory. _cursesmodule.c and zoneinfo.c are now built with Py_BUILD_CORE_MODULE macro defined.
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-11/+7
| | | | | | | | | | | _PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
* bpo-30155: Add macros to get tzinfo from datetime instances (GH-21633)Zackery Spytz2020-09-231-3/+1
| | | | Add PyDateTime_DATE_GET_TZINFO() and PyDateTime_TIME_GET_TZINFO() macros.
* bpo-41568: Fix refleaks in zoneinfo subclasses (GH-21907)Paul Ganssle2020-08-171-3/+3
| | | | | | | | | | | | | | * Fix refleak in C module __init_subclass__ This was leaking a reference to the weak cache dictionary for every ZoneInfo subclass created. * Fix refleak in ZoneInfo subclass's clear_cache The previous version of the code accidentally cleared the global ZONEINFO_STRONG_CACHE variable (and inducing `ZoneInfo` to create a new strong cache) on calls to a subclass's `clear_cache()`. This would not affect guaranteed behavior, but it's still not the right thing to do (and it caused reference leaks).
* bpo-41025: Fix subclassing for zoneinfo.ZoneInfo (GH-20965)Paul Ganssle2020-08-141-1/+1
| | | | | | | | Prior to this change, attempting to subclass the C implementation of zoneinfo.ZoneInfo gave the following error: TypeError: unbound method ZoneInfo.__init_subclass__() needs an argument https://bugs.python.org/issue41025
* bpo-41336: Fix the error handling in zoneinfo_new_instance() (GH-21546)Zackery Spytz2020-07-201-1/+7
| | | | Do not call PyObject_CallMethod() with a live exception (like KeyboardInterrupt).
* Fix -Wstring-prototypes warnings in _zoneinfo.c. (GH-21478)Benjamin Peterson2020-07-151-2/+2
|
* bpo-41056: Fix a possible MemoryError leak within zoneinfo. (GH-21007)Gregory P. Smith2020-06-221-4/+2
| | | | | This was detected by our Coverity scan as a REVERSE_INULL issue. Automerge-Triggered-By: @gpshead
* 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-40705: Fix use-after-free in _zoneinfo's module_free (GH-20280)Ammar Askar2020-05-221-6/+9
|
* bpo-40714: Remove compile warning from _zoneinfo.c (GH-20291)Dong-hee Na2020-05-211-2/+4
|
* bpo-40503: PEP 615: Tests and implementation for zoneinfo (GH-19909)Paul Ganssle2020-05-161-0/+2695
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.