#28487 closed Bug (fixed)
runserver crashes with UncodeDecodeError as of Django 1.11.4
Reported by: | newerBkl | Owned by: | Mark Rogaski |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Mark Rogaski | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
My env is windows 7 x64 Python 2.7, after upgrade to 1.11.4 , i can't run manager.py runserver
In 1.11.3 is ok,anything with "Fixed crash in runserver’s autoreload with Python 2 on Windows with non-str environment variables (#28174)."
============================================================
(users) D:\django_test\dddd>pip install --upgrade django Collecting django Using cached Django-1.11.4-py2.py3-none-any.whl Requirement already up-to-date: pytz in d:\env_python\users\lib\site-packages (from django) Installing collected packages: django Found existing installation: Django 1.11.3 Uninstalling Django-1.11.3: Successfully uninstalled Django-1.11.3 Successfully installed django-1.11.4 (users) D:\django_test\dddd>python manage.py runserver Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "D:\env_python\users\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line utility.execute() File "D:\env_python\users\lib\site-packages\django\core\management\__init__.py", line 355, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "D:\env_python\users\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "D:\env_python\users\lib\site-packages\django\core\management\commands\runserver.py", line 62, in execute super(Command, self).execute(*args, **options) File "D:\env_python\users\lib\site-packages\django\core\management\base.py", line 330, in execute output = self.handle(*args, **options) File "D:\env_python\users\lib\site-packages\django\core\management\commands\runserver.py", line 101, in handle self.run(**options) File "D:\env_python\users\lib\site-packages\django\core\management\commands\runserver.py", line 110, in run autoreload.main(self.inner_run, None, options) File "D:\env_python\users\lib\site-packages\django\utils\autoreload.py", line 341, in main reloader(wrapped_main_func, args, kwargs) File "D:\env_python\users\lib\site-packages\django\utils\autoreload.py", line 312, in python_reloader exit_code = restart_with_reloader() File "D:\env_python\users\lib\site-packages\django\utils\autoreload.py", line 294, in restart_with_reloader str_value = force_bytes(new_environ[key], encoding=encoding) File "D:\env_python\users\lib\site-packages\django\utils\encoding.py", line 124, in force_bytes return s.decode('utf-8', errors).encode(encoding, errors) File "D:\env_python\users\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8 in position 202: invalid start byte
Attachments (1)
Change History (12)
follow-up: 2 comment:1 by , 7 years ago
Cc: | added |
---|---|
Summary: | Django1.11.4 Cannot run `manage.py runserver` on Windows (UnicodeDecodeError:) → runserver crashes with UncodeDecodeError as of Django 1.11.4 |
comment:2 by , 7 years ago
Replying to Tim Graham:
What's the key/value of the environment variable that's causing the crash?
I have no idea, it's just a new project without my own code and the traceback doesn't give me any ideas about the cause.
follow-up: 4 comment:3 by , 7 years ago
You can add print(key, new_environ[key])
before the line with force_bytes(new_environ[key], encoding=encoding)
to see the problematic value.
comment:4 by , 7 years ago
Replying to Tim Graham:
You can add
print(key, new_environ[key])
before the line withforce_bytes(new_environ[key], encoding=encoding)
to see the problematic value.
Thanks , here is the output
('TMP', 'C:\\Users\\100000\\AppData\\Local\\Temp') ('PSMODULEPATH', 'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\') ('PROCESSOR_LEVEL', '6') ('_OLD_VIRTUAL_PATH', 'C:\\Program Files (x86)\\Common Files\\NetSarang;C:\\Python27\\;C:\\Python27\\Scripts;C:\\Windows\\system32;C:\\Windows ;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\\xb8\xbb\xbb\xf9\xd0\xfd\xb7\xe7\xbf\xc 6\xbc\xbc\\appSys01;C:\\Program Files (x86)\\\xb8\xbb\xbb\xf9\xd0\xfd\xb7\xe7\xbf\xc6\xbc\xbc\\appSys02;C:\\Program Files (x86)\\\xb8\xbb\xbb\ xf9\xd0\xfd\xb7\xe7\xbf\xc6\xbc\xbc\\appSys01;C:\\Program Files (x86)\\\xb8\xbb\xbb\xf9\xd0\xfd\xb7\xe7\xbf\xc6\xbc\xbc\\appSys02;C:\\Program Files (x86)\\\xb8\xbb\xbb\xf9\xd0\xfd\xb7\xe7\xbf\xc6\xbc\xbc\\appSys03;C:\\Program Files\\TortoiseSVN\\bin;;C:\\Program Files\\Microsoft VS C ode\\bin') Traceback (most recent call last): .... UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8 in position 202: invalid start byte
there was a path with Chinese in my system_path. the Chinese is
C:\Program Files (x86)\富基旋风科技\appSys01
After removing ,it works well.By the way ,my system_encoding is cp936
by , 7 years ago
Attachment: | encoding.diff added |
---|
comment:5 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:7 by , 7 years ago
Has patch: | set |
---|
PR with the patch from Jacek Kałucki to alter force_bytes()
.
comment:8 by , 7 years ago
New PR that only touches the autoreloader instead of changing force_bytes()
.
comment:9 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
What's the key/value of the environment variable that's causing the crash?