-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor parser to fix inconsistencies #180
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using `str` (e.g. `bytes`) is inconsistent with the types and the implementation.
This fixes inconsistencies reported after the release of version 0.10.0: * Valid escapes were interpreted as control characters even when in single-quoted strings. * `#` was interpreted as the start of a comment even if there was no whitespace preceding it. However, we are keeping the interpretation of escapes in double-quoted strings as they didn't make sense in versions before 0.10.0. The single large regular expression is replaced with a handwritten top-down parser using smaller regular expressions. The reason for this change is that it would have been very difficult or impossible to satisfy the parsing requirements with a single regex.
1 similar comment
I really liked the top-down parser approach, it will be a lot easier to maintain and debug now. Reviewed the code and it all look great! Thank you so much! |
theskumar
approved these changes
May 22, 2019
Would this be applicable to the behavior I'm seeing in pypa/pipenv#3757 with dotenv (by way of pipenv)? Will gladly open a new issue if not. |
Yes, I believe we fixed the double-escaping issue in 0.10.0. See #170 for more information. |
theskumar
pushed a commit
that referenced
this pull request
Jun 2, 2019
* master: (49 commits) Fix typo in README.md (#181) Refactor move run_command in cli Refractor: move 'to_env' to compat.py Refactor parser to fix inconsistencies (#180) chore(pypi): switch to markdown and twine for pypi upload + update supported version Bump version: 0.10.1 → 0.10.2 readme: Add new release stub Fix unicode/str inconsistency in Python 2 (#177) Add argument to choose .env file encoding, defaults to None Fix links in readme Restrict typing dependency to Python < 3.5 Add type hints and expose them to users Updated `.gitignore` with results from https://www.gitignore.io/api/python Added special case for `__file__` in Python 2. Fixes #130 Updated tests to show that this works. Moved `dotenv` package into `src` directory so that tests run against installed version. Added tox to run test suite against multiple versions of Python (with coverage) and run flake8. Updated Travis CI to use tox as well. Updated documentation about running tests. Fix ResourceWarning: unclosed file in setup.py and test_cli.py Clarify the usuages of export Isolate test files (#160) Deleted some temporary files that CLI tests were creating. Add python 3.7 to testsuite + udpate pypi creds ...
johnbergvall
pushed a commit
to johnbergvall/python-dotenv
that referenced
this pull request
Aug 13, 2021
* Move parser to separate module * Add tests * Use unicode strings for unit tests in Python 2 Using `str` (e.g. `bytes`) is inconsistent with the types and the implementation. * Refactor parser This fixes inconsistencies reported after the release of version 0.10.0: * Valid escapes were interpreted as control characters even when in single-quoted strings. * `#` was interpreted as the start of a comment even if there was no whitespace preceding it. However, we are keeping the interpretation of escapes in double-quoted strings as they didn't make sense in versions before 0.10.0. The single large regular expression is replaced with a handwritten top-down parser using smaller regular expressions. The reason for this change is that it would have been very difficult or impossible to satisfy the parsing requirements with a single regex.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes inconsistencies reported after the release of version 0.10.0 (comments in #148):
#
was interpreted as the start of a comment even if there was no whitespace preceding it.However, we are keeping the interpretation of escapes in double-quoted strings as they didn't make sense in versions before 0.10.0.
The single large regular expression is replaced with a handwritten top-down parser using smaller regular expressions. The reason for this change is that it would have been very difficult or impossible to satisfy the parsing requirements with a single regex.
See individual commits to understand the changes better.
Fixes #170.