Closed
Description
Bug report
Bug description:
(originally noticed by @davidhewitt in #116738 (comment))
Very infrequently, PyO3 tests for timezone conversions will fail with errors like:
---- conversions::chrono_tz::tests::test_into_pyobject stdout ----
thread 'conversions::chrono_tz::tests::test_into_pyobject' panicked at src/conversions/chrono_tz.rs:120:17:
zoneinfo.ZoneInfo(key='UTC') != zoneinfo.ZoneInfo(key='UTC')
Unfortunately, I don't have an easier way to trigger this besides "run the PyO3 tests over and over until you see a failure", since I think triggering it requires many threads simultaneously using the C API which happens automatically with cargo for the PyO3 tests.
The test code is here:
I believe that rust is more or less doing the equivalent of this C code:
#include <Python.h>
int main()
{
if (Py_IsInitialized() == 0) {
Py_InitializeEx(0);
PyObject *mod = PyImport_ImportModule("zoneinfo");
if (mod == NULL) {
PyErr_PrintEx(0);
return -1;
}
PyObject *zoneinfo = PyObject_GetAttrString(mod, "ZoneInfo");
if (zoneinfo == NULL) {
PyErr_PrintEx(0);
return -1;
}
PyObject *arg = PyUnicode_FromString("Europe/Paris");
PyObject *obj1 = PyObject_CallOneArg(zoneinfo, arg);
PyObject *obj2 = PyObject_CallOneArg(zoneinfo, arg);
PyObject *result = PyObject_RichCompare(obj1, obj2, Py_EQ);
PyObject_Print(result, stderr, Py_PRINT_RAW);
}
return 0;
}
This doesn't fail, which makes me suspect triggering it requires touching the C API in other threads.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Done