Skip to content

PYTHONDONTWRITEBYTECODE documentation is incorrect #143134

@mikekaganski

Description

@mikekaganski

Documentation

PYTHONDONTWRITEBYTECODE is documented in Doc/using/cmdline.rst as:

If this is set to a non-empty string, Python won't try to write .pyc files on the import of source modules.

This is incorrect. The variable is obtained in Python/initconfig.c as:

    int dont_write_bytecode = 0;
    _Py_get_env_flag(use_env, &dont_write_bytecode, "PYTHONDONTWRITEBYTECODE");
    if (dont_write_bytecode) {
        config->write_bytecode = 0;
    }

and _Py_get_env_flag reads the environment variable value as integer, treating non-integer string as 1. Specifically, this means that PYTHONDONTWRITEBYTECODE=0 will not suppress writing .pyc files, even though the environment variable is assigned a non-empty string "0".

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions