Skip to content

Replace read_str_coding to use tokenize.detect_encoding() #975

Backlog

Description

@lieryan

Description

Rewrite rope.base.fscommands.{unicode_to_file_data,file_data_to_unicode} and rope.base.resources to use tokenize.open()/detect_encoding().

Currently, we do some regex mucking to parse the encoding cookie. tokenize.open() is a documented way in the stdlib to open and decode a file with coding cookie and also handles BOM.

Open issue:

  • tokenize.detect_encoding() would raise syntax error on a file that has a BOM that doesn't match their coding cookie, should rope behave the same or should we attempt to be more tolerant of such ambiguities?

Activity

  1. added
    cleanup
    on Nov 27, 2026
  2. added theissue type on Nov 27, 2026
  3. RajvanshSingh4 commented on Nov 27, 2026

    @RajvanshSingh4

    /assign

  4. lieryan commented on Nov 28, 2026

    @lieryan
    MemberAuthor

    related: #966

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

    cleanupgood first issue

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions