Skip to content

[Bug] Loading env variables with trailing comments #24720

@HubertKozubek

Description

@HubertKozubek

Describe the bug
The debugger loads trailing comments when loading env variables form .env file

To Reproduce
Create .env file and test.py file

# .env
TEST_VAR = test # This comment will show up
# test.py
import os
from dotenv import load_dotenv

load_dotenv()
print(os.getenv("TEST_VAR"))
# python prints 'test'
# debugger prints 'test # This comment will show up'

Run the file, once with python, once using debugger

python -m venv venv && source venv/bin/activate && pip install python-dotenv
python test.py

when running with python the output looks like this:

test

when running with debugger the output looks like this:

test # This comment will show up

Expected behavior
The comment from .env file shouldn't be read as a part of variable when using the debugger

Environment:

  • OS: Ubuntu 22.04
  • Python: 3.12.2
  • Extension version: 2024.15.2024121701

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions