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

gh-103578: Fix pdb reading code with non-utf8 encoding #103581

Merged
merged 5 commits into from
Apr 26, 2023

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Apr 16, 2023

pdb should use io.open_code to open code to avoid encoding issue.

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!

We should probably mention in the news entry that because we use io.open_code, we'll now trigger auditing events hooks

@hauntsaninja hauntsaninja added the needs backport to 3.11 only security fixes label Apr 24, 2023
@gaogaotiantian
Copy link
Member Author

Thanks for this PR!

We should probably mention in the news entry that because we use io.open_code, we'll now trigger auditing events

io.open() also raise auditing events. According to the docs,

However, assuming that path is a str and an absolute path, open_code(path) should always behave the same as open(path, 'rb')

io.open_code() should behave the same as io.open(path, 'rb'), so is there an auditing event difference?

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Apr 24, 2023

Ah, I meant the PyFile_SetOpenCodeHook() hook from PEP 578. I'm not sure what the best phrase is, but it was described as auditing event in #17127. Maybe "auditing hook" as per the PEP?
(that PR got regressed in #26992, this PR fixes :-) )

@gaogaotiantian
Copy link
Member Author

So it seems like changing it to io.open_code() makes it possible to call into the hook set by PyFile_SetOpenCodeHook()? Is that something expected in the news entry?

@hauntsaninja
Copy link
Contributor

hauntsaninja commented Apr 24, 2023

Yup! I think can't hurt to mention it in the news entry, since it is a (good) change in behaviour and one that seems potentially noteworthy.

@gaogaotiantian
Copy link
Member Author

Yup! I think can't hurt to mention it in the news entry, since it is a (good) change in behaviour and one that seems potentially noteworthy.

I updated the news entry. Let me know if you think that requires extra polish!

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@hauntsaninja hauntsaninja merged commit 31acfd7 into python:main Apr 26, 2023
@miss-islington
Copy link
Contributor

Thanks @gaogaotiantian for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 26, 2023
…H-103581)

`pdb` should use `io.open_code` to open code to avoid encoding issue.
(cherry picked from commit 31acfd7)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
@bedevere-bot
Copy link

GH-103867 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Apr 26, 2023
@gaogaotiantian gaogaotiantian deleted the pdb-encoding-issue branch April 26, 2023 05:13
hauntsaninja pushed a commit that referenced this pull request Apr 26, 2023
) (#103867)

`pdb` should use `io.open_code` to open code to avoid encoding issue.
(cherry picked from commit 31acfd7)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
itamaro pushed a commit to itamaro/cpython that referenced this pull request Apr 26, 2023
…103581)

`pdb` should use `io.open_code` to open code to avoid encoding issue.
@zooba zooba added needs backport to 3.8 only security fixes needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Apr 27, 2023
@miss-islington
Copy link
Contributor

Thanks @gaogaotiantian for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @gaogaotiantian for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @gaogaotiantian for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @gaogaotiantian and @hauntsaninja, I had trouble checking out the 3.8 backport branch.
Please retry by removing and re-adding the "needs backport to 3.8" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 31acfd78a0810f84898d36a8289e407d3754b823 3.8

@miss-islington
Copy link
Contributor

Sorry, @gaogaotiantian and @hauntsaninja, I could not cleanly backport this to 3.9 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 31acfd78a0810f84898d36a8289e407d3754b823 3.9

@miss-islington
Copy link
Contributor

Sorry @gaogaotiantian and @hauntsaninja, I had trouble checking out the 3.10 backport branch.
Please retry by removing and re-adding the "needs backport to 3.10" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 31acfd78a0810f84898d36a8289e407d3754b823 3.10

@zooba zooba added needs backport to 3.10 only security fixes and removed needs backport to 3.10 only security fixes labels Apr 27, 2023
@miss-islington
Copy link
Contributor

Thanks @gaogaotiantian for the PR, and @hauntsaninja for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @gaogaotiantian and @hauntsaninja, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 31acfd78a0810f84898d36a8289e407d3754b823 3.10

@zooba zooba removed needs backport to 3.8 only security fixes needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Apr 27, 2023
@zooba
Copy link
Member

zooba commented Apr 27, 2023

No backport needed - this was fine in 3.8-3.10 and was regressed in 3.11.

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

Successfully merging this pull request may close these issues.

5 participants