title: Mysterious "embedded null byte" error
body: <p>Working on a fairly large/complex Django project with a team, we occasionally see runserver crash with <code>ValueError: embedded null byte</code>. We restart runserver and it's fine - either for a few minutes or a few days. 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.</p>
  
  <p>The stack trace below does not point to any location in our code -- seems to come either from Django or the virtualenv itself.</p>
  
  <p>Using Django 1.9.8, Python 3.5.0, on El Capitan. </p>
  
  <p>I can't see any way to debug this. Theories? </p>
  
  <pre><code>Traceback (most recent call last):
    File "manage.py", line 10, in &lt;module&gt;
      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 &lt;listcomp&gt;
      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
  </code></pre>