Opened 6 years ago
Last modified 6 years ago
#30184 closed Bug
Django 2.2b1 throws error on Windows in default code page — at Version 1
Reported by: | Dan Davis | Owned by: | Dan Davis |
---|---|---|---|
Component: | Core (Management commands) | Version: | 2.2 |
Severity: | Normal | Keywords: | |
Cc: | jon.dufresne@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
By default, Windows terminals start with code page 437, which is roughly equivalent to ASCII. While working on #30178, I discovered that this causes the following traceback:
(mplusmon) λ manage.py runserver Watchman unavailable: pywatchman not installed. Watching for file changes with StatReloader Exception in thread Thread-1: Traceback (most recent call last): File "c:\tools\python\3.5\Lib\threading.py", line 914, in _bootstrap_inner self.run() File "c:\tools\python\3.5\Lib\threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run self.stdout.write("Performing system checks\u2026\n\n") File "C:\Users\davisda4\PythonEnvs\mplusmon\lib\site-packages\django\core\management\base.py", line 145, in write self._out.write(style_func(msg)) File "C:\Users\davisda4\PythonEnvs\mplusmon\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2026' in position 24: character maps to <undefined>
A workaround is to change the code page to UTF-8, as follows:
chcp 65001
This appears to be a new issue relative to Django 2.1.7, because the problem did not occur there. I'll track down wherever someone entered the horizontal elipsis character rather than "..." into the code, because this ought to be easy enough to fix. Whomever did this was probably not even aware of it and it has worked well enough since almost all Django developers will use MacOS or Linux.