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

test_compileall.EncodingTest is broken #117389

Closed
sobolevn opened this issue Mar 30, 2024 · 2 comments
Closed

test_compileall.EncodingTest is broken #117389

sobolevn opened this issue Mar 30, 2024 · 2 comments
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Mar 30, 2024

Bug report

This test was added a long time ago as a part of 4b00307

But, it is broken right now for several reasons:

  1. It does not assert anything at all, so it passes when it really should not
  2. It uses print keyword from Python2, which really results in
======================================================================
FAIL: test_error (test.test_compileall.EncodingTest.test_error)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython2/Lib/test/test_compileall.py", line 516, in test_error
    self.assertEqual(buffer.getvalue(), '')
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Listing \'/var/folders/vw/n7c5l8m94zb072h[327 chars]\n\n' != ''
- Listing '/var/folders/vw/n7c5l8m94zb072h487pnlpzm0000gn/T/tmpeolpbxlq'...
- Compiling '/var/folders/vw/n7c5l8m94zb072h487pnlpzm0000gn/T/tmpeolpbxlq/_test.py'...
- ***   File "/var/folders/vw/n7c5l8m94zb072h487pnlpzm0000gn/T/tmpeolpbxlq/_test.py", line 2
-     print u"€"
-     ^^^^^^^^^^
- SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
- 


----------------------------------------------------------------------

But, we cannot see this failure, because the result of compile_all is ignored. And sys.stdout is not checked as well.

I will send a PR with the fix.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir stdlib Python modules in the Lib dir labels Mar 30, 2024
@sobolevn sobolevn self-assigned this Mar 30, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Mar 30, 2024
sobolevn added a commit to sobolevn/cpython that referenced this issue Mar 30, 2024
@terryjreedy
Copy link
Member

terryjreedy commented Mar 30, 2024

How do you get the error? What is the purpose of compileall if errors are ignored? Test if no crashes?

PR looks reasonable, but I can't test if I can't reproduce.

@sobolevn
Copy link
Member Author

@terryjreedy this is what happens when you change print() function to print keyword in my PR.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 5, 2024
(cherry picked from commit 44f6791)

Co-authored-by: Nikita Sobolev <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 5, 2024
(cherry picked from commit 44f6791)

Co-authored-by: Nikita Sobolev <[email protected]>
sobolevn added a commit that referenced this issue May 5, 2024
…8603)

gh-117389: Fix `test_compileall.EncodingTest` (GH-117390)
(cherry picked from commit 44f6791)

Co-authored-by: Nikita Sobolev <[email protected]>
SonicField pushed a commit to SonicField/cpython that referenced this issue May 8, 2024
@hugovk hugovk closed this as completed Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants