[英]Mysterious “embedded null byte” error
Working on a fairly large/complex Django project with a team, we occasionally see runserver crash with ValueError: embedded null byte
. 在团队中处理一个相当大/复杂的Django项目时,我们偶尔会看到带有
ValueError: embedded null byte
runserver崩溃ValueError: embedded null byte
。 We restart runserver and it's fine - either for a few minutes or a few days. 我们重新启动runserver,它很好 - 无论是几分钟还是几天。 We can detect no pattern to what causes the crashes (seems totally random).
我们可以检测到没有导致崩溃的模式(似乎完全随机)。 Fortunately it's only happening in local development, not on our servers, but I'm worried that it will bite us down the road.
幸运的是,它只发生在本地开发中,而不是发生在我们的服务器上,但我担心它会让我们陷入困境。
The stack trace below does not point to any location in our code -- seems to come either from Django or the virtualenv itself. 下面的堆栈跟踪并未指向我们代码中的任何位置 - 似乎来自Django或virtualenv本身。
Using Django 1.9.8, Python 3.5.0, on El Capitan. 在El Capitan上使用Django 1.9.8,Python 3.5.0。
I can't see any way to debug this. 我看不出任何调试方法。 Theories?
理论?
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 54, in execute
super(Command, self).execute(*args, **options)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 93, in handle
self.run(**options)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.main(self.inner_run, None, options)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/utils/autoreload.py", line 333, in main
reloader(wrapped_main_func, args, kwargs)
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/utils/autoreload.py", line 299, in python_reloader
reloader_thread()
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/utils/autoreload.py", line 275, in reloader_thread
change = fn()
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/utils/autoreload.py", line 204, in code_changed
for filename in gen_filenames():
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/utils/autoreload.py", line 114, in gen_filenames
basedirs = [os.path.abspath(basedir) for basedir in basedirs
File "/path/to/virtualenvs/ourproj/lib/python3.5/site-packages/django/utils/autoreload.py", line 115, in <listcomp>
if os.path.isdir(basedir)]
File "/path/to/virtualenvs/ourproj/bin/../lib/python3.5/genericpath.py", line 42, in isdir
st = os.stat(s)
ValueError: embedded null byte
AppConfig
objects has null byte in its path
attribute. AppConfig
对象的path
属性中包含空字节。 LOCALE_PATHS
has null byte. LOCALE_PATHS
具有空字节。 AppConfig.path
). AppConfig.path
)。 \\x00
) in its name. \\x00
)。 autoreload.py
lines related to this issue. 与此问题相关的
autoreload.py
行 。 os.path.isdir()
raises ValueError: embedded null byte
if its argument has null byte, eg os.path.isdir('foo\\x00bar')
. os.path.isdir()
引发ValueError: embedded null byte
如果其参数具有空字节,则为ValueError: embedded null byte
,例如os.path.isdir('foo\\x00bar')
。
You can try to edit autoreload.py
, comment out these lines temporarily: 您可以尝试编辑
autoreload.py
,暂时注释掉这些行:
basedirs = [os.path.abspath(basedir) for basedir in basedirs
if os.path.isdir(basedir)]
and add this: 并添加这个:
temp_basedirs = []
for basedir in basedirs:
try:
if os.path.isdir(basedir):
temp_basedirs.append(os.path.abspath(basedir))
except ValueError:
print(basedir)
raise
basedirs = temp_basedirs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.