python / cpython

The Python programming language
https://www.python.org
Other
62.63k stars 30.05k forks source link

Duplicate directory error when testing `test/support/os_helper.py` #124841

Closed rruuaanng closed 1 hour ago

rruuaanng commented 2 hours ago

Bug report

Bug description:

0:12:20 load avg: 10.34 Re-running 2 failed tests in verbose mode in subprocesses
0:12:20 load avg: 10.34 Run 2 tests in parallel using 2 worker processes (timeout: 10 min, worker timeout: 15 min)
0:12:21 load avg: 10.17 [1/2] test_threading passed
D:\a\cpython\cpython\Lib\test\support\os_helper.py:554: RuntimeWarning: tests may fail, unable to create temporary directory 'D:\\a\\cpython\\cpython\\build\\test_python_8256�': [WinError 183] Cannot create a file when that file already exists: 'D:\\a\\cpython\\cpython\\build\\test_python_8256�'
  with temp_dir(path=name, quiet=quiet) as temp_path:
Re-running test_threading in verbose mode (matching: test_wait_return)
test_wait_return (test.test_threading.BarrierTests.test_wait_return)

For more information, see: https://github.com/python/cpython/actions/runs/11123486415/job/30907056284?pr=124747

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

rruuaanng commented 2 hours ago

This confuses me, I can't understand why my commit didn't modify anything else, but it gave me this error.

vstinner commented 2 hours ago

The error "tests may fail, unable to create temporary directory" is not a big deal, you can ignore it. What is the purpose of your issue? I don't understand your problem.

rruuaanng commented 1 hour ago

The error "tests may fail, unable to create temporary directory" is not a big deal, you can ignore it. What is the purpose of your issue? I don't understand your problem.

Oh, victor, can you take a look at my PR? I ran that test locally and it passed, but I don't know why it had a strange error in CI.

rruuaanng commented 1 hour ago

I can't understand why it would fail, which is very confusing to me. But I run it without any problem.

vstinner commented 1 hour ago

For more information, see: https://github.com/python/cpython/actions/runs/11123486415/job/30907056284?pr=124747

It seems like you have a more serious issue:

test_copy_to_object (test.test_capi.test_abstract.CAPITest.test_copy_to_object) ...
Windows fatal exception: access violation
rruuaanng commented 1 hour ago

For more information, see: https://github.com/python/cpython/actions/runs/11123486415/job/30907056284?pr=124747更多信息,请参见:https://github.com/python/cpython/actions/runs/11123486415/job/30907056284?pr=124747

It seems like you have a more serious issue:看来你可能有一个更严重的问题:

test_copy_to_object (test.test_capi.test_abstract.CAPITest.test_copy_to_object) ...
Windows fatal exception: access violation

Yes, his error was in my test case, but it seems he has no problem

#include "Python.h"

static PyObject *
test(PyObject *module, PyObject *args)
{
    PyObject *obj;
    Py_ssize_t len;
    int result;
    char *buf, fort;

    if (!PyArg_ParseTuple(args, "Os#C", &obj, &buf, &len, &fort)) {
        return NULL;
    }
    result = PyObject_CopyToObject(obj, buf, len, fort);
    if (result < 0) {
        return NULL;
    }
    Py_INCREF(obj);
    return obj;
}

static PyMethodDef methods[] = {
    {"test", test, METH_VARARGS, "Copy data from Python object to buffer"},
    {NULL, NULL, 0, NULL}
};

static struct PyModuleDef module = {
    PyModuleDef_HEAD_INIT,
    "asd",
    NULL,
    -1,
    methods
};

PyMODINIT_FUNC
PyInit_asd(void) {
    return PyModule_Create(&module);
}

output

>>> import asd
>>> asd.test(bytes(3), 'aaa', 'C')
b'aaa'

In Lib\test\testcapi\test_abstract.py

static PyObject *
object_copy_to_object(PyObject *self, PyObject *args)
{
    PyObject *obj;
    Py_ssize_t len;
    int result;
    char *buf, fort;
    // import _testcapi;_testcapi.object_copy_to_object(bytes(3), 'abc', 'C')
    if (!PyArg_ParseTuple(args, "Os#C", &obj, &buf, &len, &fort)) {
        return NULL;
    }
    // printf("%s\t%lld\t%c", buf, len, fort);
    result = PyObject_CopyToObject(obj, buf, len, fort);
    if (result < 0) {
        return NULL;
    }
    Py_INCREF(obj);
    return obj;
}

output

>>> import _testcapi
>>>_testcapi.object_copy_to_object(bytes(3), 'abc', 'C')
b'abc'

OMG, what should I do?

rruuaanng commented 1 hour ago

I don't understand why he is so bad in CI.