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

Appearance settings

Improve permission error messages in pdb and asyncio.tools #134290

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from

Conversation

ivonastojanovic
Copy link
Contributor

This PR enhances the user experience when a PermissionError occurs while attempting to attach to a process using pdb -p or tools like asyncio ps and asyncio pstree. It adds platform-specific guidance for Linux, macOS, and Windows to help users understand why the operation failed and how to resolve it (e.g., using sudo, adjusting system settings, or enabling debugging privileges).

Currently, the same logic is duplicated in both pdb and asyncio.tools. If anyone has recommendations on how to avoid this duplication, I’d appreciate input. I couldn't find a clear shared location in the standard library where this kind of utility logic would belong.

Add help texts for Linux, macOS, and Windows to guide users in
resolving permission errors when attaching to a process using the
-p option.
Add platform-specific guidance to help users resolve permission errors
when inspecting running processes with asyncio.tools.
@ivonastojanovic ivonastojanovic force-pushed the permission_error_message branch from 2b62a35 to 6101e33 Compare May 19, 2025 21:57
@ivonastojanovic
Copy link
Contributor Author

CC @pablogsal

This function is called when a PermissionError is encountered while trying
to attach to a process.
"""
system = platform.system()
Copy link
Contributor

Choose a reason for hiding this comment

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

sys is already imported, so you can use sys.platform

@gaogaotiantian
Copy link
Member

gaogaotiantian commented May 21, 2025

Should this live in the code? I think this should live in the docs and we should just print a link for it. This documentation should probably live with sys.remote_exec. We don't want to duplicate this everywhere that uses sys.remote_exec(). I don't think we should have this big chunk of clearly documentation in the code itself.

@pablogsal
Copy link
Member

pablogsal commented May 21, 2025

Should this live in the code? I think this should live in the docs and we should just print a link for it.

I think so. We want to provide actionable output to the users right where the error happens and not just in the docs. We could put it somewhere in the docs and drop a link there though although I think that is slight worse experience. But I don't feel very strongly

@gaogaotiantian
Copy link
Member

I think this is too much text living in the code - especially with multiple copies. If we have a third library that utilizes sys.remote_exec, are we going to replicate the whole text again? Under the hood, this is an issue with sys.remote_exec, not the modules that use it. For users that use sys.remote_exec directly, they'll still be confused.

I suggest that we put a link to the docs in the PermissionError itself as a message, so it would be simply shown in the traceback.

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

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.