Skip to content
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

Preserve encoding with edit_config #1729

Closed
wants to merge 1 commit into from

Conversation

itsadok
Copy link

@itsadok itsadok commented Mar 30, 2019

PR #1180 and 24be5ab changed the way we read setup.cfg, but when
editing setup.cfg we might still lose the encoding hint on the file,
which can cause failures in subsequent steps.
This change detectes the encoding like in _parse_config_files and
writes an encoding hint header if the file encoding was detected.
Fixes jaraco/configparser#37.

@itsadok itsadok force-pushed the preserve_encoding branch from 7401ecd to a812b37 Compare March 31, 2019 07:12
@itsadok
Copy link
Author

itsadok commented Mar 31, 2019

Wrapped io.open with try-catch IOError, to better match the behavior of ConfigParser.read()

PR pypa#1180 and 24be5ab changed the way we read setup.cfg, but when
editing setup.cfg we might still lose the encoding hint on the file,
which can cause failures in subsequent steps.
This change detectes the encoding like in `_parse_config_files` and
writes an encoding hint header if the file encoding was detected.
Fixes jaraco/configparser#37.
@itsadok itsadok force-pushed the preserve_encoding branch from a812b37 to 06c89b5 Compare April 2, 2019 12:47
@jaraco
Copy link
Member

jaraco commented Apr 2, 2019

See #1702, where I'm proposing a somewhat different approach. Instead of investing more heavily in encoding declarations on a file, I'd rather standardize on UTF-8 as the sole encoding for the file.

@itsadok
Copy link
Author

itsadok commented Apr 2, 2019

OK, yeah. My code doesn't work, as I couldn't find a way to make Python 2.7's ConfigParser write UTF-8.
It would be much simpler to ignore encoding completely here, and assume UTF-8 in _parse_config_py. I'm closing this PR.

@itsadok itsadok closed this Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants