Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for the PyEval_Run family of the C API #117968

Open
18 tasks
erlend-aasland opened this issue Apr 17, 2024 · 4 comments
Open
18 tasks

Add tests for the PyEval_Run family of the C API #117968

erlend-aasland opened this issue Apr 17, 2024 · 4 comments
Labels
extension-modules C modules in the Modules dir tests Tests in the Lib/test dir topic-C-API

Comments

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Apr 17, 2024

Functional tests for the PyEval_Run family of the C API lack tests. Discovered in the discussions of PR #116637.

  • PyRun_AnyFile (may be a macro)
  • PyRun_AnyFileEx (may be a macro)
  • PyRun_AnyFileExFlags
  • PyRun_AnyFileFlags (may be a macro)
  • PyRun_File (may be a macro)
  • PyRun_FileEx (may be a macro)
  • PyRun_FileFlags (may be a macro)
  • PyRun_InteractiveLoop (may be a macro)
  • PyRun_InteractiveLoopFlags
  • PyRun_InteractiveOne (may be a macro)
  • PyRun_InteractiveOneFlags
  • PyRun_InteractiveOneObject
  • PyRun_SimpleFile (may be a macro)
  • PyRun_SimpleFileEx (may be a macro)
  • PyRun_SimpleFileExFlags
  • PyRun_SimpleString (may be a macro)
  • PyRun_SimpleStringFlags
  • PyRun_String (may be a macro)

Linked PRs

@erlend-aasland
Copy link
Contributor Author

cc. @serhiy-storchaka

@serhiy-storchaka
Copy link
Member

Most of these functions (especially implemented as macros) are thin wrappers around functions with richer interface, so it is not practical to repeat all tests for all functions. We only need to add comprehensive tests for base functions, and simpler tests for derived functions.

Some functions are implemented as macros, but also as real functions. It would be nice to test both implementations (only simple tests are needed).

serhiy-storchaka added a commit that referenced this issue Apr 17, 2024
…H-117982)

Co-authored-by: NGRsoftlab <78017794+NGRsoftlab@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 17, 2024
… the C API (pythonGH-117982)

(cherry picked from commit 6078f20)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: NGRsoftlab <78017794+NGRsoftlab@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
serhiy-storchaka added a commit that referenced this issue Apr 22, 2024
… API (GH-117982) (GH-118011)

(cherry picked from commit 6078f20)

Co-authored-by: NGRsoftlab <78017794+NGRsoftlab@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
@encukou
Copy link
Member

encukou commented Apr 23, 2024

The test_run_fileexflags test that was added in #117982 sometimes crashes on LTO+PGO buildbots, see for example:

Do you want to look into this?

serhiy-storchaka added a commit that referenced this issue Apr 25, 2024
…GH-118230)

The behavior of fileno() after fclose() is undefined, but it is the only
practical way to check whether the file was closed.
Only test this on the known platforms (Linux, Windows, macOS), where we
already tested that it works.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 25, 2024
… tests (pythonGH-118230)

The behavior of fileno() after fclose() is undefined, but it is the only
practical way to check whether the file was closed.
Only test this on the known platforms (Linux, Windows, macOS), where we
already tested that it works.
(cherry picked from commit 546cbcf)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Apr 25, 2024
…I tests (GH-118230) (GH-118266)

The behavior of fileno() after fclose() is undefined, but it is the only
practical way to check whether the file was closed.
Only test this on the known platforms (Linux, Windows, macOS), where we
already tested that it works.
(cherry picked from commit 546cbcf)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@encukou
Copy link
Member

encukou commented Apr 25, 2024

I'm still seeing failures; there might be two different issues. See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir tests Tests in the Lib/test dir topic-C-API
Projects
None yet
Development

No branches or pull requests

3 participants