gpt4 book ai didi

Django 1.11.7 - Django 压缩器 - 参数 5 : : expected LP_OVERLAPPED instance instead of pointer to OVERLAPPED

转载 作者:行者123 更新时间:2023-12-01 19:33:46 25 4
gpt4 key购买 nike

我正在尝试在我的 Windows 10 机器上启动并运行现有的 Django 1.11.7 (Python 3.5) 项目。设置好环境后,我现在可以在运行应用程序后看到主页,但是我访问的任何内部页面都会出现以下错误:
argument 5: <class 'TypeError'>: expected LP_OVERLAPPED instance instead of pointer to OVERLAPPED
我已经将其追溯到 compress.py(Django 压缩器)对一些压缩 CSS 文件的调用,以及 django.core 内部的一些 win32 文件锁定代码,特别是这一行:https://github.com/django/django/blob/master/django/core/files/locks.py#L86 (在下面的剪辑中解锁FileEx)。

class OVERLAPPED(Structure):
_anonymous_ = ['_offset_union']
_fields_ = [
('Internal', ULONG_PTR),
('InternalHigh', ULONG_PTR),
('_offset_union', _OFFSET_UNION),
('hEvent', HANDLE)]

LPOVERLAPPED = POINTER(OVERLAPPED)
....
def lock(f, flags):
hfile = msvcrt.get_osfhandle(_fd(f))
overlapped = OVERLAPPED()
ret = LockFileEx(hfile, flags, 0, 0, 0xFFFF0000, byref(overlapped))
return bool(ret)

def unlock(f):
hfile = msvcrt.get_osfhandle(_fd(f))
overlapped = OVERLAPPED()
ret = UnlockFileEx(hfile, 0, 0, 0xFFFF0000, byref(overlapped))
return bool(ret)

奇怪的是,在首页调用LockFileEx和UnlockFileEx方法都没有报错。在成功和不成功的电话中检查本地人一无所获。

堆栈跟踪以防它有帮助(更高的堆栈已编辑):
  File "C:\x\env\lib\site-packages\compressor\templatetags\compress.py", line 127, in render
return self.render_compressed(context, self.kind, self.mode, forced=forced)
File "C:\x\env\lib\site-packages\compressor\templatetags\compress.py", line 103, in render_compressed
rendered_output = compressor.output(mode, forced=forced)
File "C:\x\env\lib\site-packages\compressor\css.py", line 49, in output
ret.append(subnode.output(*args, **kwargs))
File "C:\x\env\lib\site-packages\compressor\css.py", line 51, in output
return super(CssCompressor, self).output(*args, **kwargs)
File "C:\x\env\lib\site-packages\compressor\base.py", line 292, in output
output = '\n'.join(self.filter_input(forced))
File "C:\x\env\lib\site-packages\compressor\base.py", line 232, in filter_input
for hunk in self.hunks(forced):
File "C:\x\env\lib\site-packages\compressor\base.py", line 215, in hunks
basename=basename)
File "C:\x\env\lib\site-packages\compressor\base.py", line 307, in handle_output
return output_func(mode, content, forced, basename)
File "C:\x\env\lib\site-packages\compressor\base.py", line 319, in output_file
self.storage.save(new_filepath, ContentFile(content.encode(self.charset)))
File "C:\x\env\lib\site-packages\django\core\files\storage.py", line 54, in save
return self._save(name, content)
File "C:\x\env\lib\site-packages\django\core\files\storage.py", line 357, in _save
locks.unlock(fd)
File "C:\x\env\lib\site-packages\django\core\files\locks.py", line 86, in unlock
ret = UnlockFileEx(hfile, 0, 0, 0xFFFF0000, byref(overlapped))

使用锁定/解锁的文件似乎是静态 CSS 文件。 JS 和 LESS 都是抛出上述异常的。如果有帮助的话,该项目似乎对 CSS 和 JS 过滤器都使用了 yuglify。

最佳答案

就我而言,这是由于与 youtube-dl 包的冲突,该包具有与 django-compressor 包类似的类、变量和方法。我能够通过在两种情况下“破解”各种 token 的名称来确认这一点,从而导致错误 argument 5: <class 'TypeError'>: expected LP_OVERLAPPED2 instance instead of pointer to OVERLAPPED3
我现在已经从我的环境中删除了 youtube-dl 包,作为在我的本地开发环境中运行它的临时解决方案。

关于Django 1.11.7 - Django 压缩器 - 参数 5 : <class 'TypeError' >: expected LP_OVERLAPPED instance instead of pointer to OVERLAPPED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50337960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com