mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #22117: Add a new _PyTime_FromSeconds() function
Fix also _Py_InitializeEx_Private(): initialize time before initializing import, import_init() uses the _PyTime API (for thread locks).
This commit is contained in:
parent
21dfffa218
commit
13019fdef3
6 changed files with 45 additions and 5 deletions
|
@ -3382,6 +3382,18 @@ return_result_with_error(PyObject *self, PyObject *args)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
test_pytime_fromseconds(PyObject *self, PyObject *args)
|
||||
{
|
||||
int seconds;
|
||||
_PyTime_t ts;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &seconds))
|
||||
return NULL;
|
||||
ts = _PyTime_FromSeconds(seconds);
|
||||
return _PyTime_AsNanosecondsObject(ts);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
test_pytime_fromsecondsobject(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -3651,6 +3663,7 @@ static PyMethodDef TestMethods[] = {
|
|||
return_null_without_error, METH_NOARGS},
|
||||
{"return_result_with_error",
|
||||
return_result_with_error, METH_NOARGS},
|
||||
{"PyTime_FromSeconds", test_pytime_fromseconds, METH_VARARGS},
|
||||
{"PyTime_FromSecondsObject", test_pytime_fromsecondsobject, METH_VARARGS},
|
||||
{"PyTime_AsSecondsDouble", test_pytime_assecondsdouble, METH_VARARGS},
|
||||
{"PyTime_AsTimeval", test_PyTime_AsTimeval, METH_VARARGS},
|
||||
|
|
|
@ -101,7 +101,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
char *kwlist[] = {"blocking", "timeout", NULL};
|
||||
int blocking = 1;
|
||||
PyObject *timeout_obj = NULL;
|
||||
const _PyTime_t unset_timeout = _PyTime_FromNanoseconds(-1000000000);
|
||||
const _PyTime_t unset_timeout = _PyTime_FromSeconds(-1);
|
||||
|
||||
*timeout = unset_timeout ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue