Skip to content

Treat bytes objects as immutable in C code #155742

Description

@vstinner

Currently, in the CPython C code, multiple functions treat bytes objects as mutable. For example, they use char* to access their data, instead of const char*.

In the worst case, it can lead to bad bugs like issue gh-155702 in sqlite3 which modifies an immutable bytes object.

Some functions can be rewritten using PyBytesWriter C API to avoid that.

Linked PRs

Activity

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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-refactorCode refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions