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-132950: Skip test_remote_pdb if remote exec is disabled#132951

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
vstinner merged 1 commit intopython:mainfromvstinner:skip_remote_pdb
Apr 25, 2025

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedApr 25, 2025
edited
Loading

Skip test_keyboard_interrupt() if remote execution is disabled.

@gaogaotiantian
Copy link
Member

I don't think this is the correct way to fix it. If remote debugging is not supported, this whole test file should be skipped.

@gaogaotiantian
Copy link
Member

Do we have a flag somewhere about whethersys.remote_exec is supported? For now, we can do a quick test at the beginning of the module and skip the module if that's not supported.

@vstinner
Copy link
MemberAuthor

I don't think this is the correct way to fix it. If remote debugging is not supported, this whole test file should be skipped.
Do we have a flag somewhere about whether sys.remote_exec is supported? For now, we can do a quick test at the beginning of the module and skip the module if that's not supported.

This change is a practical change for the current API. Currently, the only way to check if remote debugging is supported is to actually callsys.remote_exec().

Acceptedhttps://peps.python.org/pep-0768/ only addssys.remote_exec().

@vstinner
Copy link
MemberAuthor

cc@pablogsal

@gaogaotiantian
Copy link
Member

Currently maybe the only test that really usessys.remote_exec is this interrupt one, but the whole remote pdb feature is built onsys.remote_exec. Without it, it just won't work.

Having a specific check in_send_interrupt won't last once we add more tests (and we plan to do that very soon). We could run a quick foo test withsys.remote_exec() and test if this feature is supported, then skip the whole test if it's not. That could be a temporary solution before we have a flag to indicate whether it's supported.

@pablogsal
Copy link
Member

There is a macro to detect if remote_exec is supported. We can expose the macro somewhere (either the sys module or some other place). Ideas?

@pablogsal
Copy link
Member

Ah, I am forgetting I added this for this precise purpose:

>>> sys.is_remote_debug_enabled()True

@pablogsal
Copy link
Member

It needs#132959 first

@vstinner
Copy link
MemberAuthor

There is a macro to detect if remote_exec is supported. We can expose the macro somewhere (either the sys module or some other place). Ideas?

If you dislike my approach, I suggest addingsys._remote_exec_supported() function.

Checking if it's supported is non-trivial. Pseudo-code:

int_PySysRemoteDebug_Supported(void){#if !defined(Py_SUPPORTS_REMOTE_DEBUG)return0;#elif !defined(Py_REMOTE_DEBUG)return0;#elsePyThreadState*tstate=_PyThreadState_GET();constPyConfig*config=_PyInterpreterState_GetConfig(tstate->interp);return (config->remote_debug==1);#endif}

@pablogsal
Copy link
Member

There is a macro to detect if remote_exec is supported. We can expose the macro somewhere (either the sys module or some other place). Ideas?

If you dislike my approach, I suggest addingsys._remote_exec_supported() function.

Checking if it's supported is non-trivial. Pseudo-code:

int_PySysRemoteDebug_Supported(void){#if !defined(Py_SUPPORTS_REMOTE_DEBUG)return0;#elif !defined(Py_REMOTE_DEBUG)return0;#elsePyThreadState*tstate=_PyThreadState_GET();constPyConfig*config=_PyInterpreterState_GetConfig(tstate->interp);return (config->remote_debug==1);#endif}

We already have it:

cpython/Python/sysmodule.c

Lines 2433 to 2449 in17718b0

/*[clinic input]
sys.is_remote_debug_enabled
Return True if remote debugging is enabled, False otherwise.
[clinic start generated code]*/
staticPyObject*
sys_is_remote_debug_enabled_impl(PyObject*module)
/*[clinic end generated code: output=7ca3d38bdd5935eb input=7335c4a2fe8cf4f3]*/
{
#ifndefPy_REMOTE_DEBUG
Py_RETURN_FALSE;
#else
constPyConfig*config=_Py_GetConfig();
returnPyBool_FromLong(config->remote_debug);
#endif
}

vstinner reacted with thumbs up emoji

@vstinner
Copy link
MemberAuthor

Ok, I rewrote my PR to usesys.is_remote_debug_enabled(). I chose to skip the only test which usessys.remote_exec(): test_keyboard_interrupt().

@vstinner
Copy link
MemberAuthor

Example:

$ PYTHON_DISABLE_REMOTE_DEBUG=1 ./python -m test -v test_remote_pdb -m test_keyboard_interrupt(...)test_keyboard_interrupt (test.test_remote_pdb.PdbConnectTestCase.test_keyboard_interrupt)Test that sending keyboard interrupt breaks into pdb. ... skipped 'remote debugging is disabled'(...)

@vstinnervstinner changed the titlegh-132950: Skip test_remote_pdb on FreeBSDgh-132950: Skip test_remote_pdb if remote exec is disabledApr 25, 2025
@vstinner
Copy link
MemberAuthor

@gaogaotiantian: Please review the updated PR.

@gaogaotiantian
Copy link
Member

I still think we should skip the whole test file. Like I said, remote debugging does not exist ifsys.remote_exec is not supported. It's pointless to test the mocking stuff. Also, wewill have other tests that requiressys.remote_exec to execute - any integration test that actually attaches to the process (not just mock). I don't think we lose any coverage to simply skip this module whenremote_exec() is not supported. Just raise aSkipTest at module level if it's not supported liketest_pty.py.

@vstinner
Copy link
MemberAuthor

I still think we should skip the whole test file.

Ok, I updated my PR to do that.

Sorry, I don't know this code, so I tried to write the smallest change :-)

@vstinnervstinnerenabled auto-merge (squash)April 25, 2025 17:27
@vstinnervstinner merged commit947c4f1 intopython:mainApr 25, 2025
42 checks passed
@vstinnervstinner deleted the skip_remote_pdb branchApril 25, 2025 17:28
@gaogaotiantian
Copy link
Member

Sorry, I don't know this code, so I tried to write the smallest change :-)

It makes sense to start with the smallest change :) In this specific case I think skipping the file is the way to go. This looks good.

vstinner reacted with thumbs up emoji

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

@pablogsalpablogsalpablogsal approved these changes

@gaogaotiantiangaogaotiantianAwaiting requested review from gaogaotiantiangaogaotiantian is a code owner

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.

3 participants
@vstinner@gaogaotiantian@pablogsal

[8]ページ先頭

©2009-2025 Movatter.jp