[pypy-dev] pytest test_rposix.py with mingw32
Matti Picus
matti.picus at gmail.com
Sun May 27 19:57:53 CEST 2012
On 26/05/2012 4:47 PM, bookaa wrote:
> keywords: _PyVerify_fd __pioinfo _msize
> PyPy can not pass this test:
> pytest.py --cc=mingw32-gcc
> pypy\rlib\test\test_rposix.py::TestPosixUnicode::()::test_is_valid_fd
> After 2 days of hard work, I finally realise why. Patch file attached.
> The problem is in _PyVerify_fd:
> FILE* f = fopen("d:\\55.txt","w");
> int no = fileno(f);
> int flg1 = _PyVerify_fd(no);
> fclose(f);
> int flg2 = _PyVerify_fd(no);
> printf("flg1 %d should be 1, flg2 %d should be 0", flg1, flg2)
> in file rposix.py, source of function _PyVerify_fd is write to a c
> file, and will be compile to a Windows
> DLL file. In this function, it use
> extern __declspec(dllimport) char * __pioinfo[];
> __pioinfo as a global variable.
> I find use __pioinfo in a DLL file is not safe. the __pioinfo and
> _msize may export from many DLL:
> msvcrt.dll
> msvcr90.dll
> msvcr90d.dll
> or maybe msvcr70.dll ...
> If we fopen and fileno in a EXE file, and call _PyVerify_fd in a DLL
> file, its very danger. The EXE
> and DLL may reference different __pioinfo and get error.
> So I think test_rposix.py::TestPosixUnicode::()::test_is_valid_fd can
> pass in MSVC is only a coincidence.
> _PyVerify_fd in a DLL and use dllimport __pioinfo is not safe.
> In my fix, I do not assume any DLL we should use. I try to find the
> current DLL which export __pioinfo already
> loaded. Sure this is not very good. But I think if we must place
> _PyVerify_fd in a DLL, no good solution.
> After this path, this tests are pass:
> pytest.py --cc=mingw32-gcc pypy\rlib\test\test_rposix.py
> pytest.py pypy\rlib\test\test_rposix.py
Thanks for your help tracking this down. It's nice to see someone else
who is interested in the windows port.
Most of this patch was already merged into the default branch a few days
ago.
Also: it seems like an issue during testing only. The patch should
somehow reflect this without hardcoding runtime info into the
translated pypy.
Also please do not use --cc=mingw32 syntax for tests. If you set an
environment variable to CC:
export CC=mingw32 (in a unix-like shell)
set CC=mingw32 (in the cmd shell)
it will use a compiler named mingw32
Matti
More information about the pypy-dev
mailing list