Skip to content

Check against sys.executable when determining if we should instrument subprocess - #2065

Open
Philip DePetro (pdepetro) wants to merge 1 commit into
microsoft:mainfrom
pdepetro:main
Open

Check against sys.executable when determining if we should instrument subprocess#2065
Philip DePetro (pdepetro) wants to merge 1 commit into
microsoft:mainfrom
pdepetro:main

Conversation

@pdepetro

Copy link
Copy Markdown
Contributor

Native python binaries might not include 'python' in the file basename, causing the multiprocess monkey-patching code in pydevd to not recognize its subprocesses as python processes.

Add a fallback check against sys.executable in is_python() so that subprocesses launched via the same executable are correctly instrumented for debugging.

This is useful for custom Python builds or embedded distributions where the executable name doesn't contain 'python', 'jython', or 'pypy'.

… subprocess

Native python binaries might not include 'python' in the file
basename, causing the multiprocess monkey-patching code in pydevd to
not recognize its subprocesses as python processes.

Add a fallback check against sys.executable in is_python() so that
subprocesses launched via the same executable are correctly
instrumented for debugging.

This is useful for custom Python builds or embedded distributions
where the executable name doesn't contain 'python', 'jython', or
'pypy'.
@pdepetro
Philip DePetro (pdepetro) requested a review from a team as a code owner August 14, 2026 17:29
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@rchiodo

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@rchiodo

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR.

return True

if path == sys.executable:
return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Non-blocking recommendation

Raw equality accepts only the literal sys.executable spelling, so the same executable invoked through a symlink, relative path, or Windows case variation is still not recognized. Define whether this is intentionally an exact-path contract; if executable identity is intended, use a platform-aware path-equivalence check and cover alternate spellings.

return True

if path == sys.executable:
return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning · Non-blocking recommendation

Add a focused regression test that mocks an executable basename without python, jython, or pypy and verifies that is_python() recognizes it through sys.executable. The test should also establish the intended path-equivalence behavior.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@rchiodo Rich Chiodo (rchiodo) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

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

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants