summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fixes maximum usable length of buffer for formatting time zone in localtime().Steve Dower2016-12-141-1/+1
|\
| * Fixes maximum usable length of buffer for formatting time zone in localtime().Steve Dower2016-12-141-1/+1
| |
* | time_strptime() uses PyObject_Call()Victor Stinner2016-12-081-7/+13
|/ | | | | | Issue #28915: Use PyObject_Call() to pass a tuple of positional arguments, instead of relying on _PyObject_CallMethodId() weird behaviour to unpack the tuple.
* Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-1/+1
| | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
* Issue #28148: Stop using localtime() and gmtime() in the time module.Alexander Belopolsky2016-09-281-41/+14
| | | | | | Introduced platform independent _PyTime_localtime API that is similar to POSIX localtime_r, but available on all platforms. Patch by Ed Schouten.
* more granular configure checks for clock_* functions (closes #28081)Benjamin Peterson2016-09-141-3/+11
|
* Closes #25283: Make tm_gmtoff and tm_zone available on all platforms.Alexander Belopolsky2016-09-121-33/+81
|
* Issue #22624: Python 3 requires clock() to buildVictor Stinner2016-07-081-0/+1
|
* Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-1/+1
| | | | private functions.