Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Modernize Code In IDLELib Editor Backspace (and potentially deprecate handling of tabs in IDLE) #136556

Open
Labels
stdlibPython modules in the Lib dirtopic-IDLEtype-featureA feature request or enhancement
@johnzhou721

Description

@johnzhou721

In#136061,

# Ick. It may require *inserting* spaces if we back up over a
# tab character! This is written to be clear, not fast.
tabwidth=self.tabwidth
have=len(chars.expandtabs(tabwidth))
asserthave>0
want= ((have-1)//self.indentwidth)*self.indentwidth
# Debug prompt is multilined....
ncharsdeleted=0
whileTrue:
chars=chars[:-1]
ncharsdeleted=ncharsdeleted+1
have=len(chars.expandtabs(tabwidth))
ifhave<=wantorchars[-1]notin"\t":
break
text.undo_block_start()
text.delete("insert-%dc"%ncharsdeleted,"insert")
ifhave<want:
text.insert("insert",' '* (want-have),
self.user_input_insert_tags)
text.undo_block_stop()
return"break"
is mentioned as an area of code with quadratic complexity, which may lead to performance issues; though this is unlikely to be of large impact in practice because attackers with the ability to get a huge file loaded and/or modify configuration files to change the tab width can do much worse things than getting IDLE to hang on hitting backspace.

However, the complexity there comes from a loop which handles situations (files with tabs) that either cannot or should not occur; in the current default IDLE, you can't put tabs, and a space after a tab should just be deleted in a file coming from elsewhere as in indicated in#134874 (comment). Therefore, simplifying the function specification and/or deprecating IDLE to handle tabs (which we should do) will allow elimination of this piece of obsolete code, as indicated in#136061 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-IDLEtype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp