Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-103997: Automatically dedent the argument to "-c"#103998
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
Conversation
bedevere-bot commentedApr 29, 2023
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
ghost commentedApr 29, 2023 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
71c6b63 to51c1320CompareErotemic commentedApr 30, 2023
I was able to cobble my way through the C docs and write what I think is a reasonable attempt at a pure C dedent function (I forgot how fun -- albiet time consuming --- pointer logic can be). To highlight some of the corner cases that need to be accounted for, this is the test case I'm using locally: I still haven't handled tabs, but I think my space logic is correct. I do need help vetting my C code and fixing the memory and security problems with it. |
Uh oh!
There was an error while loading.Please reload this page.
sunmy2019 commentedApr 30, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Delete all your Delete all your |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
sunmy2019 commentedMay 1, 2023
You should act fast since 3.12 release window will soon close. No new feature after May 8. Can you give me write access to your branch? |
Erotemic commentedMay 1, 2023
@sunmy2019 I gave you access to my cpython fork. |
sunmy2019 commentedMay 1, 2023
I got one thought:
It requires remembering the exact "space and tab prefix". Should we implement this? |
Erotemic commentedMay 1, 2023
Probably, but off the top of my head I'm not sure what the most elegant way to do it would be. I suppose instead of maintaining the tab and space counts, it would be sufficient to maintain the current shortest whitespace sequence, and then check how much of that sequence new lines match, shortening the sequence as necessary. I can give that a try. On a different note, I'm sure that new features will want tests associated with them, but I'm not sure where the other "-c" tests live. Do you know where the best spot to put tests would be? |
sunmy2019 commentedMay 1, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@Erotemic, take a look. I have implemented it with production quality atd336ac7. Edit your#103998 (comment) to make it clear and concise, so that we can attract more reviewers. |
sunmy2019 commentedMay 1, 2023
I guess |
sunmy2019 commentedMay 1, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We need someone with write access to review this. @vstinner as the recent maintainer of this file. |
📜🤖 Added by blurb_it.
Erotemic commentedApr 10, 2025
@AA-Turner CI issues have been resolved. Since this patch was last updated the "Core and Builtins" news section had spaces in its path name removed, so the file for this patch had to be moved to the new correct location. The other issue was a c compiler warning, which was elevated to an error by CI policy. The usage of |
AA-Turner left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This broadly looks fine to me, a minor suggestion on the test cases. I'll leave@methane or someone else to merge, though.
A
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
picnixz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please update therefcount.dat file (don't remember if it's in Tools, Doc or somewhere else).
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2023-04-29-23-15-38.gh-issue-103997.BS3uVt.rstShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2023-04-29-23-15-38.gh-issue-103997.BS3uVt.rstShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2023-04-29-23-15-38.gh-issue-103997.BS3uVt.rstShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
picnixz commentedApr 17, 2025
Ah, I've deleted a comment by mistake. My comment was about the construction |
sunmy2019 commentedApr 18, 2025
I have made the requested changes; please review again |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
methane left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
-c option in idle and pdb should be dedented too. But it can be separated PR.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2023-04-29-23-15-38.gh-issue-103997.BS3uVt.rstShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fc0ec29 intopython:mainUh oh!
There was an error while loading.Please reload this page.
sunmy2019 commentedApr 18, 2025
I overlooked this. I will check it later. |
picnixz commentedApr 18, 2025
It's fine, this is just for internal knowledge |
Uh oh!
There was an error while loading.Please reload this page.
This is an implementation of the idea proposed in#103997.
It intercepts the argument passed to
-c, and removes common leading whitespace from each line in the argument.Given an input string, the algorithm overview is:
pymain-run-commandfunction with that.Big thanks to@sunmy2019 who really helped clean this PR up.