Skip to content

Rewrite 'assert' statements as if/raise #7831

Description

@adamchainz

Checklist

Python's -O flag, enables "optimized mode" which, among other things, disables the assert statement. A naive user may activate it to try speed up their application. DRF has many uses of assert in its library code (not tests) to guard against bad conditions. Rewriting those assert statements as an if check and a raise of an appropriate exception would allow it to continue functioning in "optimized mode".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions