Change8

v1.2.3

📦 python-dotenvView on GitHub →
🐛 4 fixes🔧 5 symbols

Summary

This release addresses several bugs related to .env file parsing and manipulation. Key fixes include handling UTF-8 BOM, correctly escaping backslashes, improving error messages for `dotenv run`, and caching results for empty .env files.

🐛 Bug Fixes

  • Strip a leading UTF-8 BOM from .env file contents to prevent the first variable from being silently lost when the file is saved with BOM (e.g., by some JetBrains IDEs on Windows).
  • Escape backslashes in `set_key` to ensure values containing them (like Windows paths or regular expressions) survive a write/read round-trip. Previously, quoted values ending in an escaped backslash could be mis-parsed as an escaped quote, leading to swallowed lines.
  • Print a friendly error instead of a traceback when no command is given to `dotenv run`.
  • Cache the parsed result for empty .env files to avoid re-reading the file on repeated `dotenv_values`/`load_dotenv` calls.

Affected Symbols