Skip to content

IDLE: Wrong highlighting when previous line ends with backslash #140334

Description

@TheLizzard

Bug report

Bug description:

Code like this

str. \
    format

should be coloured the same way as

str.format

Right now IDLE doesn't respect the slash before the newline and thinks that every new line is a new statement.

Similarly in:

x = match if match else \
                   match

The last match should be coloured in like a variable and not a keyword.

Image

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. TheLizzard commented on Oct 19, 2025

    @TheLizzard
    Author

    I found exactly where the problem is coming from (Lib/idlelib/colorizer.py@make_pat) and I have a solution that passes all tests. I am working a pull request.

  2. changed the title [-]IDLE: Wrong highlighting when previous line ends with slash[/-] [+]IDLE: Wrong highlighting when previous line ends with backslash[/+] on Oct 19, 2025
  3. terryjreedy commented on Oct 20, 2025

    @terryjreedy
    Member

    @TheLizzard Thank you for a definitely non trivial patch. Will test when I can before looking at Stan's alternative.

    @StanFromIreland When I merged to patch to support t-strings, I thought about using the new tokenizer and associated PyREPL code. I made a new issue for this and changed your PR to attach it there.

  4. StanFromIreland commented on Oct 20, 2025

    @StanFromIreland
    Member

    I think we can merge the patch first, and then look at the larger issue.

  5. removed
    stdlibStandard Library Python modules in the Lib/ directory
    on Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-IDLEtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions