Mysterious “embedded null byte” error

前端 未结 1 1378
耶瑟儿~
耶瑟儿~ 2021-01-19 00:59

Working on a fairly large/complex Django project with a team, we occasionally see runserver crash with ValueError: embedded null byte. We restart runserver and

相关标签:
1条回答
  • 2021-01-19 01:28
    • One of the AppConfig objects has null byte in its path attribute.
    • One of the LOCALE_PATHS has null byte.
    • One of the files is in the "wrong" encoding, so Django treats something has null byte (e. g. AppConfig.path).
    • One of the files or directories in project directory has null byte (\x00) in its name.
    • Other reason.

    autoreload.py lines related to this issue. os.path.isdir() raises ValueError: embedded null byte if its argument has null byte, e. g. os.path.isdir('foo\x00bar').

    You can try to edit autoreload.py, comment out these lines temporarily:

    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
    
    0 讨论(0)
提交回复
热议问题