Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-126554: correct detection ofgcc forTestNullDlsym.test_null_dlsym#129872

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
encukou merged 2 commits intopython:mainfrompetermarko:fix/test_null_dlsym-main
Feb 10, 2025

Conversation

@petermarko
Copy link
Contributor

@petermarkopetermarko commentedFeb 8, 2025
edited by bedevere-appbot
Loading

In case gcc is not available, it will throw exception and test fails. So catch the exception to skip the test correctly.

======================================================================ERROR: test_null_dlsym (test.test_ctypes.test_dlerror.TestNullDlsym.test_null_dlsym)----------------------------------------------------------------------Traceback (most recent call last):  File "/usr/lib/python3.12/test/test_ctypes/test_dlerror.py", line 61, in test_null_dlsym    retcode = subprocess.call(["gcc", "--version"],              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.12/subprocess.py", line 391, in call    with Popen(*popenargs, **kwargs) as p:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.12/subprocess.py", line 1028, in __init__    self._execute_child(args, executable, preexec_fn, close_fds,  File "/usr/lib/python3.12/subprocess.py", line 1963, in _execute_child    raise child_exception_type(errno_num, err_msg, err_filename)FileNotFoundError: [Errno 2] No such file or directory: 'gcc'

@ghost
Copy link

ghost commentedFeb 8, 2025
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-appbedevere-appbot added the testsTests in the Lib/test dir labelFeb 8, 2025
@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@picnixz
Copy link
Member

picnixz commentedFeb 9, 2025
edited
Loading

Wait, how come thereturncode is not catching this kind of issue. I remember we changed thesubprocess call but I don't remember why we left it as is.

  1. Can you also use the issue number we used for adding this test?
  2. Can you narrow down the exception being caught instead of a bareexcept? or find a way to avoid a try-except and use another feature ofsubprocess if possible?

cc@encukou (I don't remember why we didn't catch this)

@petermarko
Copy link
ContributorAuthor

The trace is actually from 3.12.9, but the subprocess call throws exception also in 3.13 and 3.14-rc although I didn't try to run the testsuite in those.
The test was introduced based ongh-126554 and backported to 3.12 ingh-127764.
I can also just target 3.12 branch if it's not a problem for newer branches.

I'll rewrite this to catch justFileNotFoundError

@picnixzpicnixz changed the titlectypes: correct gcc check in testgh-126554: correct detection ofgcc forTestNullDlsym.test_null_dlsymFeb 9, 2025
@petermarko
Copy link
ContributorAuthor

Beautified by addingFileNotFoundError exception type

Meanwhile I retested also 3.13.2, so I guess it's valid for all releases.

======================================================================ERROR: test_null_dlsym (test.test_ctypes.test_dlerror.TestNullDlsym.test_null_dlsym)----------------------------------------------------------------------Traceback (most recent call last):  File "/usr/lib/python3.13/test/test_ctypes/test_dlerror.py", line 61, in test_null_dlsym    retcode = subprocess.call(["gcc", "--version"],                              stdout=subprocess.DEVNULL,                              stderr=subprocess.DEVNULL)  File "/usr/lib/python3.13/subprocess.py", line 397, in call    with Popen(*popenargs, **kwargs) as p:         ~~~~~^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.13/subprocess.py", line 1038, in __init__    self._execute_child(args, executable, preexec_fn, close_fds,    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                        pass_fds, cwd, env,                        ^^^^^^^^^^^^^^^^^^^    ...<5 lines>...                        gid, gids, uid, umask,                        ^^^^^^^^^^^^^^^^^^^^^^                        start_new_session, process_group)                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.13/subprocess.py", line 1974, in _execute_child    raise child_exception_type(errno_num, err_msg, err_filename)FileNotFoundError: [Errno 2] No such file or directory: 'gcc'

@picnixzpicnixz added needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsFeb 9, 2025
@picnixz
Copy link
Member

Ok, actually thereis a way to make it work without a try-except: We need to pass theshell=True parameter.However it appears that the following happens:

>>>subprocess.call(["gcc","--version"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)0>>>subprocess.call(["gcc","--version"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,shell=True)1

So, we need to be a bit more careful with the actual return code! So, instead I either indeed suggest using aFileNotFoundError guard. Note that usingwhich could work but this utility is not present everywhere:

subprocess.call(["which","abc"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)# == 1subprocess.call(["which","gcc"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)# == 0

So, let's use the guard.

In case gcc is not available, it will throw exception and test fails.So catch the exception to skip the test correctly.======================================================================ERROR: test_null_dlsym (test.test_ctypes.test_dlerror.TestNullDlsym.test_null_dlsym)----------------------------------------------------------------------Traceback (most recent call last):  File "/usr/lib/python3.12/test/test_ctypes/test_dlerror.py", line 61, in test_null_dlsym    retcode = subprocess.call(["gcc", "--version"],              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.12/subprocess.py", line 391, in call    with Popen(*popenargs, **kwargs) as p:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.12/subprocess.py", line 1028, in __init__    self._execute_child(args, executable, preexec_fn, close_fds,  File "/usr/lib/python3.12/subprocess.py", line 1963, in _execute_child    raise child_exception_type(errno_num, err_msg, err_filename)FileNotFoundError: [Errno 2] No such file or directory: 'gcc'Signed-off-by: Peter Marko <peter.marko@siemens.com>
@encukou
Copy link
Member

There isshutil.which, but, catching the error is more appropriate here.

Perhaps it's time to add a test helper to find gcc/clang, and skip test if it's not available. (But that would be for a new PR.)

@encukouencukou merged commit978211c intopython:mainFeb 10, 2025
38 checks passed
@miss-islington-app
Copy link

Thanks@petermarko for the PR, and@encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 10, 2025
…ull_dlsym` (pythonGH-129872)In case gcc is not available, the test will fail with FileNotFoundError.So catch the exception to skip the test correctly.(cherry picked from commit978211c)Co-authored-by: Peter Marko <peter.marko@siemens.com>Signed-off-by: Peter Marko <peter.marko@siemens.com>
@bedevere-app
Copy link

GH-129944 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelFeb 10, 2025
@encukou
Copy link
Member

Thank you for the report & fix,@petermarko!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 10, 2025
…ull_dlsym` (pythonGH-129872)In case gcc is not available, the test will fail with FileNotFoundError.So catch the exception to skip the test correctly.(cherry picked from commit978211c)Co-authored-by: Peter Marko <peter.marko@siemens.com>Signed-off-by: Peter Marko <peter.marko@siemens.com>
@bedevere-app
Copy link

GH-129945 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelFeb 10, 2025
picnixz pushed a commit that referenced this pull requestFeb 10, 2025
…null_dlsym` (GH-129872) (#129945)gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872)In case gcc is not available, the test will fail with FileNotFoundError.So catch the exception to skip the test correctly.(cherry picked from commit978211c)Signed-off-by: Peter Marko <peter.marko@siemens.com>Co-authored-by: Peter Marko <peter.marko@siemens.com>
picnixz pushed a commit that referenced this pull requestFeb 10, 2025
…null_dlsym` (GH-129872) (#129944)gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872)In case gcc is not available, the test will fail with FileNotFoundError.So catch the exception to skip the test correctly.(cherry picked from commit978211c)Signed-off-by: Peter Marko <peter.marko@siemens.com>Co-authored-by: Peter Marko <peter.marko@siemens.com>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure⚠️⚠️⚠️

Hi! The buildbotAMD64 Debian root 3.13 has failed when building commitcef406b.

What do you need to do:

  1. Don't panic.
  2. Checkthe buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1441/builds/897) and take a look at the build logs.
  4. Check if the failure is related to this commit (cef406b) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1441/builds/897

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_ns_select - test.test_os.TimerfdTests.test_timerfd_ns_select

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):  File"/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/test_os.py", line4450, intest_timerfd_ns_selectself.assertEqual(self.read_count_signaled(fd),1)~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError:3 != 1Traceback (most recent call last):  File"/root/buildarea/3.13.angelico-debian-amd64/build/Lib/test/test_os.py", line4450, intest_timerfd_ns_selectself.assertEqual(self.read_count_signaled(fd),1)~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError:4 != 1

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@encukouencukouencukou left review comments

@picnixzpicnixzpicnixz approved these changes

Assignees

No one assigned

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@petermarko@picnixz@encukou@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp