summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-37205: time.time() cannot fail with fatal error (GH-23314)Victor Stinner2020-11-161-22/+65
| | | | | | | | | | | | | | | time.time(), time.perf_counter() and time.monotonic() functions can no longer fail with a Python fatal error, instead raise a regular Python exception on failure. Remove _PyTime_Init(): don't check system, monotonic and perf counter clocks at startup anymore. On error, _PyTime_GetSystemClock(), _PyTime_GetMonotonicClock() and _PyTime_GetPerfCounter() now silently ignore the error and return 0. They cannot fail with a Python fatal error anymore. Add py_mach_timebase_info() and win_perf_counter_frequency() sub-functions.
* bpo-41100: Support macOS 11 and Apple Silicon (GH-22855)Ronald Oussoren2020-11-081-52/+162
| | | | | | | | | | | Co-authored-by: Lawrence D’Anna <lawrence_danna@apple.com> * Add support for macOS 11 and Apple Silicon (aka arm64) As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy * Support building on recent versions of macOS while deploying to older versions This allows building installers on macOS 11 while still supporting macOS 10.9.
* bpo-35455: Fix thread_time for Solaris OS (GH-11118)Jakub Kulík2020-11-021-0/+17
|
* 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-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-6/+5
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* closes bpo-40017: Add CLOCK_TAI constant to the time module. (GH-19096)Russell Owen2020-03-241-0/+5
| | | Co-authored-by: Benjamin Peterson <benjamin@python.org>
* bpo-1635741: Port time module to multiphase initialization (PEP 489) (GH-19107)Paulo Henrique Silva2020-03-231-51/+52
|
* bpo-1635741: Fix refleaks of time module error handling (GH-18486)Hai Shi2020-03-111-18/+45
|
* bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na2020-02-171-1/+1
|
* bpo-36205: Fix the rusage implementation of time.process_time() (GH-15538)vrajivk2019-08-271-1/+1
|
* bpo-36779: time.tzname returns empty string on Windows if default cod… ↵Paul Monson2019-06-121-0/+14
| | | | | | | | | | | | | | | (GH-13073) Calling setlocale(LC_CTYPE, "") on a system where GetACP() returns CP_UTF8 results in empty strings in _tzname[]. This causes time.tzname to be an empty string. I have reported the bug to the UCRT team and will follow up, but it will take some time get a fix into production. In the meantime one possible workaround is to temporarily change the locale by calling setlocale(LC_CTYPE, "C") before calling _tzset and restore the current locale after if the GetACP() == CP_UTF8 or CP_UTF7 @zooba https://bugs.python.org/issue36779
* bpo-36895: remove time.clock() as per removal notice. (GH-13270)Matthias Bussonnier2019-05-131-50/+0
| | | | `time.clock()` was deprecated in 3.3, and marked for removal removal in 3.8; this thus remove it from the time module.
* bpo-31904: Port the time module on VxWorks (GH-12305)pxinwr2019-04-151-4/+7
| | | time.clock() is not available on VxWorks.
* bpo-34373: Fix time.mktime() on AIX (GH-12726)Victor Stinner2019-04-091-29/+37
| | | | | | | | | | | | | | | Fix time.mktime() error handling on AIX for year before 1970. Other changes: * mktime(): rename variable 'buf' to 'tm'. * _PyTime_localtime(): * Use "localtime" rather than "ctime" in the error message (specific to AIX). * Always initialize errno to 0 just in case if localtime_r() doesn't set errno on error. * On AIX, avoid abs() which is limited to int type. * EINVAL constant is now always available.
* bpo-24643: Fix "#define timezone _timezone" clashes on Windows (GH-12019)Zackery Spytz2019-02-251-5/+15
|
* bpo-35702: Add new identifier time.CLOCK_UPTIME_RAW for macOS 10.12 (GH-11503)Joannah Nanjekye2019-01-101-0/+3
|
* bpo-35550: Fix incorrect Solaris define guards (GH-11275)Jakub Kulík2018-12-311-2/+2
| | | | | | | Python source code uses on several places ifdef sun or defined(sun) without the underscores, which is not standard compliant and shouldn't be used. Defines should check for __sun instead. Reference: http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#Solaris https://bugs.python.org/issue35550
* bpo-35214: MSan workarounds for socket, time, and test_faulthandler. (GH-11375)Gregory P. Smith2018-12-311-0/+7
| | | | | Add Clang Memory Sanitizer build instrumentation to work around false positives from the socket and time modules as well as skipping a couple test_faulthandler tests.
* bpo-34373: fix test_mktime and test_pthread_getcpuclickid tests on AIX (GH-8726)Michael Felt2018-12-281-12/+33
| | | | | | | | | * Fix test_mktime on AIX by adding code to get mktime to behave the same way as it does on other *nix systems * Fix test_pthread_getcpuclickid in AIX by adjusting the test case expectations when running on AIX in 32-bit mode Patch by Michael Felt.
* bpo-35373: Fix PyInit_time() error handling (GH-10865)Victor Stinner2018-12-031-4/+7
| | | | | | | * PyInit_time() now returns NULL if an exception is raised. * Rename PyInit_timezone() to init_timezone(). "PyInit_" prefix is a special prefix for function initializing a module. init_timezone() doesn't initialize a module and the function is not exported.
* bpo-35373: Fix PyInit_timezone() if HAVE_DECL_TZNAME is defined (GH-10861)Victor Stinner2018-12-031-4/+5
| | | If HAVE_DECL_TZNAME, PyInit_timezone() now returns -1 on error.
* get_gmtoff() now returns time_t (GH-10838)Victor Stinner2018-11-301-11/+36
| | | | | | | get_gmtoff() now returns time_t instead of int to fix the following Visual Studio warning: Modules\timemodule.c(1183): warning C4244: 'return': conversion from 'time_t' to 'int', possible loss of data
* bpo-35337: Fix gettmarg(): use PyStructSequence_GET_ITEM() (GH-10765)Victor Stinner2018-11-281-2/+2
| | | | PyStructSequence_GET_ITEM() must be used instead of PyTuple_GET_ITEM() on a StructTimeType.
* bpo-34672: fix a compiler warning in timemodule.c (GH-10176)Xiang Zhang2018-10-281-1/+1
|
* closes bpo-35025: Properly guard the `CLOCK_GETTIME` et al macros in ↵Max Bélanger2018-10-211-0/+4
| | | | | timemodule.c. (GH-9961) Guard the `CLOCK_GETTIME` et al macros in `timemodule` based on the availability of the parent functions
* bpo-34735: Fix a memory leak in Modules/timemodule.c (GH-9418)Zackery Spytz2018-09-211-0/+1
| | | There was a missing PyMem_Free(format) in time_strftime().
* Simplify PyInit_timezone. (GH-9467)Benjamin Peterson2018-09-211-50/+48
| | | | | | | | Reduce the knotty preprocessor conditional logic, dedent unnecessarily nested code, and handle errors properly. The first edition of this change (afde1c1a05cc8a1e8adf6403c451f6708509a605) failed (bpo-34715) because FreeBSD doesn't define the timezone globals. That's why we're now checking for HAVE_DECL_TZNAME.
* bpo-34715: Revert "Simplify PyInit_timezone. (GH-9323)" (GH-9366)Victor Stinner2018-09-171-15/+68
| | | This reverts commit afde1c1a05cc8a1e8adf6403c451f6708509a605.
* Simplify PyInit_timezone. (GH-9323)Benjamin Peterson2018-09-141-68/+15
| | | Assume tzname exists. Only use a hack to compute altzone if it's not defined.
* bpo-34672: Don't pass NULL to gmtime_r. (GH-9312)Benjamin Peterson2018-09-141-1/+2
|
* bpo-34672: Try to pass the C library's own timezone strings back to it. ↵Benjamin Peterson2018-09-141-4/+36
| | | | (GH-9288)
* bpo-13312: Avoid int underflow in time year. (GH-8912)Gregory P. Smith2018-08-251-0/+6
| | | Avoids an integer underflow in the time module's year handling code.
* Fix some warnings produced by different compilers. (#5593)Serhiy Storchaka2018-02-091-0/+2
|
* bpo-29240: Fix locale encodings in UTF-8 Mode (#5170)Victor Stinner2018-01-151-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Modify locale.localeconv(), time.tzname, os.strerror() and other functions to ignore the UTF-8 Mode: always use the current locale encoding. Changes: * Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or encoding error, they return the position of the error and an error message which are used to raise Unicode errors in PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale(). * Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx(). * PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all cases, especially for the strict error handler. * Add _Py_DecodeUTF8Ex(): return more information on decoding error and supports the strict error handler. * Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex(). * Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx(). * Ignore the UTF-8 mode to encode/decode localeconv(), strerror() and time zone name. * Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use the "current" locale. * Remove _PyUnicode_DecodeCurrentLocale(), _PyUnicode_DecodeCurrentLocaleAndSize() and _PyUnicode_EncodeCurrentLocale().
* bpo-29240: Ignore UTF-8 Mode in time module (#5148)Victor Stinner2018-01-111-6/+6
| | | | | | time.strftime() must use the current LC_CTYPE encoding, not UTF-8 if the UTF-8 mode is enabled. Add _PyUnicode_DecodeCurrentLocale() function.
* bpo-32025: Add time.thread_time() (#4410)Antoine Pitrou2017-11-151-0/+117
| | | | | | | | | | | | | | * bpo-32025: Add time.thread_time() * Add missing #endif * Add NEWS blurb * Add docs and whatsnew * Address review comments * Review comments
* bpo-31784: Implement PEP 564: add time.time_ns() (#3989)Victor Stinner2017-11-021-117/+309
| | | | | | | | | | | | | | | | | | | | | | | | | Add new time functions: * time.clock_gettime_ns() * time.clock_settime_ns() * time.monotonic_ns() * time.perf_counter_ns() * time.process_time_ns() * time.time_ns() Add new _PyTime functions: * _PyTime_FromTimespec() * _PyTime_FromNanosecondsObject() * _PyTime_FromTimeval() Other changes: * Add also os.times() tests to test_os. * pytime_fromtimeval() and pytime_fromtimeval() now return _PyTime_MAX or _PyTime_MIN on overflow, rather than undefined behaviour * _PyTime_FromNanoseconds() parameter type changes from long long to _PyTime_t
* bpo-31917: Add 3 new clock identifiers (#4207)Victor Stinner2017-11-021-0/+9
| | | | | | | Add new clock identfiers: * time.CLOCK_BOOTTIME * time.CLOCK_PROF * time.CLOCK_UPTIME
* bpo-31806: Use _PyTime_ROUND_TIMEOUT for the timeout argument parsing in ↵Pablo Galindo2017-10-181-1/+1
| | | | | | | | | more functions (#4026) Fix timeout rounding in time.sleep(), threading.Lock.acquire() and socket.socket.settimeout() to round correctly negative timeouts between -1.0 and 0.0. The functions now block waiting for events as expected. Previously, the call was incorrectly non-blocking.
* time.clock() now emits a DeprecationWarning (GH-4020)Victor Stinner2017-10-171-0/+7
| | | | | | | | | | bpo-31803: time.clock() and time.get_clock_info('clock') now emit a DeprecationWarning warning. Replace time.clock() with time.perf_counter() in tests and demos. Remove also hasattr(time, 'monotonic') in test_time since time.monotonic() is now always available since Python 3.5.
* bpo-31773: _PyTime_GetPerfCounter() uses _PyTime_t (GH-3983)Victor Stinner2017-10-161-3/+4
| | | | | | | | * Rewrite win_perf_counter() to only use integers internally. * Add _PyTime_MulDiv() which compute "ticks * mul / div" in two parts (int part and remaining) to prevent integer overflow. * Clock frequency is checked at initialization for integer overflow. * Enhance also pymonotonic() to reduce the precision loss on macOS (mach_absolute_time() clock).
* bpo-31773: time.perf_counter() uses again double (GH-3964)Victor Stinner2017-10-121-17/+11
| | | | | | | | time.clock() and time.perf_counter() now use again C double internally. Remove also _PyTime_GetWinPerfCounterWithInfo(): use _PyTime_GetPerfCounterDoubleWithInfo() instead on Windows.
* bpo-28157: Improvements for the time module documentation (GH-928)Cheryl Sabella2017-10-111-22/+1
| | | | | * Separated functions and constants descriptions in sections. * Added a note about the limitations of timezone constants. * Removed redundant lists from the module docstring.
* bpo-31415: Add _PyTime_GetPerfCounter() and use it for -X importtime (#3936)Victor Stinner2017-10-101-48/+23
| | | | | * Add _PyTime_GetPerfCounter() * Use _PyTime_GetPerfCounter() for -X importtime
* closes bpo-31596: Add an interface for pthread_getcpuclockid(3) (#3756)pdox2017-10-051-0/+32
|
* bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal ↵Oren Milman2017-08-201-6/+17
| | | | tuples. (#3119)
* timemodule.c: Cast PyUnicode_AsUTF8() to char* (#1294)Victor Stinner2017-04-261-1/+1
| | | | | | | | | | bpo-28769 changed PyUnicode_AsUTF8() return type from const char* to char* in Python 3.7, but tm_zone field type of the tm structure is char* on FreeBSD. Cast PyUnicode_AsUTF8() to char* in gettmarg() to fix the warning: Modules/timemodule.c:443:20: warning: assigning to 'char *' from 'const char *' discards qualifiers
* tmtotuple(): use time_t for gmtoff (#1276)Victor Stinner2017-04-241-3/+3
| | | | | | | timegm() return type is time_t, not int. Use time_t to prevent the following compiler warning on Windows: timemodule.c: warning C4244: '=': conversion from 'time_t' to 'int', possible loss of data
* Only define get_zone() and get_gmtoff() if needed (#1193)Victor Stinner2017-04-201-0/+2
| | | | | | | | | Only define the get_zone() and get_gmtoff() private functions in the time module if these functions are needed to initialize the module. The change fixes the following warnings on AIX: Modules/timemodule.c:1175:1: warning: 'get_gmtoff' defined but not used [-Wunused-function] Modules/timemodule.c:1164:1: warning: 'get_zone' defined but not used [-Wunused-function]
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-4/+2
| | | | possible. Patch is writen with Coccinelle.