peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 147 forks source link

Documentation bug: smart quotes #110

Closed coredumperror closed 8 years ago

coredumperror commented 9 years ago

On the PyPI page for bumpversion, the documented defaults for settings which take strings surround the strings with smartquotes. These can't be copied directly to a .bumpversion.cfg file because you'll get this error if you do so:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/bumpversion", line 11, in <module>
    sys.exit(main())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bumpversion/__init__.py", line 695, in main
    config.write(log_config)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 412, in write
    key = " = ".join((key, str(value).replace('\n', '\n\t')))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 0: ordinal not in range(128)

I would like to request that all these smart quotes (and other other non-ascii characters in the docs) be replaced with ascii-compatible characters.

EDIT: Unfortunately, after some more testing, it looks like this is actually PyPI's fault, rather than yours. Copying the default strings from the github display of the README gives real quotes. Maybe you could add some de-smartification code to the parser? Though that seems really silly.

TL;DR F*$% "smart" quotes.

coredumperror commented 9 years ago

Oh my, this is worse than I thought. After finally getting my .bumpversion.cfg file fully set up, I realized that quotes shouldn't be included in those settings at all, because they get included verbatim into the setting value. For example:

message = "Bumped version to 7.x-{new_version}"

That will cause the git commit message to be "Bumped version to 7.x-{new_version}", with the quotes around it. Thank goodness for --dry-run!

That seems like it probably shouldn't happen, especially since the documentation includes those quote marks.

peritus commented 9 years ago

Yes, you're right. Want to submit a pull request ?

That stack trace is probably a duplicate of #105, but we should probably include code in bumpversion itself to safeguard against that bug in configparser.

coredumperror commented 9 years ago

So I'm trying to put together a pull request to fix the unicode error, but the test framework itself seems to suffer from the same problem. I'm not familiar with tox and pytest, so I'm probably doing something wrong, but I can't get it to write out a .bumpversion.cfg that has smartquotes in it. The call to tmpdir.join(".bumpversion.cfg").write() fails with:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 114: ordinal not in range(128)

On another note, do you think it'd be better to update the documentation to remove the quotes, or update the parser to strip them? I this this is really a documentation bug hiding within this unicode problem, making itself look like a code bug.

peritus commented 9 years ago

@coredumperror The documentation is ambiguous, let's fix that. The test suite is in python, so it handles unicode the same way, yes. Lots of stuff is better in Python 3 :)

coredumperror commented 9 years ago

So what, if anything, can I do to make it possible to test unicode-containing config files in Python 2.7?

peritus commented 8 years ago

IIRC this is fixed in #112, if not please re-open.