Opened 17 years ago
Closed 17 years ago
#5867 closed (invalid)
Python default encoding would be _really_ useful in Unicode documentation
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | unicode default encoding | |
Cc: | develbob@… | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
While upgrading Django we collided upon a numberous amount of Unicode errors only to find, after looking for a long time, that there was a simple and easy way out; by setting the default encoding for Python. This can simple be done by dropping the following snipplet somewhere in the Python path:
# sitecustomize.py # this file can be anywhere in your Python path, # but it usually goes in ${pythondir}/lib/site-packages/ import sys sys.setdefaultencoding('iso-8859-1')
We feel that it would be really useful to mention this in the Unicode page of the Django documentation. The script itself we have found on http://www.diveintopython.org/xml_processing/unicode.html.
Change History (2)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Firstly, this is not a good idea. It's not recommended by the Python maintainers, for a start. I consider it a bug in "Dive Into Python" that it's recommended there, since as soon as you start making changes like this, your code becomes non-portable.
Secondly, this isn't a bug in Django.
Ugh. That causes *serious* problems. Guess why site.py *removes* setdefaultencoding...