Skip to content

gh-136061: IDLE - modernize idlelib code in editor.Editor.load_extension methodname processing - #134874

Open
johnzhou721 wants to merge 38 commits into
python:mainfrom
johnzhou721:idledos
Open

gh-136061: IDLE - modernize idlelib code in editor.Editor.load_extension methodname processing#134874
johnzhou721 wants to merge 38 commits into
python:mainfrom
johnzhou721:idledos

Conversation

@johnzhou721

@johnzhou721johnzhou721 commented May 29, 2025

Copy link
Copy Markdown
Contributor

A DOS by Quadratic complexity issue is fixed in idlelib. Part of (but does not fix) #134873.

@terryjreedyterryjreedy moved this to In Progress in IDLE IssuesMay 29, 2025
@terryjreedyterryjreedy self-assigned this May 29, 2025
@terryjreedy

Copy link
Copy Markdown
Member

I believe that the 6 lines from 1205 to 1210 can be replaced by 2 lines -- an re.match and an f-string. I will submit an alternate proposal later. I believe that the input vevent name should have either no <>s or 2 of each, with maybe the latter for back compatibility (I will test). But I will may stick with the more general code to not break buggy extensions.

@ZeroIntensityZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assuming this is the fix that we go with, let's add a test case.

Comment threadMisc/NEWS.d/next/Security/2025-05-29-03-24-18.gh-issue-134873.dziqkQ.rst Outdated
@ZeroIntensityZeroIntensity added type-security A security issue needs backport to 3.9 needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 29, 2025
@johnzhou721

johnzhou721 commented May 29, 2025 via email

Copy link
Copy Markdown
ContributorAuthor

Comment threadLib/idlelib/editor.py
@johnzhou721

johnzhou721 commented May 29, 2025 via email

Copy link
Copy Markdown
ContributorAuthor

@kexinoh

Copy link
Copy Markdown

@johnzhou721
I would greatly appreciate it if you could kindly address the issue located at

whileTrue:
chars=chars[:-1]
ncharsdeleted=ncharsdeleted+1
have=len(chars.expandtabs(tabwidth))
ifhave<=wantorchars[-1] notin" \t":
break
. I sincerely apologize for overlooking this in my previous message.

As an example, I successfully utilized Gemini 2.5 Pro to generate a reasonable fix for this problem. Could you give it a try?

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

@kexinoh Yes, I would give it a try once I have time; however, I am working on something else right now -- is it acceptable if I delay this by about a day or so?

(if anyone else has a fix ready before I get to this, feel free to make a pr onto the branch of my pr and I'll merge it into my PR)

…dziqkQ.rst
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

@kexinoh I have a small amount of time not enough to work on anything else before I end my day so I attempted the issue you pointed out -- but can't test though.

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

Assuming this is the fix that we go with, let's add a test case.

Where? How? For what? Thanks! @ZeroIntensity

@ZeroIntensity

Copy link
Copy Markdown
Member

Where? How? For what?

We need a test case in test_idlelib that results in DOS/extreme slowness off main. Basically, just do something to prove that this PR fixes it (probably just testing with large amounts of data).

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

I have made the requested changes; please review again

FYI: I credited @terryjreedy as well since they came up with the approach for combining it into all one line.

(@terryjreedy: not sure about your pronouns, sorry for using they)

@bedevere-app

Copy link
Copy Markdown

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@bedevere-app
bedevere-appBot requested a review from terryjreedyJune 29, 2025 13:08
@zware

Copy link
Copy Markdown
Member

@zware Do you have any idea what is wrong? Is the fact that johnzhou forked from somewhere else than python/cpython relevant?

My suspicion would be that the push to https:// is rejected; I seem to remember something about GitHub no longer accepting HTTPS pushes at all anymore, but I don't have a reference for that assertion. I'd try git push git@github.com:johnzhou721/cpython pr_134874:idledos instead.

Comment threadLib/idlelib/editor.py Outdated
Comment threadMisc/NEWS.d/next/IDLE/2025-06-28-13-29-52.gh-issue-136061.EQYuVW.rst Outdated
Comment threadLib/idlelib/News3.txt Outdated
johnzhou721and others added 2 commits June 30, 2025 11:55
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

Wow. Apparently I forgot to resolve a conversation.

Since this is finalized, merging main to retrigger this.

@terryjreedy Have you had time to rereview this yet? Thanks!

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

Hmm... apparently the labels in the sidebar is triggering the issue, not the Resolve Conversation on GitHub. Sorry for merging main again!

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

@terryjreedy Is there anything else I need to do to get this merged, or are you just busy? Thanks!

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

#136556 tracks the refactoring for the backspace part... I don't know if any information will need to be included there. The issue in its curretn form is quite vague and I am clueless about what to do.

@johnzhou721

Copy link
Copy Markdown
ContributorAuthor

@terryjreedy Is there any chance that you'd have time to look at this again? Thank you!

Comment threadLib/idlelib/editor.py
Comment threadLib/idlelib/News3.txt Outdated
@merwok

Copy link
Copy Markdown
Member

Can the PR title be changed to be more useful? Every PR is a change. Good titles say «Add thing to spam» or «Fix eggs with ham»

@johnzhou721johnzhou721 changed the title gh-136061: IDLE - update code in editor.Editor.load_extensiongh-136061: IDLE - modernize idlelib code in editor.Editor.load_extension methodname processingNov 4, 2025
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Apr 25, 2026
@serhiy-storchakaserhiy-storchaka added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 30, 2026
@github-actionsgithub-actionsBot removed the stale Stale PR or inactive for long period of time. label May 31, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting change reviewneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesneeds backport to 3.15pre-release feature fixes, bugs and security fixesskip news

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

9 participants

@johnzhou721@terryjreedy@kexinoh@ZeroIntensity@picnixz@zware@serhiy-storchaka@merwok@nazeerali4325-commits