{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \r\n\r\n\"\"\"\r\n\r\n\r\n@app.get(\"/\")\r\nasync def get():\r\n return HTMLResponse(html)\r\n\r\n\r\nasync def get_cookie_or_client(\r\n websocket: WebSocket, session: str = Cookie(None), x_client: str = Header(None)\r\n):\r\n if session is None and x_client is None:\r\n await websocket.close(code=WS_1008_POLICY_VIOLATION)\r\n return session or x_client\r\n\r\n\r\n@app.websocket(\"/items/{item_id}/ws\")\r\nasync def websocket_endpoint(\r\n websocket: WebSocket,\r\n item_id: int,\r\n q: str = None,\r\n cookie_or_client: str = Depends(get_cookie_or_client),\r\n):\r\n await websocket.accept()\r\n while True:\r\n data = await websocket.receive_text()\r\n await websocket.send_text(\r\n f\"Session Cookie or X-Client Header value is: {cookie_or_client}\"\r\n )\r\n if q is not None:\r\n await websocket.send_text(f\"Query parameter q is: {q}\")\r\n await websocket.send_text(f\"Message text was: {data}, for item ID: {item_id}\")\r\n``` \r\n2. Run the application with the cmd:\r\n```\r\nuvicorn main:app --log-level debug --reload\r\n```\r\n3. Open the browser 127.0.0.01\r\n - the first time i connect with ItemID foo , press the button connect \r\n - send message hi with ItemID foo and press the button send.\r\n it's look like the connect fail but the second ,but the send have return code 200\r\n but nothing happen on the web side. \r\n\r\n![image](https://user-images.githubusercontent.com/52538873/60673629-db137a00-9e80-11e9-8a6b-8246e5297277.png)\r\n\r\n4. See error\r\n```python\r\n\r\nINFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\r\nINFO: Started reloader process [366952]\r\nemail-validator not installed, email fields will be treated as str.\r\nTo install, run: pip install email-validator\r\nINFO: Started server process [366957]\r\nINFO: Waiting for application startup.\r\nDEBUG: None - ASGI [1] Started\r\nDEBUG: None - ASGI [1] Sent {'type': 'lifespan.startup'}\r\nDEBUG: None - ASGI [1] Received {'type': 'lifespan.startup.complete'}\r\nDEBUG: ('127.0.0.1', 50056) - Connected\r\nDEBUG: server - state = CONNECTING\r\nDEBUG: server - event = connection_made()\r\nDEBUG: ('127.0.0.1', 50056) - ASGI [2] Started\r\nDEBUG: ('127.0.0.1', 50056) - ASGI [2] Received {'type': 'websocket.close', 'code': 1008}\r\nINFO: ('127.0.0.1', 50056) - \"WebSocket /items/foo/ws\" 403\r\nDEBUG: ('127.0.0.1', 50056) - ASGI [2] Raised exception\r\nERROR: Exception in ASGI application\r\nTraceback (most recent call last):\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py\", line 147, in run_asgi\r\n result = await self.app(self.scope, self.asgi_receive, self.asgi_send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py\", line 58, in __call__\r\n raise exc from None\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py\", line 54, in __call__\r\n await self.app(scope, inner_receive, inner_send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/applications.py\", line 133, in __call__\r\n await self.error_middleware(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/middleware/errors.py\", line 87, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/exceptions.py\", line 49, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 585, in __call__\r\n await route(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 265, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 56, in app\r\n await func(session)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/fastapi/routing.py\", line 148, in app\r\n await websocket.close(code=WS_1008_POLICY_VIOLATION)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/websockets.py\", line 121, in close\r\n await self.send({\"type\": \"websocket.close\", \"code\": code})\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/websockets.py\", line 70, in send\r\n raise RuntimeError('Cannot call \"send\" once a close message has been sent.')\r\nRuntimeError: Cannot call \"send\" once a close message has been sent.\r\nDEBUG: server ! failing WebSocket connection in the CONNECTING state: 1006 [no reason]\r\nDEBUG: ('127.0.0.1', 50058) - Connected\r\nDEBUG: server x half-closing TCP connection\r\nDEBUG: ('127.0.0.1', 50058) - ASGI [3] Started\r\nDEBUG: ('127.0.0.1', 50058) - ASGI [3] Received {'type': 'http.response.start', 'status': 200, 'headers': '<...>'}\r\nINFO: ('127.0.0.1', 50058) - \"GET / HTTP/1.1\" 200\r\nDEBUG: ('127.0.0.1', 50058) - ASGI [3] Received {'type': 'http.response.body', 'body': '<1419 bytes>'}\r\nDEBUG: ('127.0.0.1', 50058) - ASGI [3] Completed\r\nDEBUG: server - event = eof_received()\r\nDEBUG: server - event = connection_lost(None)\r\nDEBUG: server - state = CLOSED\r\nDEBUG: server x code = 1006, reason = [no reason]\r\nDEBUG: ('127.0.0.1', 50058) - Disconnected\r\nDEBUG: ('127.0.0.1', 50060) - Connected\r\nDEBUG: ('127.0.0.1', 50060) - ASGI [4] Started\r\nDEBUG: ('127.0.0.1', 50060) - ASGI [4] Received {'type': 'http.response.start', 'status': 200, 'headers': '<...>'}\r\nINFO: ('127.0.0.1', 50060) - \"GET / HTTP/1.1\" 200\r\nDEBUG: ('127.0.0.1', 50060) - ASGI [4] Received {'type': 'http.response.body', 'body': '<1419 bytes>'}\r\nDEBUG: ('127.0.0.1', 50060) - ASGI [4] Completed\r\nDEBUG: ('127.0.0.1', 50060) - Disconnected\r\n\r\n\r\n```\r\n**Expected behavior**\r\nexpected to appear the send bold message on the web page.\r\n\r\n**Environment:**\r\n - OS: centos 7\r\n - FastAPI Version [e.g. 0.3.0], get it with: fastapi==0.31.0\r\n\r\n```Python\r\nimport fastapi\r\nprint(fastapi.__version__)\r\n0.31.0\r\n```\r\n\r\n- Python version, get it with:\r\n\r\n```bash\r\npython --version\r\nPython 3.7.3\r\n```\r\n\r\n\n"},"hints_text":{"kind":"string","value":"@BenjPy ,\r\nJust add `event.preventDefault()` in the beginning of `connect` js function.\r\nThe problem here is when you are trying to make websocket connection, browser refreshes page and closes websocket connection.\r\nSo `connect` function should looks like this:\r\n```\r\nfunction connect(event) {\r\n event.preventDefault()\r\n var input = document.getElementById(\"itemId\")\r\n ws = new WebSocket(\"ws://localhost:8000/items/\" + input.value + \"/ws\");\r\n ws.onmessage = function(event) {\r\n var messages = document.getElementById('messages')\r\n var message = document.createElement('li')\r\n var content = document.createTextNode(event.data)\r\n message.appendChild(content)\r\n messages.appendChild(message)\r\n };\r\n}\r\n```\n@alj06ka ,\r\nstill nothing appear , when added the line on the web page\r\nit's look like the first time the Websocket fail to connect\r\n\r\nsee on below the js code\r\n```js\r\nhtml = \"\"\"\r\n\r\n\r\n \r\n Chat\r\n \r\n \r\n

WebSocket Chat

\r\n
\r\n \r\n \r\n
\r\n \r\n \r\n
\r\n
    \r\n
\r\n \r\n \r\n\r\n\"\"\"\r\n```\r\n### see the log on below\r\n```bash\r\nINFO: ('127.0.0.1', 59388) - \"WebSocket /items/foo/ws\" 403\r\nDEBUG: ('127.0.0.1', 59388) - ASGI [13] Raised exception\r\nERROR: Exception in ASGI application\r\nTraceback (most recent call last):\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py \", line 147, in run_asgi\r\n result = await self.app(self.scope, self.asgi_receive, self.asgi_send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py\", line 58, in __call__\r\n raise exc from None\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py\", line 54, in __call__\r\n await self.app(scope, inner_receive, inner_send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/applications.py\", line 133, in __call __\r\n await self.error_middleware(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/middleware/errors.py\", line 87, in __ call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/exceptions.py\", line 49, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 585, in __call__\r\n await route(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 265, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 56, in app\r\n await func(session)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/fastapi/routing.py\", line 148, in app\r\n await websocket.close(code=WS_1008_POLICY_VIOLATION)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/websockets.py\", line 121, in close\r\n await self.send({\"type\": \"websocket.close\", \"code\": code})\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/websockets.py\", line 70, in send\r\n raise RuntimeError('Cannot call \"send\" once a close message has been sent.')\r\nRuntimeError: Cannot call \"send\" once a close message has been sent.\r\nDEBUG: server ! failing WebSocket connection in the CONNECTING state: 1006 [no reason]\r\nDEBUG: server x half-closing TCP connection\r\nDEBUG: server - event = eof_received()\r\nDEBUG: server - event = connection_lost(None)\r\nDEBUG: server - state = CLOSED\r\nDEBUG: server x code = 1006, reason = [no reason]\r\nDEBUG: ('127.0.0.1', 59390) - Connected\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [14] Started\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [14] Received {'type': 'http.response.start', 'status': 200, 'headers': '<...>'}\r\nINFO: ('127.0.0.1', 59390) - \"GET / HTTP/1.1\" 200\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [14] Received {'type': 'http.response.body', 'body': '<1458 bytes>'}\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [14] Completed\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [15] Started\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [15] Received {'type': 'http.response.start', 'status': 200, 'headers': '<...>'}\r\nINFO: ('127.0.0.1', 59390) - \"GET / HTTP/1.1\" 200\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [15] Received {'type': 'http.response.body', 'body': '<1458 bytes>'}\r\nDEBUG: ('127.0.0.1', 59390) - ASGI [15] Completed\r\nDEBUG: ('127.0.0.1', 59390) - Disconnected\r\nDEBUG: ('127.0.0.1', 59448) - Connected\r\nDEBUG: ('127.0.0.1', 59448) - ASGI [16] Started\r\nDEBUG: ('127.0.0.1', 59448) - ASGI [16] Received {'type': 'http.response.start', 'status': 200, 'headers': '<...>'}\r\nINFO: ('127.0.0.1', 59448) - \"GET / HTTP/1.1\" 200\r\nDEBUG: ('127.0.0.1', 59448) - ASGI [16] Received {'type': 'http.response.body', 'body': '<1458 bytes>'}\r\nDEBUG: ('127.0.0.1', 59448) - ASGI [16] Completed\r\n\r\n```\r\n\r\n\n@BenjPy ,\r\nLooks like this window is still reloading...\r\nActually, I think, that separation onto two forms will help you:\r\n```\r\n
\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n```\r\nIt's not a good way, but it's okay to try out websockets.\n@alj06ka ,\r\nHi, still nothing appear on the web page.\n@BenjPy ,\r\nHi, actually, problem was not in page reloading. I find out, that this example shows how to pass cookie or header params as well. So, you can see dependency `cookie_or_client`. It means, that you must pass `session` param in `Cookie`, or `x-client` param in `Header` on websocket connection request. So if you pass it, everything works correctly.\r\nHere is my code of this example:\r\n```\r\nimport uvicorn\r\n\r\nfrom fastapi import Cookie, Depends, FastAPI, Header\r\nfrom starlette.responses import HTMLResponse\r\nfrom starlette.status import WS_1008_POLICY_VIOLATION\r\nfrom starlette.websockets import WebSocket\r\n\r\napp = FastAPI()\r\n\r\nhtml = \"\"\"\r\n\r\n\r\n \r\n Chat\r\n \r\n \r\n

WebSocket Chat

\r\n
\r\n \r\n \r\n
\r\n \r\n \r\n
\r\n
    \r\n
\r\n \r\n \r\n\r\n\"\"\"\r\n\r\n\r\n@app.get(\"/\")\r\nasync def get():\r\n return HTMLResponse(html)\r\n\r\n\r\nasync def get_cookie_or_client(\r\n websocket: WebSocket, session: str = Cookie(None), x_client: str = Header(None)\r\n):\r\n if session is None and x_client is None:\r\n await websocket.close(code=WS_1008_POLICY_VIOLATION)\r\n return session or x_client\r\n\r\n\r\n@app.websocket(\"/items/{item_id}/ws\")\r\nasync def websocket_endpoint(\r\n websocket: WebSocket,\r\n item_id: int,\r\n q: str = None,\r\n cookie_or_client: str = Depends(get_cookie_or_client),\r\n):\r\n await websocket.accept()\r\n while True:\r\n data = await websocket.receive_text()\r\n await websocket.send_text(\r\n f\"Session Cookie or X-Client Header value is: {cookie_or_client}\"\r\n )\r\n if q is not None:\r\n await websocket.send_text(f\"Query parameter q is: {q}\")\r\n await websocket.send_text(f\"Message text was: {data}, for item ID: {item_id}\")\r\n\r\nif __name__ == '__main__':\r\n uvicorn.run(app, host='localhost', port=8000)\r\n```\n@alj06ka\r\nwork, thank you \r\nneed to change item_id to str \r\n```python\r\n@app.websocket(\"/items/{item_id}/ws\")\r\nasync def websocket_endpoint(\r\n websocket: WebSocket,\r\n item_id: str,\r\n q: str = None,\r\n cookie_or_client: str = Depends(get_cookie_or_client),\r\n):\r\n```\r\n\r\n> it's possible to update the doc ?\nI just had the same problem, and looks like the doc hasn't been edited yet as of Mar. 3rd 2020.\r\nThe code above seems like a decent fix, which has worked for me too.\nI still have this problem:\r\n```\r\nfrom fastapi import Cookie, Depends, FastAPI, Header, WebSocket, status\r\n\r\napp = FastAPI()\r\n\r\n\r\nasync def get_cookie_or_client(\r\n websocket: WebSocket, session: str = Cookie(None), x_client: str = Header(None)\r\n):\r\n if session is None and x_client is None:\r\n await websocket.close(code=status.WS_1008_POLICY_VIOLATION)\r\n return session or x_client\r\n\r\n\r\n@app.websocket(\"/ws\")\r\nasync def websocket_endpoint(\r\n websocket: WebSocket, cookie_or_client: str = Depends(get_cookie_or_client),\r\n):\r\n await websocket.accept()\r\n while True:\r\n data = await websocket.receive_text()\r\n\r\n await websocket.send_text(f\"Message text was: {data}\")\r\n```\r\n"},"created_at":{"kind":"string","value":"2020-06-09T15:37:27Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/protocols/websockets/websockets_impl.py\", line 147, in run_asgi\r\n result = await self.app(self.scope, self.asgi_receive, self.asgi_send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py\", line 58, in __call__\r\n raise exc from None\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py\", line 54, in __call__\r\n await self.app(scope, inner_receive, inner_send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/applications.py\", line 133, in __call__\r\n await self.error_middleware(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/middleware/errors.py\", line 87, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/exceptions.py\", line 49, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 585, in __call__\r\n await route(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 265, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/routing.py\", line 56, in app\r\n await func(session)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/fastapi/routing.py\", line 148, in app\r\n await websocket.close(code=WS_1008_POLICY_VIOLATION)\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/websockets.py\", line 121, in close\r\n await self.send({\"type\": \"websocket.close\", \"code\": code})\r\n File \"/data/experiments/realtime_web_socket/lib/python3.7/site-packages/starlette/websockets.py\", line 70, in send\r\n raise RuntimeError('Cannot call \"send\" once a close message has been sent.')\r\nRuntimeError: Cannot call \"send\" once a close message has been sent.\r\n"},"__index_level_0__":{"kind":"number","value":18183,"string":"18,183"}}},{"rowIdx":1519,"cells":{"repo":{"kind":"string","value":"tiangolo/fastapi"},"instance_id":{"kind":"string","value":"tiangolo__fastapi-347"},"base_commit":{"kind":"string","value":"b30cca8e9e39461db35cea41967eb206dd51387d"},"patch":{"kind":"string","value":"diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py\n--- a/fastapi/openapi/utils.py\n+++ b/fastapi/openapi/utils.py\n@@ -8,7 +8,11 @@\n from fastapi.openapi.constants import METHODS_WITH_BODY, REF_PREFIX\n from fastapi.openapi.models import OpenAPI\n from fastapi.params import Body, Param\n-from fastapi.utils import get_flat_models_from_routes, get_model_definitions\n+from fastapi.utils import (\n+ generate_operation_id_for_path,\n+ get_flat_models_from_routes,\n+ get_model_definitions,\n+)\n from pydantic.fields import Field\n from pydantic.schema import field_schema, get_model_name_map\n from pydantic.utils import lenient_issubclass\n@@ -113,10 +117,7 @@ def generate_operation_id(*, route: routing.APIRoute, method: str) -> str:\n if route.operation_id:\n return route.operation_id\n path: str = route.path_format\n- operation_id = route.name + path\n- operation_id = operation_id.replace(\"{\", \"_\").replace(\"}\", \"_\").replace(\"/\", \"_\")\n- operation_id = operation_id + \"_\" + method.lower()\n- return operation_id\n+ return generate_operation_id_for_path(name=route.name, path=path, method=method)\n \n \n def generate_operation_summary(*, route: routing.APIRoute, method: str) -> str:\ndiff --git a/fastapi/routing.py b/fastapi/routing.py\n--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -13,7 +13,7 @@\n )\n from fastapi.encoders import jsonable_encoder\n from fastapi.exceptions import RequestValidationError, WebSocketRequestValidationError\n-from fastapi.utils import create_cloned_field\n+from fastapi.utils import create_cloned_field, generate_operation_id_for_path\n from pydantic import BaseConfig, BaseModel, Schema\n from pydantic.error_wrappers import ErrorWrapper, ValidationError\n from pydantic.fields import Field\n@@ -205,12 +205,19 @@ def __init__(\n self.path = path\n self.endpoint = endpoint\n self.name = get_name(endpoint) if name is None else name\n+ self.path_regex, self.path_format, self.param_convertors = compile_path(path)\n+ if methods is None:\n+ methods = [\"GET\"]\n+ self.methods = set([method.upper() for method in methods])\n+ self.unique_id = generate_operation_id_for_path(\n+ name=self.name, path=self.path_format, method=list(methods)[0]\n+ )\n self.response_model = response_model\n if self.response_model:\n assert lenient_issubclass(\n response_class, JSONResponse\n ), \"To declare a type the response must be a JSON response\"\n- response_name = \"Response_\" + self.name\n+ response_name = \"Response_\" + self.unique_id\n self.response_field: Optional[Field] = Field(\n name=response_name,\n type_=self.response_model,\n@@ -251,7 +258,7 @@ def __init__(\n assert lenient_issubclass(\n model, BaseModel\n ), \"A response model must be a Pydantic model\"\n- response_name = f\"Response_{additional_status_code}_{self.name}\"\n+ response_name = f\"Response_{additional_status_code}_{self.unique_id}\"\n response_field = Field(\n name=response_name,\n type_=model,\n@@ -267,9 +274,6 @@ def __init__(\n else:\n self.response_fields = {}\n self.deprecated = deprecated\n- if methods is None:\n- methods = [\"GET\"]\n- self.methods = set([method.upper() for method in methods])\n self.operation_id = operation_id\n self.response_model_include = response_model_include\n self.response_model_exclude = response_model_exclude\n@@ -278,7 +282,6 @@ def __init__(\n self.include_in_schema = include_in_schema\n self.response_class = response_class\n \n- self.path_regex, self.path_format, self.param_convertors = compile_path(path)\n assert inspect.isfunction(endpoint) or inspect.ismethod(\n endpoint\n ), f\"An endpoint must be a function or method\"\n@@ -288,7 +291,7 @@ def __init__(\n 0,\n get_parameterless_sub_dependant(depends=depends, path=self.path_format),\n )\n- self.body_field = get_body_field(dependant=self.dependant, name=self.name)\n+ self.body_field = get_body_field(dependant=self.dependant, name=self.unique_id)\n self.dependency_overrides_provider = dependency_overrides_provider\n self.app = request_response(\n get_app(\ndiff --git a/fastapi/utils.py b/fastapi/utils.py\n--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -93,3 +93,10 @@ def create_cloned_field(field: Field) -> Field:\n new_field.shape = field.shape\n new_field._populate_validators()\n return new_field\n+\n+\n+def generate_operation_id_for_path(*, name: str, path: str, method: str) -> str:\n+ operation_id = name + path\n+ operation_id = operation_id.replace(\"{\", \"_\").replace(\"}\", \"_\").replace(\"/\", \"_\")\n+ operation_id = operation_id + \"_\" + method.lower()\n+ return operation_id\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"OpenAPI fails when forcing query params to be body and multiple params in each\n**Describe the bug**\r\n\r\nThe OpenAPI spec for my app breaks with the following error (shown in my web browser).\r\n\r\n```\r\nFetch error\r\nInternal Server Error /openapi.json\r\n```\r\n\r\nThis only happens when I have endpoints defined in two separate files, each of which force all their arguments to be body parameters via annotating each parameter with `Body(...)` to force them to be body parameters, as opposed to query parameters.\r\n\r\nCheck this out!\r\n\r\n- If the endpoints are defined in the same file, then the problem does not happen.\r\n- If each endpoint only has a single parameter, the problem does not happen.\r\n- If only one endpoint has multiple parameters, then the problem does not happen.\r\n\r\nIt only happens when both endpoints have *multiple* parameters annotated with `Body(...)`.\r\n\r\n\r\n**To Reproduce**\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Create a directory with the following structure.\r\n\r\n```\r\n.\r\n├── foo\r\n│   ├── __init__.py\r\n│   ├── bar.py\r\n│   └── baz.py\r\n└── main.py\r\n```\r\n\r\nmain.py\r\n\r\n```python\r\nfrom fastapi import FastAPI\r\n\r\nimport foo.bar\r\nimport foo.baz\r\n\r\napp = FastAPI()\r\n\r\napp.get('/v1/compute')(foo.bar.compute)\r\napp.get('/v2/compute')(foo.baz.compute)\r\n```\r\n\r\nfoo/bar.py\r\n\r\n```python\r\nfrom fastapi import Body\r\n\r\ndef compute(\r\n a: int = Body(...),\r\n b: str = Body(...),\r\n):\r\n return a + b \r\n```\r\n\r\nfoo/baz.py (identical to foo/bar.py)\r\n\r\n```python\r\nfrom fastapi import Body\r\n\r\ndef compute(\r\n a: int = Body(...),\r\n b: str = Body(...),\r\n):\r\n return a + b\r\n```\r\n\r\n2. Run with `uvicorn main:app --reload`\r\n3. Visit `http://localhost:8000/docs`\r\n\r\n**Expected behavior**\r\n\r\nThe OpenAPI page shows without error.\r\n\r\n**Screenshots**\r\n\r\n![image](https://user-images.githubusercontent.com/2068912/58768563-3e448080-8552-11e9-92b1-cfc1e8040d68.png)\r\n\r\nHere's the exception my app produces when I try to visit `http://localhost:8000`.\r\n\r\n```\r\nip-10-8-0-198% % uvicorn run:app --reload\r\nINFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\r\nINFO: Started reloader process [77186]\r\nWARNING:root:email-validator not installed, email fields will be treated as str.\r\nTo install, run: pip install email-validator\r\nINFO:uvicorn:Started server process [77188]\r\nINFO:uvicorn:Waiting for application startup.\r\nINFO:uvicorn:('127.0.0.1', 54932) - \"GET /docs HTTP/1.1\" 200\r\nINFO:uvicorn:('127.0.0.1', 54932) - \"GET /openapi.json HTTP/1.1\" 500\r\nERROR:uvicorn:Exception in ASGI application\r\nTraceback (most recent call last):\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 368, in run_asgi\r\n result = await app(self.scope, self.receive, self.send)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/uvicorn/middleware/asgi2.py\", line 7, in __call__\r\n await instance(receive, send)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/middleware/errors.py\", line 125, in asgi\r\n raise exc from None\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/middleware/errors.py\", line 103, in asgi\r\n await asgi(receive, _send)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/exceptions.py\", line 74, in app\r\n raise exc from None\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/exceptions.py\", line 63, in app\r\n await instance(receive, sender)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/routing.py\", line 43, in awaitable\r\n response = await run_in_threadpool(func, request)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/concurrency.py\", line 24, in run_in_threadpool\r\n return await loop.run_in_executor(None, func, *args)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/concurrent/futures/thread.py\", line 56, in run\r\n result = self.fn(*self.args, **self.kwargs)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/applications.py\", line 83, in \r\n lambda req: JSONResponse(self.openapi()),\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/applications.py\", line 75, in openapi \r\n openapi_prefix=self.openapi_prefix,\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/openapi/utils.py\", line 248, in get_openapi \r\n flat_models=flat_models, model_name_map=model_name_map\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/utils.py\", line 45, in get_model_definitions \r\n model_name = model_name_map[model]\r\nKeyError: \r\n```\r\n\r\n**Environment:**\r\n - OS: [e.g. macOS]\r\n - FastAPI Version [e.g. 0.27.0], get it with `pip install fastapi`.\r\n\r\n```Python\r\nimport fastapi\r\nprint(fastapi.__version__)\r\n```\r\n\r\n**Additional context**\r\n\r\n- When I only have a single endpoint, the value of `model_name_map` is `{: 'Body_compute'}`.\r\n- However, when I have both endpoints take multiple parameters, the value of `model_name_map` is `{: 'None__Body_compute'}`.\n"},"hints_text":{"kind":"string","value":"Thanks for the report. I'll check it soon."},"created_at":{"kind":"string","value":"2019-06-28T17:31:21Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 368, in run_asgi\r\n result = await app(self.scope, self.receive, self.send)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/uvicorn/middleware/asgi2.py\", line 7, in __call__\r\n await instance(receive, send)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/middleware/errors.py\", line 125, in asgi\r\n raise exc from None\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/middleware/errors.py\", line 103, in asgi\r\n await asgi(receive, _send)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/exceptions.py\", line 74, in app\r\n raise exc from None\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/exceptions.py\", line 63, in app\r\n await instance(receive, sender)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/routing.py\", line 43, in awaitable\r\n response = await run_in_threadpool(func, request)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/starlette/concurrency.py\", line 24, in run_in_threadpool\r\n return await loop.run_in_executor(None, func, *args)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/concurrent/futures/thread.py\", line 56, in run\r\n result = self.fn(*self.args, **self.kwargs)\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/applications.py\", line 83, in \r\n lambda req: JSONResponse(self.openapi()),\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/applications.py\", line 75, in openapi \r\n openapi_prefix=self.openapi_prefix,\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/openapi/utils.py\", line 248, in get_openapi \r\n flat_models=flat_models, model_name_map=model_name_map\r\n File \"/Users/edwardbanner/.anaconda/lib/python3.6/site-packages/fastapi/utils.py\", line 45, in get_model_definitions \r\n model_name = model_name_map[model]\r\nKeyError: \r\n"},"__index_level_0__":{"kind":"number","value":18194,"string":"18,194"}}},{"rowIdx":1520,"cells":{"repo":{"kind":"string","value":"tiangolo/fastapi"},"instance_id":{"kind":"string","value":"tiangolo__fastapi-918"},"base_commit":{"kind":"string","value":"55afb70b3717969565499f5dcaef54b1f0acc7da"},"patch":{"kind":"string","value":"diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py\n--- a/fastapi/dependencies/utils.py\n+++ b/fastapi/dependencies/utils.py\n@@ -634,7 +634,11 @@ async def request_body_to_args(\n ) and isinstance(received_body, FormData):\n value = received_body.getlist(field.alias)\n else:\n- value = received_body.get(field.alias)\n+ try:\n+ value = received_body.get(field.alias)\n+ except AttributeError:\n+ errors.append(get_missing_field_error(field.alias))\n+ continue\n if (\n value is None\n or (isinstance(field_info, params.Form) and value == \"\")\n@@ -645,18 +649,7 @@ async def request_body_to_args(\n )\n ):\n if field.required:\n- if PYDANTIC_1:\n- errors.append(\n- ErrorWrapper(MissingError(), loc=(\"body\", field.alias))\n- )\n- else: # pragma: nocover\n- errors.append(\n- ErrorWrapper( # type: ignore\n- MissingError(),\n- loc=(\"body\", field.alias),\n- config=BaseConfig,\n- )\n- )\n+ errors.append(get_missing_field_error(field.alias))\n else:\n values[field.name] = deepcopy(field.default)\n continue\n@@ -685,6 +678,16 @@ async def request_body_to_args(\n return values, errors\n \n \n+def get_missing_field_error(field_alias: str) -> ErrorWrapper:\n+ if PYDANTIC_1:\n+ missing_field_error = ErrorWrapper(MissingError(), loc=(\"body\", field_alias))\n+ else: # pragma: no cover\n+ missing_field_error = ErrorWrapper( # type: ignore\n+ MissingError(), loc=(\"body\", field_alias), config=BaseConfig,\n+ )\n+ return missing_field_error\n+\n+\n def get_schema_compatible_field(*, field: ModelField) -> ModelField:\n out_field = field\n if lenient_issubclass(field.type_, UploadFile):\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Sending incorrect data cause 500 error\nI've got this simple example:\r\n\r\n```\r\nfrom typing import List\r\n\r\nfrom fastapi import FastAPI, Body\r\n\r\n\r\nclass User(BaseModel):\r\n name: str\r\n\r\n\r\n@app.post('/test/')\r\nasync def test(users: List[User], test: str = Body(...)):\r\n return {'users': users, 'test': test}\r\n```\r\n\r\nWhen sending incorrect payload the server returns 500 error:\r\n\r\n```\r\n# curl -s -D - -o /dev/null -X POST \"localhost:8080/test/\" -H \"accept: application/json\" -H \"Content-Type: application/json\" -d \"[]\"\r\nHTTP/1.1 500 Internal Server Error\r\ndate: Fri, 24 Jan 2020 10:59:47 GMT\r\nserver: uvicorn\r\ncontent-length: 1264\r\ncontent-type: text/plain; charset=utf-8\r\n```\r\nServer exception:\r\n\r\n```\r\nINFO: 127.0.0.1:60652 - \"POST /test/ HTTP/1.1\" 500 Internal Server Error\r\nERROR: Exception in ASGI application\r\nTraceback (most recent call last):\r\n File \"/test/venv38/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 385, in run_asgi\r\n result = await app(self.scope, self.receive, self.send)\r\n File \"/test/venv38/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py\", line 45, in __call__\r\n return await self.app(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/applications.py\", line 140, in __call__\r\n await super().__call__(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/applications.py\", line 134, in __call__\r\n await self.error_middleware(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/middleware/errors.py\", line 178, in __call__\r\n raise exc from None\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/middleware/errors.py\", line 156, in __call__\r\n await self.app(scope, receive, _send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/exceptions.py\", line 73, in __call__\r\n raise exc from None\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/exceptions.py\", line 62, in __call__\r\n await self.app(scope, receive, sender)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/routing.py\", line 590, in __call__\r\n await route(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/routing.py\", line 208, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/routing.py\", line 41, in app\r\n response = await func(request)\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/routing.py\", line 115, in app\r\n solved_result = await solve_dependencies(\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/dependencies/utils.py\", line 547, in solve_dependencies\r\n ) = await request_body_to_args( # body_params checked above\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/dependencies/utils.py\", line 637, in request_body_to_args\r\n value = received_body.get(field.alias)\r\nAttributeError: 'list' object has no attribute 'get'\r\n```\r\n\r\nSo the body is not validated in this case?\n"},"hints_text":{"kind":"string","value":"Have reproduced same error."},"created_at":{"kind":"string","value":"2020-01-25T06:59:01Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/test/venv38/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py\", line 385, in run_asgi\r\n result = await app(self.scope, self.receive, self.send)\r\n File \"/test/venv38/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py\", line 45, in __call__\r\n return await self.app(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/applications.py\", line 140, in __call__\r\n await super().__call__(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/applications.py\", line 134, in __call__\r\n await self.error_middleware(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/middleware/errors.py\", line 178, in __call__\r\n raise exc from None\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/middleware/errors.py\", line 156, in __call__\r\n await self.app(scope, receive, _send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/exceptions.py\", line 73, in __call__\r\n raise exc from None\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/exceptions.py\", line 62, in __call__\r\n await self.app(scope, receive, sender)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/routing.py\", line 590, in __call__\r\n await route(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/routing.py\", line 208, in __call__\r\n await self.app(scope, receive, send)\r\n File \"/test/venv38/lib/python3.8/site-packages/starlette/routing.py\", line 41, in app\r\n response = await func(request)\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/routing.py\", line 115, in app\r\n solved_result = await solve_dependencies(\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/dependencies/utils.py\", line 547, in solve_dependencies\r\n ) = await request_body_to_args( # body_params checked above\r\n File \"/test/venv38/lib/python3.8/site-packages/fastapi/dependencies/utils.py\", line 637, in request_body_to_args\r\n value = received_body.get(field.alias)\r\nAttributeError: 'list' object has no attribute 'get'\r\n"},"__index_level_0__":{"kind":"number","value":18206,"string":"18,206"}}},{"rowIdx":1521,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-1141"},"base_commit":{"kind":"string","value":"c1e5dd3ddeb926ab5bd60e950ea56dee1eb5660f"},"patch":{"kind":"string","value":"diff --git a/src/twisted/application/internet.py b/src/twisted/application/internet.py\n--- a/src/twisted/application/internet.py\n+++ b/src/twisted/application/internet.py\n@@ -517,9 +517,15 @@ def backoffPolicy(initialDelay=1.0, maxDelay=60.0, factor=1.5,\n @rtype: see L{ClientService.__init__}'s C{retryPolicy} argument.\n \"\"\"\n def policy(attempt):\n- return min(initialDelay * (factor ** attempt), maxDelay) + jitter()\n+ try:\n+ delay = min(initialDelay * (factor ** min(100, attempt)), maxDelay)\n+ except OverflowError:\n+ delay = maxDelay\n+ return delay + jitter()\n return policy\n \n+\n+\n _defaultPolicy = backoffPolicy()\n \n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"t.a.i.backoffPolicy fails after a certain number of retries (builtins.OverflowError)\n|[\"wiml's](https://github.com/wiml)| @wiml reported|\n|-|-|\n|Trac ID|trac#9476|\n|Type|defect|\n|Created|2018-07-02 21:05:08Z|\n\nI have some connections which can go down for a while, but I want to keep checking (once per minute, e.g.) until they become reachable again. Supposedly, I can do this with the `maxDelay` parameter of `backoffPolicy`.\n\nAfter a while, though, instead of continuing to re-try, `policy` will start raising an exception:\n\n```\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/automat/_methodical.py\", line 135, in _connectionFailed\nJul 02 12:59:22 [8534]: value = output(oself, *args, **kwargs)\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/automat/_methodical.py\", line 169, in __call__\nJul 02 12:59:22 [8534]: return self.method(oself, *args, **kwargs)\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/twisted/application/internet.py\", line 740, in _ignoreAndWait\nJul 02 12:59:22 [8534]: return self._doWait()\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/twisted/application/internet.py\", line 744, in _doWait\nJul 02 12:59:22 [8534]: delay = self._timeoutForAttempt(self._failedAttempts)\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/twisted/application/internet.py\", line 520, in policy\nJul 02 12:59:22 [8534]: return min(initialDelay * (factor ** attempt), maxDelay) + jitter()\nJul 02 12:59:22 [8534]: builtins.OverflowError: (34, 'Numerical result out of range')\n```\n\n(Some pathnames sanitized.) A little investigation shows that once the `attempt` count exceeds 1750, the intermediate result is too large to represent in a `float`, and so even though it will be discarded and replaced by `maxDelay` this will cause retries to fail:\n\n```\n>>> factor = 1.5\n>>> (factor ** 1750)\n1.4444527745742028e+308\n>>> (factor ** 1751)\nTraceback (most recent call last):\n File \"\", line 1, in \nOverflowError: (34, 'Numerical result out of range')\n```\n\nThis will take only a couple of days at `maxDelay=60.0`: less than a weekend.\n\nVersions:\n* Twisted==18.4.0\n* Python 3.6.3 (default, Jan 4 2018, 16:40:53) \n* [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux\n* CentOS Linux release 7.4.1708 (Core)\n\n\n
Searchable metadata\n\n```\ntrac-id__9476 9476\ntype__defect defect\nreporter__wiml wiml\npriority__normal normal\nmilestone__None None\nbranch__ \nbranch_author__ \nstatus__closed closed\nresolution__fixed fixed\ncomponent__core core\nkeywords__None None\ntime__1530565508694370 1530565508694370\nchangetime__1558292011336444 1558292011336444\nversion__None None\nowner__jandelgado jandelgado\n\n```\n
\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2019-05-17T22:07:37Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"\", line 1, in \nOverflowError: (34, 'Numerical result out of range')\n"},"__index_level_0__":{"kind":"number","value":18209,"string":"18,209"}}},{"rowIdx":1522,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-1142"},"base_commit":{"kind":"string","value":"c1e5dd3ddeb926ab5bd60e950ea56dee1eb5660f"},"patch":{"kind":"string","value":"diff --git a/src/twisted/application/internet.py b/src/twisted/application/internet.py\n--- a/src/twisted/application/internet.py\n+++ b/src/twisted/application/internet.py\n@@ -517,9 +517,15 @@ def backoffPolicy(initialDelay=1.0, maxDelay=60.0, factor=1.5,\n @rtype: see L{ClientService.__init__}'s C{retryPolicy} argument.\n \"\"\"\n def policy(attempt):\n- return min(initialDelay * (factor ** attempt), maxDelay) + jitter()\n+ try:\n+ delay = min(initialDelay * (factor ** min(100, attempt)), maxDelay)\n+ except OverflowError:\n+ delay = maxDelay\n+ return delay + jitter()\n return policy\n \n+\n+\n _defaultPolicy = backoffPolicy()\n \n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"t.a.i.backoffPolicy fails after a certain number of retries (builtins.OverflowError)\n|[\"wiml's](https://github.com/wiml)| @wiml reported|\n|-|-|\n|Trac ID|trac#9476|\n|Type|defect|\n|Created|2018-07-02 21:05:08Z|\n\nI have some connections which can go down for a while, but I want to keep checking (once per minute, e.g.) until they become reachable again. Supposedly, I can do this with the `maxDelay` parameter of `backoffPolicy`.\n\nAfter a while, though, instead of continuing to re-try, `policy` will start raising an exception:\n\n```\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/automat/_methodical.py\", line 135, in _connectionFailed\nJul 02 12:59:22 [8534]: value = output(oself, *args, **kwargs)\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/automat/_methodical.py\", line 169, in __call__\nJul 02 12:59:22 [8534]: return self.method(oself, *args, **kwargs)\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/twisted/application/internet.py\", line 740, in _ignoreAndWait\nJul 02 12:59:22 [8534]: return self._doWait()\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/twisted/application/internet.py\", line 744, in _doWait\nJul 02 12:59:22 [8534]: delay = self._timeoutForAttempt(self._failedAttempts)\nJul 02 12:59:22 [8534]: File \".../python3.6/site-packages/twisted/application/internet.py\", line 520, in policy\nJul 02 12:59:22 [8534]: return min(initialDelay * (factor ** attempt), maxDelay) + jitter()\nJul 02 12:59:22 [8534]: builtins.OverflowError: (34, 'Numerical result out of range')\n```\n\n(Some pathnames sanitized.) A little investigation shows that once the `attempt` count exceeds 1750, the intermediate result is too large to represent in a `float`, and so even though it will be discarded and replaced by `maxDelay` this will cause retries to fail:\n\n```\n>>> factor = 1.5\n>>> (factor ** 1750)\n1.4444527745742028e+308\n>>> (factor ** 1751)\nTraceback (most recent call last):\n File \"\", line 1, in \nOverflowError: (34, 'Numerical result out of range')\n```\n\nThis will take only a couple of days at `maxDelay=60.0`: less than a weekend.\n\nVersions:\n* Twisted==18.4.0\n* Python 3.6.3 (default, Jan 4 2018, 16:40:53) \n* [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux\n* CentOS Linux release 7.4.1708 (Core)\n\n\n
Searchable metadata\n\n```\ntrac-id__9476 9476\ntype__defect defect\nreporter__wiml wiml\npriority__normal normal\nmilestone__None None\nbranch__ \nbranch_author__ \nstatus__closed closed\nresolution__fixed fixed\ncomponent__core core\nkeywords__None None\ntime__1530565508694370 1530565508694370\nchangetime__1558292011336444 1558292011336444\nversion__None None\nowner__jandelgado jandelgado\n\n```\n
\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2019-05-19T18:20:25Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"\", line 1, in \nOverflowError: (34, 'Numerical result out of range')\n"},"__index_level_0__":{"kind":"number","value":18210,"string":"18,210"}}},{"rowIdx":1523,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-11603"},"base_commit":{"kind":"string","value":"8ebcdc2f5a414a5ac1fdf5ee4aed62116af219e3"},"patch":{"kind":"string","value":"diff --git a/src/twisted/internet/base.py b/src/twisted/internet/base.py\n--- a/src/twisted/internet/base.py\n+++ b/src/twisted/internet/base.py\n@@ -80,6 +80,9 @@ class DelayedCall:\n debug = False\n _repr: Optional[str] = None\n \n+ # In debug mode, the call stack at the time of instantiation.\n+ creator: Optional[Sequence[str]] = None\n+\n def __init__(\n self,\n time: float,\n@@ -265,7 +268,7 @@ def __repr__(self) -> str:\n )\n L.append(\")\")\n \n- if self.debug:\n+ if self.creator is not None:\n L.append(\"\\n\\ntraceback at creation: \\n\\n%s\" % (\" \".join(self.creator)))\n L.append(\">\")\n \n@@ -990,8 +993,8 @@ def runUntilCurrent(self) -> None:\n call.called = 1\n call.func(*call.args, **call.kw)\n except BaseException:\n- log.deferr()\n- if hasattr(call, \"creator\"):\n+ log.err()\n+ if call.creator is not None:\n e = \"\\n\"\n e += (\n \" C: previous exception occurred in \"\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"AttributeError: 'DelayedCall' object has no attribute 'creator'\n|\"allenap's| allenap reported|\n|-|-|\n|Trac ID|trac#8306|\n|Type|defect|\n|Created|2016-04-26 16:04:05Z|\n\n```\nPython 3.5.1+ (default, Mar 30 2016, 22:46:26) \n[GCC 5.3.1 20160330] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> from twisted.internet.base import DelayedCall\n>>> dc = DelayedCall(1, lambda: None, (), {}, lambda dc: None, lambda dc: None)\n>>> dc.debug = True\n>>> str(dc)\nTraceback (most recent call last):\n File \"\", line 1, in \n File \".../twisted/internet/base.py\", line 206, in __str__\n L.append(\"\\n\\ntraceback at creation: \\n\\n%s\" % (' '.join(self.creator)))\nAttributeError: 'DelayedCall' object has no attribute 'creator'\n```\n\n```\n$ tail -n1 twisted/_version.py \nversion = versions.Version('twisted', 16, 1, 1)\n```\n\n\n
Searchable metadata\n\n```\ntrac-id__8306 8306\ntype__defect defect\nreporter__allenap allenap\npriority__normal normal\nmilestone__None None\nbranch__ \nbranch_author__ \nstatus__new new\nresolution__None None\ncomponent__core core\nkeywords__None None\ntime__1461686645106304 1461686645106304\nchangetime__1462290530743285 1462290530743285\nversion__None None\nowner__None None\n\n```\n
\n\n"},"hints_text":{"kind":"string","value":"|[\"pawelmhm's](https://github.com/pawelmhm)|@pawelmhm commented|\n|-|-|\n\nseems like this is caused by [#8110](https://github.com/twisted/twisted/issues/8110) - when I remove dc.debug = True line I dont get any excception"},"created_at":{"kind":"string","value":"2022-08-18T15:51:30Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"\", line 1, in \n File \".../twisted/internet/base.py\", line 206, in __str__\n L.append(\"\\n\\ntraceback at creation: \\n\\n%s\" % (' '.join(self.creator)))\nAttributeError: 'DelayedCall' object has no attribute 'creator'\n"},"__index_level_0__":{"kind":"number","value":18217,"string":"18,217"}}},{"rowIdx":1524,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-11644"},"base_commit":{"kind":"string","value":"ca9f05e7dfe9dcc6d88ea9a1be3871019a92812d"},"patch":{"kind":"string","value":"diff --git a/src/twisted/trial/_dist/managercommands.py b/src/twisted/trial/_dist/managercommands.py\n--- a/src/twisted/trial/_dist/managercommands.py\n+++ b/src/twisted/trial/_dist/managercommands.py\n@@ -7,7 +7,7 @@\n @since: 12.3\n \"\"\"\n \n-from twisted.protocols.amp import Boolean, Command, ListOf, Unicode\n+from twisted.protocols.amp import Boolean, Command, Integer, Unicode\n \n NativeString = Unicode\n \n@@ -28,9 +28,9 @@ class AddError(Command):\n \n arguments = [\n (b\"testName\", NativeString()),\n- (b\"error\", NativeString()),\n (b\"errorClass\", NativeString()),\n- (b\"frames\", ListOf(NativeString())),\n+ (b\"errorStreamId\", Integer()),\n+ (b\"framesStreamId\", Integer()),\n ]\n response = [(b\"success\", Boolean())]\n \n@@ -42,9 +42,9 @@ class AddFailure(Command):\n \n arguments = [\n (b\"testName\", NativeString()),\n- (b\"fail\", NativeString()),\n+ (b\"failStreamId\", Integer()),\n (b\"failClass\", NativeString()),\n- (b\"frames\", ListOf(NativeString())),\n+ (b\"framesStreamId\", Integer()),\n ]\n response = [(b\"success\", Boolean())]\n \n@@ -65,7 +65,7 @@ class AddExpectedFailure(Command):\n \n arguments = [\n (b\"testName\", NativeString()),\n- (b\"error\", NativeString()),\n+ (b\"errorStreamId\", Integer()),\n (b\"todo\", NativeString()),\n ]\n response = [(b\"success\", Boolean())]\ndiff --git a/src/twisted/trial/_dist/worker.py b/src/twisted/trial/_dist/worker.py\n--- a/src/twisted/trial/_dist/worker.py\n+++ b/src/twisted/trial/_dist/worker.py\n@@ -11,16 +11,18 @@\n \n import os\n from typing import Awaitable, Callable, Dict, List, Optional, TextIO, TypeVar\n+from unittest import TestCase\n \n from zope.interface import implementer\n \n from attrs import frozen\n-from typing_extensions import Protocol\n+from typing_extensions import Protocol, TypedDict\n \n-from twisted.internet.defer import Deferred\n+from twisted.internet.defer import Deferred, DeferredList\n from twisted.internet.error import ProcessDone\n from twisted.internet.interfaces import IAddress, ITransport\n from twisted.internet.protocol import ProcessProtocol\n+from twisted.logger import Logger\n from twisted.protocols.amp import AMP\n from twisted.python.failure import Failure\n from twisted.python.filepath import FilePath\n@@ -34,7 +36,8 @@\n from twisted.trial._dist.workerreporter import WorkerReporter\n from twisted.trial.reporter import TestResult\n from twisted.trial.runner import TestLoader, TrialSuite\n-from twisted.trial.unittest import TestCase, Todo\n+from twisted.trial.unittest import Todo\n+from .stream import StreamOpen, StreamReceiver, StreamWrite\n \n \n @frozen(auto_exc=False)\n@@ -42,18 +45,26 @@ class WorkerException(Exception):\n \"\"\"\n An exception was reported by a test running in a worker process.\n \n- :ivar message: An error message describing the exception.\n+ @ivar message: An error message describing the exception.\n \"\"\"\n \n message: str\n \n \n+class RunResult(TypedDict):\n+ \"\"\"\n+ Represent the result of a L{workercommands.Run} command.\n+ \"\"\"\n+\n+ success: bool\n+\n+\n class Worker(Protocol):\n \"\"\"\n An object that can run actions.\n \"\"\"\n \n- async def run(self, case: TestCase, result: TestResult) -> None:\n+ async def run(self, case: TestCase, result: TestResult) -> RunResult:\n \"\"\"\n Run a test case.\n \"\"\"\n@@ -68,20 +79,52 @@ class WorkerProtocol(AMP):\n The worker-side trial distributed protocol.\n \"\"\"\n \n+ logger = Logger()\n+\n def __init__(self, forceGarbageCollection=False):\n self._loader = TestLoader()\n self._result = WorkerReporter(self)\n self._forceGarbageCollection = forceGarbageCollection\n \n @workercommands.Run.responder\n- def run(self, testCase):\n+ async def run(self, testCase: str) -> RunResult:\n \"\"\"\n Run a test case by name.\n \"\"\"\n- case = self._loader.loadByName(testCase)\n- suite = TrialSuite([case], self._forceGarbageCollection)\n- suite.run(self._result)\n- return {\"success\": True}\n+ with self._result.gatherReportingResults() as results:\n+ case = self._loader.loadByName(testCase)\n+ suite = TrialSuite([case], self._forceGarbageCollection)\n+ suite.run(self._result)\n+\n+ allSucceeded = True\n+ for (success, result) in await DeferredList(results, consumeErrors=True):\n+ if success:\n+ # Nothing to do here, proceed to the next result.\n+ continue\n+\n+ # There was some error reporting a result to the peer.\n+ allSucceeded = False\n+\n+ # We can try to report the error but since something has already\n+ # gone wrong we shouldn't be extremely confident that this will\n+ # succeed. So we will also log it (and any errors reporting *it*)\n+ # to our local log.\n+ self.logger.failure(\n+ \"Result reporting for {id} failed\",\n+ failure=result,\n+ id=testCase,\n+ )\n+ try:\n+ await self._result.addErrorFallible(testCase, result)\n+ except BaseException:\n+ # We failed to report the failure to the peer. It doesn't\n+ # seem very likely that reporting this new failure to the peer\n+ # will succeed so just log it locally.\n+ self.logger.failure(\n+ \"Additionally, reporting the reporting failure failed.\"\n+ )\n+\n+ return {\"success\": allSucceeded}\n \n @workercommands.Start.responder\n def start(self, directory):\n@@ -98,6 +141,19 @@ class LocalWorkerAMP(AMP):\n Local implementation of the manager commands.\n \"\"\"\n \n+ def __init__(self, boxReceiver=None, locator=None):\n+ super().__init__(boxReceiver, locator)\n+ self._streams = StreamReceiver()\n+\n+ @StreamOpen.responder\n+ def streamOpen(self):\n+ return {\"streamId\": self._streams.open()}\n+\n+ @StreamWrite.responder\n+ def streamWrite(self, streamId, data):\n+ self._streams.write(streamId, data)\n+ return {}\n+\n @managercommands.AddSuccess.responder\n def addSuccess(self, testName):\n \"\"\"\n@@ -137,15 +193,24 @@ def _buildFailure(\n def addError(\n self,\n testName: str,\n- error: str,\n errorClass: str,\n- frames: List[str],\n+ errorStreamId: int,\n+ framesStreamId: int,\n ) -> Dict[str, bool]:\n \"\"\"\n Add an error to the reporter.\n \n- :param error: A message describing the error.\n+ @param errorStreamId: The identifier of a stream over which the text\n+ of this error was previously completely sent to the peer.\n+\n+ @param framesStreamId: The identifier of a stream over which the lines\n+ of the traceback for this error were previously completely sent to\n+ the peer.\n+\n+ @param error: A message describing the error.\n \"\"\"\n+ error = \"\".join(self._streams.finish(errorStreamId))\n+ frames = self._streams.finish(framesStreamId)\n # Wrap the error message in ``WorkerException`` because it is not\n # possible to transfer arbitrary exception values over the AMP\n # connection to the main process but we must give *some* Exception\n@@ -158,13 +223,22 @@ def addError(\n def addFailure(\n self,\n testName: str,\n- fail: str,\n+ failStreamId: int,\n failClass: str,\n- frames: List[str],\n+ framesStreamId: int,\n ) -> Dict[str, bool]:\n \"\"\"\n Add a failure to the reporter.\n+\n+ @param failStreamId: The identifier of a stream over which the text of\n+ this failure was previously completely sent to the peer.\n+\n+ @param framesStreamId: The identifier of a stream over which the lines\n+ of the traceback for this error were previously completely sent to the\n+ peer.\n \"\"\"\n+ fail = \"\".join(self._streams.finish(failStreamId))\n+ frames = self._streams.finish(framesStreamId)\n # See addError for info about use of WorkerException here.\n failure = self._buildFailure(WorkerException(fail), failClass, frames)\n self._result.addFailure(self._testCase, failure)\n@@ -180,11 +254,15 @@ def addSkip(self, testName, reason):\n \n @managercommands.AddExpectedFailure.responder\n def addExpectedFailure(\n- self, testName: str, error: str, todo: Optional[None]\n+ self, testName: str, errorStreamId: int, todo: Optional[str]\n ) -> Dict[str, bool]:\n \"\"\"\n Add an expected failure to the reporter.\n+\n+ @param errorStreamId: The identifier of a stream over which the text\n+ of this error was previously completely sent to the peer.\n \"\"\"\n+ error = \"\".join(self._streams.finish(errorStreamId))\n _todo = Todo(\"\" if todo is None else todo)\n self._result.addExpectedFailure(self._testCase, error, _todo)\n return {\"success\": True}\n@@ -206,14 +284,7 @@ def testWrite(self, out):\n self._testStream.flush()\n return {\"success\": True}\n \n- def _stopTest(self, result):\n- \"\"\"\n- Stop the current running test case, forwarding the result.\n- \"\"\"\n- self._result.stopTest(self._testCase)\n- return result\n-\n- def run(self, testCase, result):\n+ async def run(self, testCase: TestCase, result: TestResult) -> RunResult:\n \"\"\"\n Run a test.\n \"\"\"\n@@ -221,8 +292,10 @@ def run(self, testCase, result):\n self._result = result\n self._result.startTest(testCase)\n testCaseId = testCase.id()\n- d = self.callRemote(workercommands.Run, testCase=testCaseId)\n- return d.addCallback(self._stopTest)\n+ try:\n+ return await self.callRemote(workercommands.Run, testCase=testCaseId) # type: ignore[no-any-return]\n+ finally:\n+ self._result.stopTest(testCase)\n \n def setTestStream(self, stream):\n \"\"\"\ndiff --git a/src/twisted/trial/_dist/workerreporter.py b/src/twisted/trial/_dist/workerreporter.py\n--- a/src/twisted/trial/_dist/workerreporter.py\n+++ b/src/twisted/trial/_dist/workerreporter.py\n@@ -9,12 +9,155 @@\n @since: 12.3\n \"\"\"\n \n-from typing import List\n+from types import TracebackType\n+from typing import Callable, List, Optional, Sequence, Tuple, Type, TypeVar, Union\n+from unittest import TestCase as PyUnitTestCase\n \n+from attrs import Factory, define\n+from typing_extensions import Literal, TypeAlias\n+\n+from twisted.internet.defer import Deferred, maybeDeferred\n+from twisted.protocols.amp import AMP\n from twisted.python.failure import Failure\n from twisted.python.reflect import qual\n from twisted.trial._dist import managercommands\n from twisted.trial.reporter import TestResult\n+from .stream import chunk, stream\n+\n+T = TypeVar(\"T\")\n+ExcInfo: TypeAlias = Tuple[Type[BaseException], BaseException, TracebackType]\n+XUnitFailure = Union[ExcInfo, Tuple[None, None, None]]\n+TrialFailure = Union[XUnitFailure, Failure]\n+\n+\n+async def addError(\n+ amp: AMP, testName: str, errorClass: str, error: str, frames: List[str]\n+) -> None:\n+ \"\"\"\n+ Send an error to the worker manager over an AMP connection.\n+\n+ First the pieces which can be large are streamed over the connection.\n+ Then, L{managercommands.AddError} is called with the rest of the\n+ information and the stream IDs.\n+\n+ :param amp: The connection to use.\n+ :param testName: The name (or ID) of the test the error relates to.\n+ :param errorClass: The fully qualified name of the error type.\n+ :param error: The string representation of the error.\n+ :param frames: The lines of the traceback associated with the error.\n+ \"\"\"\n+\n+ errorStreamId = await stream(amp, chunk(error, 2 ** 16 - 1))\n+ framesStreamId = await stream(amp, iter(frames))\n+\n+ await amp.callRemote(\n+ managercommands.AddError,\n+ testName=testName,\n+ errorClass=errorClass,\n+ errorStreamId=errorStreamId,\n+ framesStreamId=framesStreamId,\n+ )\n+\n+\n+async def addFailure(\n+ amp: AMP, testName: str, fail: str, failClass: str, frames: List[str]\n+) -> None:\n+ \"\"\"\n+ Like L{addError} but for failures.\n+\n+ :param amp: See L{addError}\n+ :param testName: See L{addError}\n+ :param failClass: The fully qualified name of the exception associated\n+ with the failure.\n+ :param fail: The string representation of the failure.\n+ :param frames: The lines of the traceback associated with the error.\n+ \"\"\"\n+ failStreamId = await stream(amp, chunk(fail, 2 ** 16 - 1))\n+ framesStreamId = await stream(amp, iter(frames))\n+\n+ await amp.callRemote(\n+ managercommands.AddFailure,\n+ testName=testName,\n+ failClass=failClass,\n+ failStreamId=failStreamId,\n+ framesStreamId=framesStreamId,\n+ )\n+\n+\n+async def addExpectedFailure(amp: AMP, testName: str, error: str, todo: str) -> None:\n+ \"\"\"\n+ Like L{addError} but for expected failures.\n+\n+ :param amp: See L{addError}\n+ :param testName: See L{addError}\n+ :param error: The string representation of the expected failure.\n+ :param todo: The string description of the expectation.\n+ \"\"\"\n+ errorStreamId = await stream(amp, chunk(error, 2 ** 16 - 1))\n+\n+ await amp.callRemote(\n+ managercommands.AddExpectedFailure,\n+ testName=testName,\n+ errorStreamId=errorStreamId,\n+ todo=todo,\n+ )\n+\n+\n+@define\n+class ReportingResults:\n+ \"\"\"\n+ A mutable container for the result of sending test results back to the\n+ parent process.\n+\n+ Since it is possible for these sends to fail asynchronously but the\n+ L{TestResult} protocol is not well suited for asynchronous result\n+ reporting, results are collected on an instance of this class and when the\n+ runner believes the test is otherwise complete, it can collect the results\n+ and do something with any errors.\n+\n+ :ivar _reporter: The L{WorkerReporter} this object is associated with.\n+ This is the object doing the result reporting.\n+\n+ :ivar _results: A list of L{Deferred} instances representing the results\n+ of reporting operations. This is expected to grow over the course of\n+ the test run and then be inspected by the runner once the test is\n+ over. The public interface to this list is via the context manager\n+ interface.\n+ \"\"\"\n+\n+ _reporter: \"WorkerReporter\"\n+ _results: List[Deferred[object]] = Factory(list)\n+\n+ def __enter__(self) -> Sequence[Deferred[object]]:\n+ \"\"\"\n+ Begin a new reportable context in which results can be collected.\n+\n+ :return: A sequence which will contain the L{Deferred} instances\n+ representing the results of all test result reporting that happens\n+ while the context manager is active. The sequence is extended as\n+ the test runs so its value should not be consumed until the test\n+ is over.\n+ \"\"\"\n+ return self._results\n+\n+ def __exit__(\n+ self,\n+ excType: Type[BaseException],\n+ excValue: BaseException,\n+ excTraceback: TracebackType,\n+ ) -> Literal[False]:\n+ \"\"\"\n+ End the reportable context.\n+ \"\"\"\n+ self._reporter._reporting = None\n+ return False\n+\n+ def record(self, result: Deferred[object]) -> None:\n+ \"\"\"\n+ Record a L{Deferred} instance representing one test result reporting\n+ operation.\n+ \"\"\"\n+ self._results.append(result)\n \n \n class WorkerReporter(TestResult):\n@@ -24,20 +167,36 @@ class WorkerReporter(TestResult):\n \n @ivar _DEFAULT_TODO: Default message for expected failures and\n unexpected successes, used only if a C{Todo} is not provided.\n+\n+ @ivar _reporting: When a \"result reporting\" context is active, the\n+ corresponding context manager. Otherwise, L{None}.\n \"\"\"\n \n _DEFAULT_TODO = \"Test expected to fail\"\n \n+ ampProtocol: AMP\n+ _reporting: Optional[ReportingResults] = None\n+\n def __init__(self, ampProtocol):\n \"\"\"\n @param ampProtocol: The communication channel with the trial\n distributed manager which collects all test results.\n- @type ampProtocol: C{AMP}\n \"\"\"\n super().__init__()\n self.ampProtocol = ampProtocol\n \n- def _getFailure(self, error):\n+ def gatherReportingResults(self) -> ReportingResults:\n+ \"\"\"\n+ Get a \"result reporting\" context manager.\n+\n+ In a \"result reporting\" context, asynchronous test result reporting\n+ methods may be used safely. Their results (in particular, failures)\n+ are available from the context manager.\n+ \"\"\"\n+ self._reporting = ReportingResults(self)\n+ return self._reporting\n+\n+ def _getFailure(self, error: TrialFailure) -> Failure:\n \"\"\"\n Convert a C{sys.exc_info()}-style tuple to a L{Failure}, if necessary.\n \"\"\"\n@@ -56,48 +215,85 @@ def _getFrames(self, failure: Failure) -> List[str]:\n frames.extend([frame[0], frame[1], str(frame[2])])\n return frames\n \n- def addSuccess(self, test):\n+ def _call(self, f: Callable[[], T]) -> None:\n \"\"\"\n- Send a success over.\n+ Call L{f} if and only if a \"result reporting\" context is active.\n+\n+ @param f: A function to call. Its result is accumulated into the\n+ result reporting context. It may return a L{Deferred} or a\n+ coroutine or synchronously raise an exception or return a result\n+ value.\n+\n+ @raise ValueError: If no result reporting context is active.\n+ \"\"\"\n+ if self._reporting is not None:\n+ self._reporting.record(maybeDeferred(f))\n+ else:\n+ raise ValueError(\n+ \"Cannot call command outside of reporting context manager.\"\n+ )\n+\n+ def addSuccess(self, test: PyUnitTestCase) -> None:\n+ \"\"\"\n+ Send a success to the parent process.\n+\n+ This must be called in context managed by L{gatherReportingResults}.\n \"\"\"\n super().addSuccess(test)\n testName = test.id()\n- self.ampProtocol.callRemote(managercommands.AddSuccess, testName=testName)\n+ self._call(\n+ lambda: self.ampProtocol.callRemote( # type: ignore[no-any-return]\n+ managercommands.AddSuccess, testName=testName\n+ )\n+ )\n \n- def addError(self, test, error):\n+ async def addErrorFallible(self, testName: str, errorObj: TrialFailure) -> None:\n \"\"\"\n- Send an error over.\n+ Attempt to report an error to the parent process.\n+\n+ Unlike L{addError} this can fail asynchronously. This version is for\n+ infrastructure code that can apply its own failure handling.\n+\n+ @return: A L{Deferred} that fires with the result of the attempt.\n \"\"\"\n- super().addError(test, error)\n- testName = test.id()\n- failure = self._getFailure(error)\n- error = failure.getErrorMessage()\n+ failure = self._getFailure(errorObj)\n+ errorStr = failure.getErrorMessage()\n errorClass = qual(failure.type)\n frames = self._getFrames(failure)\n- self.ampProtocol.callRemote(\n- managercommands.AddError,\n- testName=testName,\n- error=error,\n- errorClass=errorClass,\n- frames=frames,\n+ await addError(\n+ self.ampProtocol,\n+ testName,\n+ errorClass,\n+ errorStr,\n+ frames,\n )\n \n- def addFailure(self, test, fail):\n+ def addError(self, test: PyUnitTestCase, error: TrialFailure) -> None:\n+ \"\"\"\n+ Send an error to the parent process.\n+ \"\"\"\n+ super().addError(test, error)\n+ testName = test.id()\n+ self._call(lambda: self.addErrorFallible(testName, error))\n+\n+ def addFailure(self, test: PyUnitTestCase, fail: TrialFailure) -> None:\n \"\"\"\n Send a Failure over.\n \"\"\"\n super().addFailure(test, fail)\n testName = test.id()\n failure = self._getFailure(fail)\n- fail = failure.getErrorMessage()\n+ failureMessage = failure.getErrorMessage()\n failClass = qual(failure.type)\n frames = self._getFrames(failure)\n- self.ampProtocol.callRemote(\n- managercommands.AddFailure,\n- testName=testName,\n- fail=fail,\n- failClass=failClass,\n- frames=frames,\n+ self._call(\n+ lambda: addFailure(\n+ self.ampProtocol,\n+ testName,\n+ failureMessage,\n+ failClass,\n+ frames,\n+ ),\n )\n \n def addSkip(self, test, reason):\n@@ -107,8 +303,10 @@ def addSkip(self, test, reason):\n super().addSkip(test, reason)\n reason = str(reason)\n testName = test.id()\n- self.ampProtocol.callRemote(\n- managercommands.AddSkip, testName=testName, reason=reason\n+ self._call(\n+ lambda: self.ampProtocol.callRemote(\n+ managercommands.AddSkip, testName=testName, reason=reason\n+ )\n )\n \n def _getTodoReason(self, todo):\n@@ -129,11 +327,13 @@ def addExpectedFailure(self, test, error, todo=None):\n super().addExpectedFailure(test, error, todo)\n errorMessage = error.getErrorMessage()\n testName = test.id()\n- self.ampProtocol.callRemote(\n- managercommands.AddExpectedFailure,\n- testName=testName,\n- error=errorMessage,\n- todo=self._getTodoReason(todo),\n+ self._call(\n+ lambda: addExpectedFailure(\n+ self.ampProtocol,\n+ testName=testName,\n+ error=errorMessage,\n+ todo=self._getTodoReason(todo),\n+ )\n )\n \n def addUnexpectedSuccess(self, test, todo=None):\n@@ -142,10 +342,12 @@ def addUnexpectedSuccess(self, test, todo=None):\n \"\"\"\n super().addUnexpectedSuccess(test, todo)\n testName = test.id()\n- self.ampProtocol.callRemote(\n- managercommands.AddUnexpectedSuccess,\n- testName=testName,\n- todo=self._getTodoReason(todo),\n+ self._call(\n+ lambda: self.ampProtocol.callRemote(\n+ managercommands.AddUnexpectedSuccess,\n+ testName=testName,\n+ todo=self._getTodoReason(todo),\n+ )\n )\n \n def printSummary(self):\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Failure: twisted.protocols.amp.UnknownRemoteError: Code: Unknown Error\n|[\"exarkun's](https://github.com/exarkun)| @exarkun reported|\n|-|-|\n|Trac ID|trac#10314|\n|Type|enhancement|\n|Created|2022-03-08 21:28:12Z|\n\nSometimes an application-level test failure causes `trial -jN ...` to report this error:\n\n```\nTraceback (most recent call last):\nFailure: twisted.protocols.amp.UnknownRemoteError: Code: Unknown Error\n[FAIL]\n```\n\nand then immediately exit with no further details.\n\nThe test which encountered the error and the details of the error are all lost, making it extremely difficult to diagnose and fix the problem.\n\n`trial -jN ...` should:\n\n* never fail this way\n* always report detailed errors in application code\n\n\n
Searchable metadata\n\n```\ntrac-id__10314 10314\ntype__enhancement enhancement\nreporter__exarkun exarkun\npriority__normal normal\nmilestone__None None\nbranch__ \nbranch_author__ \nstatus__new new\nresolution__None None\ncomponent__trial trial\nkeywords__None None\ntime__1646774892879232 1646774892879232\nchangetime__1646774892879232 1646774892879232\nversion__None None\nowner__None None\n\n```\n
\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2022-09-07T18:18:31Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\nFailure: twisted.protocols.amp.UnknownRemoteError: Code: Unknown Error\n[FAIL]\n```\n\nand then immediately exit with no further details.\n"},"__index_level_0__":{"kind":"number","value":18224,"string":"18,224"}}},{"rowIdx":1525,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-11878"},"base_commit":{"kind":"string","value":"be28750c20fa55aa344d608a1c0edbfc6da45066"},"patch":{"kind":"string","value":"diff --git a/src/twisted/internet/_sslverify.py b/src/twisted/internet/_sslverify.py\n--- a/src/twisted/internet/_sslverify.py\n+++ b/src/twisted/internet/_sslverify.py\n@@ -159,11 +159,8 @@ def _selectVerifyImplementation():\n )\n \n try:\n- from service_identity import VerificationError # type: ignore[import]\n- from service_identity.pyopenssl import ( # type: ignore[import]\n- verify_hostname,\n- verify_ip_address,\n- )\n+ from service_identity import VerificationError\n+ from service_identity.pyopenssl import verify_hostname, verify_ip_address\n \n return verify_hostname, verify_ip_address, VerificationError\n except ImportError as e:\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"trunk test failure: twisted.internet.test.test_endpoints.WrapClientTLSParserTests.test_tls fails with service_identity 23.1\ntests are failing on trunk again due to service_identity 23.1 release no longer honoring the CN fallback, which our test server.pem uses because it includes no SANs\r\n\r\nUpdated for posterity; it's this traceback: https://github.com/twisted/twisted/actions/runs/5222913768/jobs/9532027215\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/runner/work/twisted/twisted/.tox/alldeps-withcov-posix/lib/python3.10/site-packages/twisted/internet/test/test_endpoints.py\", line 4276, in test_tls\r\n self.assertFalse(plainClient.transport.disconnecting)\r\n File \"/home/runner/work/twisted/twisted/.tox/alldeps-withcov-posix/lib/python3.10/site-packages/twisted/trial/_synctest.py\", line 386, in assertFalse\r\n super().assertFalse(condition, msg)\r\n File \"/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/unittest/case.py\", line 681, in assertFalse\r\n raise self.failureException(msg)\r\ntwisted.trial.unittest.FailTest: True is not false\r\n\r\ntwisted.internet.test.test_endpoints.WrapClientTLSParserTests.test_tls\r\n```\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2023-06-14T20:43:38Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/home/runner/work/twisted/twisted/.tox/alldeps-withcov-posix/lib/python3.10/site-packages/twisted/internet/test/test_endpoints.py\", line 4276, in test_tls\r\n self.assertFalse(plainClient.transport.disconnecting)\r\n File \"/home/runner/work/twisted/twisted/.tox/alldeps-withcov-posix/lib/python3.10/site-packages/twisted/trial/_synctest.py\", line 386, in assertFalse\r\n super().assertFalse(condition, msg)\r\n File \"/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/unittest/case.py\", line 681, in assertFalse\r\n raise self.failureException(msg)\r\ntwisted.trial.unittest.FailTest: True is not false\r\n"},"__index_level_0__":{"kind":"number","value":18264,"string":"18,264"}}},{"rowIdx":1526,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-11909"},"base_commit":{"kind":"string","value":"a9ee8e59a5cd1950bf1a18c4b6ca813e5f56ad08"},"patch":{"kind":"string","value":"diff --git a/src/twisted/python/_tzhelper.py b/src/twisted/python/_tzhelper.py\n--- a/src/twisted/python/_tzhelper.py\n+++ b/src/twisted/python/_tzhelper.py\n@@ -6,7 +6,12 @@\n Time zone utilities.\n \"\"\"\n \n-from datetime import datetime as DateTime, timedelta as TimeDelta, tzinfo as TZInfo\n+from datetime import (\n+ datetime as DateTime,\n+ timedelta as TimeDelta,\n+ timezone,\n+ tzinfo as TZInfo,\n+)\n from typing import Optional\n \n __all__ = [\n@@ -68,9 +73,9 @@ def fromLocalTimeStamp(cls, timeStamp: float) -> \"FixedOffsetTimeZone\":\n Create a time zone with a fixed offset corresponding to a time stamp in\n the system's locally configured time zone.\n \"\"\"\n- offset = DateTime.fromtimestamp(timeStamp) - DateTime.utcfromtimestamp(\n- timeStamp\n- )\n+ offset = DateTime.fromtimestamp(timeStamp) - DateTime.fromtimestamp(\n+ timeStamp, timezone.utc\n+ ).replace(tzinfo=None)\n return cls(offset)\n \n def utcoffset(self, dt: Optional[DateTime]) -> TimeDelta:\ndiff --git a/src/twisted/python/log.py b/src/twisted/python/log.py\n--- a/src/twisted/python/log.py\n+++ b/src/twisted/python/log.py\n@@ -11,7 +11,7 @@\n import time\n import warnings\n from abc import ABC, abstractmethod\n-from datetime import datetime\n+from datetime import datetime, timezone\n from typing import Any, BinaryIO, Dict, Optional, cast\n \n from zope.interface import Interface\n@@ -490,7 +490,9 @@ def getTimezoneOffset(self, when):\n @return: The number of seconds offset from UTC. West is positive,\n east is negative.\n \"\"\"\n- offset = datetime.utcfromtimestamp(when) - datetime.fromtimestamp(when)\n+ offset = datetime.fromtimestamp(when, timezone.utc).replace(\n+ tzinfo=None\n+ ) - datetime.fromtimestamp(when)\n return offset.days * (60 * 60 * 24) + offset.seconds\n \n def formatTime(self, when):\n@@ -512,7 +514,9 @@ def formatTime(self, when):\n return datetime.fromtimestamp(when).strftime(self.timeFormat)\n \n tzOffset = -self.getTimezoneOffset(when)\n- when = datetime.utcfromtimestamp(when + tzOffset)\n+ when = datetime.fromtimestamp(when + tzOffset, timezone.utc).replace(\n+ tzinfo=None\n+ )\n tzHour = abs(int(tzOffset / 60 / 60))\n tzMin = abs(int(tzOffset / 60 % 60))\n if tzOffset < 0:\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Python 3.12: Deprecated utcnow and utcfromtimestamp\n**Describe the incorrect behavior you saw**\r\n`datetime.datetime.utcnow` and `datetime.datetime.utcfromtimestamp` raise deprecation warnings in Python 3.12.\r\n\r\n**Describe how to cause this behavior**\r\n\r\nWhile running trial on buildbot this generates lots of deprecation warnings like:\r\n```\r\nTraceback (most recent call last):\r\n File \"C:\\P\\twisted\\src\\twisted\\logger\\_observer.py\", line 81, in __call__\r\n observer(event)\r\n File \"C:\\P\\twisted\\src\\twisted\\logger\\_legacy.py\", line 90, in __call__\r\n self.legacyObserver(event)\r\n File \"C:\\P\\twisted\\src\\twisted\\python\\log.py\", line 544, in emit\r\n timeStr = self.formatTime(eventDict[\"time\"])\r\n File \"C:\\P\\twisted\\src\\twisted\\python\\log.py\", line 514, in formatTime\r\n tzOffset = -self.getTimezoneOffset(when)\r\n File \"C:\\P\\twisted\\src\\twisted\\python\\log.py\", line 493, in getTimezoneOffset\r\n offset = datetime.utcfromtimestamp(when) - datetime.fromtimestamp(when)\r\nbuiltins.DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).\r\nE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n```\r\n\r\nRunning buildbot trial with current HEAD & current trunk of twisted.\r\n\r\n**Describe the correct behavior you'd like to see**\r\nNo deprecation warning reported while running trial under python 3.12.\r\n\r\n**Testing environment**\r\n - Operating System and Version; paste the output of these commands:\r\n```\r\nOS Name: Microsoft Windows 11 Home\r\nOS Version: 10.0.22621 N/A Build 22621\r\nOS Manufacturer: Microsoft Corporation\r\nOS Configuration: Standalone Workstation\r\nOS Build Type: Multiprocessor Free\r\nSystem Manufacturer: Microsoft Corporation\r\nBIOS Version: Microsoft Corporation 15.11.140, 8. 7. 2022\r\n```\r\n - Twisted version\r\n 22.10.0.post0\r\n https://github.com/twisted/twisted/commit/a9ee8e59a5cd1950bf1a18c4b6ca813e5f56ad08\r\n - Reactor [e.g. select, iocp]\r\n `twisted-iocpsupport 1.0.4`\r\n\r\n\r\n**Additional context**\r\n - Deprecate utcnow and utcfromtimestamp python/cpython#103857\r\n - https://blog.ganssle.io/articles/2019/11/utcnow.html\r\n\n"},"hints_text":{"kind":"string","value":"Thanks for the report.\r\n\r\nHappy to receive a PR with a fix for this :)"},"created_at":{"kind":"string","value":"2023-08-16T11:44:38Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"C:\\P\\twisted\\src\\twisted\\logger\\_observer.py\", line 81, in __call__\r\n observer(event)\r\n File \"C:\\P\\twisted\\src\\twisted\\logger\\_legacy.py\", line 90, in __call__\r\n self.legacyObserver(event)\r\n File \"C:\\P\\twisted\\src\\twisted\\python\\log.py\", line 544, in emit\r\n timeStr = self.formatTime(eventDict[\"time\"])\r\n File \"C:\\P\\twisted\\src\\twisted\\python\\log.py\", line 514, in formatTime\r\n tzOffset = -self.getTimezoneOffset(when)\r\n File \"C:\\P\\twisted\\src\\twisted\\python\\log.py\", line 493, in getTimezoneOffset\r\n offset = datetime.utcfromtimestamp(when) - datetime.fromtimestamp(when)\r\nbuiltins.DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).\r\n"},"__index_level_0__":{"kind":"number","value":18267,"string":"18,267"}}},{"rowIdx":1527,"cells":{"repo":{"kind":"string","value":"twisted/twisted"},"instance_id":{"kind":"string","value":"twisted__twisted-778"},"base_commit":{"kind":"string","value":"2d37db4491298380c846cb2537c45d129458550b"},"patch":{"kind":"string","value":"diff --git a/src/twisted/web/client.py b/src/twisted/web/client.py\n--- a/src/twisted/web/client.py\n+++ b/src/twisted/web/client.py\n@@ -411,14 +411,21 @@ def _cancelTimeout(self, result, timeoutCall):\n return result\n \n def gotHeaders(self, headers):\n+ \"\"\"\n+ Parse the response HTTP headers.\n+\n+ @param headers: The response HTTP headers.\n+ @type headers: L{dict}\n+ \"\"\"\n self.response_headers = headers\n if b'set-cookie' in headers:\n for cookie in headers[b'set-cookie']:\n- cookparts = cookie.split(b';')\n- cook = cookparts[0]\n- cook.lstrip()\n- k, v = cook.split(b'=', 1)\n- self.cookies[k.lstrip()] = v.lstrip()\n+ if b'=' in cookie:\n+ cookparts = cookie.split(b';')\n+ cook = cookparts[0]\n+ cook.lstrip()\n+ k, v = cook.split(b'=', 1)\n+ self.cookies[k.lstrip()] = v.lstrip()\n \n def gotStatus(self, version, status, message):\n \"\"\"\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Wrong Set-Cookie header causes a traceback in Twisted\n|[\"itshane's](https://github.com/itshane)| @itshane reported|\n|-|-|\n|Trac ID|trac#9136|\n|Type|defect|\n|Created|2017-05-15 08:06:56Z|\n\nWhen the Set-Cookie header comes as a list which just contains the following \"HttpOnly;Secure\" string, it causes a \"exceptions.ValueError: need more than 1 value to unpack\" traceback.\n\n```\nUnhandled Error\nTraceback (most recent call last):\n File \"/usr/lib/python2.7/site-packages/twisted/python/log.py\", line 101, in callWithLogger\n return callWithContext({\"system\": lp}, func, *args, **kw)\n File \"/usr/lib/python2.7/site-packages/twisted/python/log.py\", line 84, in callWithContext\n return context.call({ILogContext: newCtx}, func, *args, **kw)\n File \"/usr/lib/python2.7/site-packages/twisted/python/context.py\", line 118, in callWithContext\n return self.currentContext().callWithContext(ctx, func, *args, **kw)\n File \"/usr/lib/python2.7/site-packages/twisted/python/context.py\", line 81, in callWithContext\n return func(*args,**kw)\n--- ---\n File \"/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py\", line 597, in _doReadOrWrite\n why = selectable.doRead()\n File \"/usr/lib/python2.7/site-packages/twisted/internet/tcp.py\", line 209, in doRead\n return self._dataReceived(data)\n File \"/usr/lib/python2.7/site-packages/twisted/internet/tcp.py\", line 215, in _dataReceived\n rval = self.protocol.dataReceived(data)\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/tls.py\", line 422, in dataReceived\n self._flushReceiveBIO()\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/tls.py\", line 392, in _flushReceiveBIO\n ProtocolWrapper.dataReceived(self, bytes)\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/policies.py\", line 120, in dataReceived\n self.wrappedProtocol.dataReceived(data)\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/basic.py\", line 571, in dataReceived\n why = self.lineReceived(line)\n File \"/usr/lib/python2.7/site-packages/twisted/web/http.py\", line 459, in lineReceived\n self.handleEndHeaders()\n File \"/usr/lib/python2.7/site-packages/twisted/web/client.py\", line 144, in handleEndHeaders\n self.factory.gotHeaders(self.headers)\n File \"/usr/lib/python2.7/site-packages/twisted/web/client.py\", line 420, in gotHeaders\n k, v = cook.split(b'=', 1)\nexceptions.ValueError: need more than 1 value to unpack\n```\n\nIt would be better just to omit the wrong part of the header, therefore, a response can be gracefully processed.\n\n
Searchable metadata\n\n```\ntrac-id__9136 9136\ntype__defect defect\nreporter__itshane itshane\npriority__normal normal\nmilestone__None None\nbranch__ \nbranch_author__ \nstatus__closed closed\nresolution__fixed fixed\ncomponent__web web\nkeywords__None None\ntime__1494835616649140 1494835616649140\nchangetime__1502610226137736 1502610226137736\nversion__None None\nowner__itshane itshane\n\n```\n
\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2017-05-12T09:17:21Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/usr/lib/python2.7/site-packages/twisted/python/log.py\", line 101, in callWithLogger\n return callWithContext({\"system\": lp}, func, *args, **kw)\n File \"/usr/lib/python2.7/site-packages/twisted/python/log.py\", line 84, in callWithContext\n return context.call({ILogContext: newCtx}, func, *args, **kw)\n File \"/usr/lib/python2.7/site-packages/twisted/python/context.py\", line 118, in callWithContext\n return self.currentContext().callWithContext(ctx, func, *args, **kw)\n File \"/usr/lib/python2.7/site-packages/twisted/python/context.py\", line 81, in callWithContext\n return func(*args,**kw)\n--- ---\n File \"/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py\", line 597, in _doReadOrWrite\n why = selectable.doRead()\n File \"/usr/lib/python2.7/site-packages/twisted/internet/tcp.py\", line 209, in doRead\n return self._dataReceived(data)\n File \"/usr/lib/python2.7/site-packages/twisted/internet/tcp.py\", line 215, in _dataReceived\n rval = self.protocol.dataReceived(data)\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/tls.py\", line 422, in dataReceived\n self._flushReceiveBIO()\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/tls.py\", line 392, in _flushReceiveBIO\n ProtocolWrapper.dataReceived(self, bytes)\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/policies.py\", line 120, in dataReceived\n self.wrappedProtocol.dataReceived(data)\n File \"/usr/lib/python2.7/site-packages/twisted/protocols/basic.py\", line 571, in dataReceived\n why = self.lineReceived(line)\n File \"/usr/lib/python2.7/site-packages/twisted/web/http.py\", line 459, in lineReceived\n self.handleEndHeaders()\n File \"/usr/lib/python2.7/site-packages/twisted/web/client.py\", line 144, in handleEndHeaders\n self.factory.gotHeaders(self.headers)\n File \"/usr/lib/python2.7/site-packages/twisted/web/client.py\", line 420, in gotHeaders\n k, v = cook.split(b'=', 1)\nexceptions.ValueError: need more than 1 value to unpack\n"},"__index_level_0__":{"kind":"number","value":18277,"string":"18,277"}}},{"rowIdx":1528,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1013"},"base_commit":{"kind":"string","value":"ab83e3b4a89b5c7b31a965d85d950d93a9d74daa"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailimages/views/images.py b/wagtail/wagtailimages/views/images.py\n--- a/wagtail/wagtailimages/views/images.py\n+++ b/wagtail/wagtailimages/views/images.py\n@@ -119,10 +119,18 @@ def edit(request, image_id):\n except NoReverseMatch:\n url_generator_enabled = False\n \n+ # Get file size\n+ try:\n+ filesize = image.file.size\n+ except OSError:\n+ # File doesn't exist\n+ filesize = None\n+\n return render(request, \"wagtailimages/images/edit.html\", {\n 'image': image,\n 'form': form,\n 'url_generator_enabled': url_generator_enabled,\n+ 'filesize': filesize,\n })\n \n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"OSError when image file is missing\nIf an image entry exists within Wagtail for which the cosponsoring filesystem path does not exist an `OSError` is thrown.\n\n```\nTraceback (most recent call last):\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, *args, **kwargs)\n File \"/srv/django/site/env/lib/python2.7/site-packages/wagtail/wagtailimages/views/images.py\", line 126, in edit\n 'url_generator_enabled': url_generator_enabled,\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/shortcuts.py\", line 50, in render\n return HttpResponse(loader.render_to_string(*args, **kwargs),\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader.py\", line 178, in render_to_string\n return t.render(context_instance)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 148, in render\n return self._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 126, in render\n return compiled_parent._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 126, in render\n return compiled_parent._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 126, in render\n return compiled_parent._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 65, in render\n result = block.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 65, in render\n result = block.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 898, in render\n output = self.filter_expression.resolve(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 596, in resolve\n obj = self.var.resolve(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 734, in resolve\n value = self._resolve_lookup(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 770, in _resolve_lookup\n current = getattr(current, bit)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/db/models/fields/files.py\", line 74, in _get_size\n return self.storage.size(self.name)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/core/files/storage.py\", line 285, in size\n return os.path.getsize(self.path(name))\n File \"/srv/django/site/env/lib/python2.7/genericpath.py\", line 49, in getsize\n return os.stat(filename).st_size\nOSError: [Errno 2] No such file or directory: '/srv/django/site/media/original_images/img-17686908.jpg'\n```\n\n"},"hints_text":{"kind":"string","value":"We fixed a similar issue in `0.8.3` (see: https://github.com/torchbox/wagtail/blob/e0fe9af555e4e9f9b731c52f69d2c86746c02ffc/CHANGELOG.txt#L46). Are you using the latest version?\n\nI'm on the master branch as the MySQL migration fix hasn't made it to pypi yet.\n\nJust had a closer look at your traceback and I think I've spotted the problem.\n\nIt looks like you're not using Wagtails `{% image %}` tag for rendering the image which would usually catch this exception.\n\nIf you'd like to show your image at it's original size, I'd recommend using the `original` filter like so: `{% image myimage original %}`. (http://docs.wagtail.io/en/latest/core_components/images/index.html#using-images-in-templates)\n\nI should have been more explicit in my bug report. This occurs in the Wagtail backend when the file system path to the uploaded original image doesn't exist any more.\n\n**Steps to reproduce**\n- Upload an image in the wagtail backend\n- rm the file\n- View the file page in the Wagtail backend\n\nThis prevents deletion of the related db entries via the Wagtail interface without re-adding a file at that path.\n\nOhh, apologies for the confusion.\n\nI'll look into this further\n\nI can confirm that this is a bug introduced in Wagtail 0.9.\n\nIt appears that we are now reading the file to check its size but are not checking that it exists first. https://github.com/torchbox/wagtail/commit/9fe6f04d7b11a0d3c7fc6c850e290b94bd29f126\n\nIs this a meaningful bug? I'm not particularly convinced :-) We have fallback behaviour on front-end templates for missing image files, as a convenience to developers - so that they can pull down live database snapshots to their local development version and still be able to render templates. But if you're going in to the image admin area and editing actual image records, there's a reasonable expectation that the image ought to exist, and it's not unreasonable for Wagtail to throw an error if it doesn't.\n\nI think it's a bug.\n\nWagtail `0.8.x` didn't do it and Wagtail `0.9.x` only does it due to an unintended side effect of getting the filesize of the nonexistant image in the template.\n\nIf we want Wagtail to crash in this case, I think we should be explicity telling Wagtail to crash instead of relying on `file.size` to crash for us. And add a test for it.\n\nIt's a bug for sure but not a major one. It would just be more convenient to be able to delete the image entry via the wagtail UI in the case of a missing file rather than either having to resort to `./manage.py shell`, direct database access or putting a dummy file in place.\n\n@kaedroho Well, that's just the nature of undefined behaviour... just because something worked by chance in the past doesn't mean that we should commit to it continuing to work, or failing in a predictable way. And I think there's merit in leaving behaviour undefined sometimes, providing it doesn't interfere with normal use of the system - it means there's one fewer edge case to account for when we refactor the code in future.\n\nHaving said that - if you're willing to fix this and commit to maintaining a particular behaviour in future, go ahead!\n\n@gasman I think it depends on whether you want to program defensively or not. Generally my principle with regards to I/O is always presume it's going to fail in some edge cases and be as defensive as possible.\n"},"created_at":{"kind":"string","value":"2015-02-19T20:03:26Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, *args, **kwargs)\n File \"/srv/django/site/env/lib/python2.7/site-packages/wagtail/wagtailimages/views/images.py\", line 126, in edit\n 'url_generator_enabled': url_generator_enabled,\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/shortcuts.py\", line 50, in render\n return HttpResponse(loader.render_to_string(*args, **kwargs),\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader.py\", line 178, in render_to_string\n return t.render(context_instance)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 148, in render\n return self._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 126, in render\n return compiled_parent._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 126, in render\n return compiled_parent._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 126, in render\n return compiled_parent._render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 142, in _render\n return self.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 65, in render\n result = block.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/loader_tags.py\", line 65, in render\n result = block.nodelist.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 844, in render\n bit = self.render_node(node, context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 858, in render_node\n return node.render(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 898, in render\n output = self.filter_expression.resolve(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 596, in resolve\n obj = self.var.resolve(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 734, in resolve\n value = self._resolve_lookup(context)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/template/base.py\", line 770, in _resolve_lookup\n current = getattr(current, bit)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/db/models/fields/files.py\", line 74, in _get_size\n return self.storage.size(self.name)\n File \"/srv/django/site/env/lib/python2.7/site-packages/django/core/files/storage.py\", line 285, in size\n return os.path.getsize(self.path(name))\n File \"/srv/django/site/env/lib/python2.7/genericpath.py\", line 49, in getsize\n return os.stat(filename).st_size\nOSError: [Errno 2] No such file or directory: '/srv/django/site/media/original_images/img-17686908.jpg'\n"},"__index_level_0__":{"kind":"number","value":18293,"string":"18,293"}}},{"rowIdx":1529,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1218"},"base_commit":{"kind":"string","value":"0e926e839946274c2dce1b987a755816c8e681bf"},"patch":{"kind":"string","value":"diff --git a/wagtail/contrib/wagtailfrontendcache/utils.py b/wagtail/contrib/wagtailfrontendcache/utils.py\n--- a/wagtail/contrib/wagtailfrontendcache/utils.py\n+++ b/wagtail/contrib/wagtailfrontendcache/utils.py\n@@ -61,8 +61,12 @@ def purge_url_from_cache(url, backend_settings=None, backends=None):\n \n \n def purge_page_from_cache(page, backend_settings=None, backends=None):\n+ page_url = page.full_url\n+ if page_url is None: # nothing to be done if the page has no routable URL\n+ return\n+\n for backend_name, backend in get_backends(backend_settings=backend_settings, backends=backends).items():\n # Purge cached paths from cache\n for path in page.specific.get_cached_paths():\n- logger.info(\"[%s] Purging URL: %s\", backend_name, page.full_url + path[1:])\n- backend.purge(page.full_url + path[1:])\n+ logger.info(\"[%s] Purging URL: %s\", backend_name, page_url + path[1:])\n+ backend.purge(page_url + path[1:])\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"wagtailfrontendcache throws an error when a root page is created without a site\nOn a new install of wagtail w/ wagtailfrontendcache enabled, I go through the following steps:\n1. Go to the admin\n2. Delete the default \"welcome\" page from the database\n3. Create a new root page\n\nAfter I create the new root page, I get the following error:\n\n```\n[17/Apr/2015 20:02:28] ERROR [django.request:231] Internal Server Error: /admin/pages/new/pages/genericpage/1/\nTraceback (most recent call last):\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, *args, **kwargs)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/wagtailadmin/views/pages.py\", line 211, in create\n revision.publish()\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/wagtailcore/models.py\", line 1141, in publish\n page_published.send(sender=page.specific_class, instance=page.specific)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/django/dispatch/dispatcher.py\", line 198, in send\n response = receiver(signal=self, sender=sender, **named)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/contrib/wagtailfrontendcache/signal_handlers.py\", line 9, in page_published_signal_handler\n purge_page_from_cache(instance)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/contrib/wagtailfrontendcache/utils.py\", line 100, in purge_page_from_cache\n logger.info(\"[%s] Purging URL: %s\", backend_name, page.full_url + path[1:])\nTypeError: unsupported operand type(s) for +: 'NoneType' and 'str'\n```\n\nDigging into the code, this error is the request of the following line:\n\n```\nlogger.info(\"[%s] Purging URL: %s\", backend_name, page.full_url + path[1:])\n```\n\nThis line failes because `page.full_url` is set to `None` when it executes, which results in the line throwing an exception. The new page model is still saved, so I just need to refresh the admin in my browser to get back into a good working state.\n\n"},"hints_text":{"kind":"string","value":"The workaround for this issue is to register the new root page as the root of a new site in Wagtail. When the last root page is deleted, it looks like the Site record is also removed from the system. \n\nOne caveat though is that it seems that this error will still occur when new root pages are created.\n\nHi @strife25,\nThank you for the report. You are hitting the bug described in #687.\n\nClosing this as duplicate. Will work on issuing a warning as proposed in https://github.com/torchbox/wagtail/issues/687#issuecomment-60032801\n\nI think this is different to #687, although the two are certainly related...\n\nThe way that the page/site model is designed makes it possible for a page to have no routable URL. This in itself is not a bug - although it's not something that you'd intentionally want to happen, so it's appropriate to give a warning as per #687.\n\nNevertheless, a page with no routable URL is still perfectly valid, and wagtailfrontendcache ought to be fixed so that it doesn't break in the presence of such pages.\n\nFair enough.\n\nWhat is the desired behaviour in this case? Only add `page.full_url` to the purge string when it is not None? Or skip the purge all together?\n\nI'm not really familiar with wagtailfrontendcache's behaviour, but it seems to me that it would be appropriate to simply skip the page. If a page is not accessible at any URL, then there's no way that it can exist in a front-end cache in the first place.\n"},"created_at":{"kind":"string","value":"2015-04-20T19:04:18Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, *args, **kwargs)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/wagtailadmin/views/pages.py\", line 211, in create\n revision.publish()\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/wagtailcore/models.py\", line 1141, in publish\n page_published.send(sender=page.specific_class, instance=page.specific)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/django/dispatch/dispatcher.py\", line 198, in send\n response = receiver(signal=self, sender=sender, **named)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/contrib/wagtailfrontendcache/signal_handlers.py\", line 9, in page_published_signal_handler\n purge_page_from_cache(instance)\n File \"/Users/jryding/.virtualenvs/cms/lib/python2.7/site-packages/wagtail/contrib/wagtailfrontendcache/utils.py\", line 100, in purge_page_from_cache\n logger.info(\"[%s] Purging URL: %s\", backend_name, page.full_url + path[1:])\nTypeError: unsupported operand type(s) for +: 'NoneType' and 'str'\n"},"__index_level_0__":{"kind":"number","value":18353,"string":"18,353"}}},{"rowIdx":1530,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1368"},"base_commit":{"kind":"string","value":"5bcd7841da6964dc0b3366b61383c7b28e5a62c1"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailimages/fields.py b/wagtail/wagtailimages/fields.py\n--- a/wagtail/wagtailimages/fields.py\n+++ b/wagtail/wagtailimages/fields.py\n@@ -12,60 +12,46 @@\n ALLOWED_EXTENSIONS = ['gif', 'jpg', 'jpeg', 'png']\n SUPPORTED_FORMATS_TEXT = _(\"GIF, JPEG, PNG\")\n \n-INVALID_IMAGE_ERROR = _(\n- \"Not a supported image format. Supported formats: %s.\"\n-) % SUPPORTED_FORMATS_TEXT\n-\n-INVALID_IMAGE_KNOWN_FORMAT_ERROR = _(\n- \"Not a valid %s image.\"\n-)\n-\n-MAX_UPLOAD_SIZE = getattr(settings, 'WAGTAILIMAGES_MAX_UPLOAD_SIZE', 10 * 1024 * 1024)\n-\n-if MAX_UPLOAD_SIZE is not None:\n- MAX_UPLOAD_SIZE_TEXT = filesizeformat(MAX_UPLOAD_SIZE)\n-\n- FILE_TOO_LARGE_ERROR = _(\n- \"This file is too big. Maximum filesize %(max_upload_size)s.\"\n- ) % {\n- 'max_upload_size': MAX_UPLOAD_SIZE_TEXT,\n- }\n-\n- FILE_TOO_LARGE_KNOWN_SIZE_ERROR = _(\n- \"This file is too big (%%(max_upload_size)s). Maximum filesize %s.\"\n- ) % {\n- 'max_upload_size': MAX_UPLOAD_SIZE_TEXT,\n- }\n-\n- IMAGE_FIELD_HELP_TEXT = _(\n- \"Supported formats: %(supported_formats)s. Maximum filesize: %(max_upload_size)s.\"\n- ) % {\n- 'supported_formats': SUPPORTED_FORMATS_TEXT,\n- 'max_upload_size': MAX_UPLOAD_SIZE_TEXT,\n- }\n-else:\n- MAX_UPLOAD_SIZE_TEXT = \"\"\n- FILE_TOO_LARGE_ERROR = \"\"\n- FILE_TOO_LARGE_KNOWN_SIZE_ERROR = \"\"\n-\n- IMAGE_FIELD_HELP_TEXT = _(\n- \"Supported formats: %(supported_formats)s.\"\n- ) % {\n- 'supported_formats': SUPPORTED_FORMATS_TEXT,\n- }\n-\n \n class WagtailImageField(ImageField):\n- default_error_messages = {\n- 'invalid_image': INVALID_IMAGE_ERROR,\n- 'invalid_image_known_format': INVALID_IMAGE_KNOWN_FORMAT_ERROR,\n- 'file_too_large': FILE_TOO_LARGE_KNOWN_SIZE_ERROR,\n- }\n-\n def __init__(self, *args, **kwargs):\n super(WagtailImageField, self).__init__(*args, **kwargs)\n \n- self.help_text = IMAGE_FIELD_HELP_TEXT\n+ # Get max upload size from settings\n+ self.max_upload_size = getattr(settings, 'WAGTAILIMAGES_MAX_UPLOAD_SIZE', 10 * 1024 * 1024)\n+ max_upload_size_text = filesizeformat(self.max_upload_size)\n+\n+ # Help text\n+ if self.max_upload_size is not None:\n+ self.help_text = _(\n+ \"Supported formats: %(supported_formats)s. Maximum filesize: %(max_upload_size)s.\"\n+ ) % {\n+ 'supported_formats': SUPPORTED_FORMATS_TEXT,\n+ 'max_upload_size': max_upload_size_text,\n+ }\n+ else:\n+ self.help_text = _(\n+ \"Supported formats: %(supported_formats)s.\"\n+ ) % {\n+ 'supported_formats': SUPPORTED_FORMATS_TEXT,\n+ }\n+\n+ # Error messages\n+ self.error_messages['invalid_image'] = _(\n+ \"Not a supported image format. Supported formats: %s.\"\n+ ) % SUPPORTED_FORMATS_TEXT\n+\n+ self.error_messages['invalid_image_known_format'] = _(\n+ \"Not a valid %s image.\"\n+ )\n+\n+ self.error_messages['file_too_large'] = _(\n+ \"This file is too big (%%s). Maximum filesize %s.\"\n+ ) % max_upload_size_text\n+\n+ self.error_messages['file_too_large_unknown_size'] = _(\n+ \"This file is too big. Maximum filesize %s.\"\n+ ) % max_upload_size_text\n \n def check_image_file_format(self, f):\n # Check file extension\n@@ -111,11 +97,11 @@ def check_image_file_format(self, f):\n \n def check_image_file_size(self, f):\n # Upload size checking can be disabled by setting max upload size to None\n- if MAX_UPLOAD_SIZE is None:\n+ if self.max_upload_size is None:\n return\n \n # Check the filesize\n- if f.size > MAX_UPLOAD_SIZE:\n+ if f.size > self.max_upload_size:\n raise ValidationError(self.error_messages['file_too_large'] % (\n filesizeformat(f.size),\n ), code='file_too_large')\ndiff --git a/wagtail/wagtailimages/views/chooser.py b/wagtail/wagtailimages/views/chooser.py\n--- a/wagtail/wagtailimages/views/chooser.py\n+++ b/wagtail/wagtailimages/views/chooser.py\n@@ -12,7 +12,6 @@\n from wagtail.wagtailimages.models import get_image_model\n from wagtail.wagtailimages.forms import get_image_form, ImageInsertionForm\n from wagtail.wagtailimages.formats import get_image_format\n-from wagtail.wagtailimages.fields import MAX_UPLOAD_SIZE\n \n \n def get_image_json(image):\n@@ -147,7 +146,7 @@ def chooser_upload(request):\n \n return render_modal_workflow(\n request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js',\n- {'images': images, 'uploadform': form, 'searchform': searchform, 'max_filesize': MAX_UPLOAD_SIZE}\n+ {'images': images, 'uploadform': form, 'searchform': searchform}\n )\n \n \ndiff --git a/wagtail/wagtailimages/views/images.py b/wagtail/wagtailimages/views/images.py\n--- a/wagtail/wagtailimages/views/images.py\n+++ b/wagtail/wagtailimages/views/images.py\n@@ -17,7 +17,6 @@\n from wagtail.wagtailimages.models import get_image_model, Filter\n from wagtail.wagtailimages.forms import get_image_form, URLGeneratorForm\n from wagtail.wagtailimages.utils import generate_signature\n-from wagtail.wagtailimages.fields import MAX_UPLOAD_SIZE\n from wagtail.wagtailimages.exceptions import InvalidFilterSpecError\n \n \n@@ -252,7 +251,6 @@ def add(request):\n \n return render(request, \"wagtailimages/images/add.html\", {\n 'form': form,\n- 'max_filesize': MAX_UPLOAD_SIZE,\n })\n \n \ndiff --git a/wagtail/wagtailimages/views/multiple.py b/wagtail/wagtailimages/views/multiple.py\n--- a/wagtail/wagtailimages/views/multiple.py\n+++ b/wagtail/wagtailimages/views/multiple.py\n@@ -12,13 +12,7 @@\n \n from wagtail.wagtailimages.models import get_image_model\n from wagtail.wagtailimages.forms import get_image_form\n-from wagtail.wagtailimages.fields import (\n- MAX_UPLOAD_SIZE,\n- IMAGE_FIELD_HELP_TEXT,\n- INVALID_IMAGE_ERROR,\n- ALLOWED_EXTENSIONS,\n- FILE_TOO_LARGE_ERROR,\n-)\n+from wagtail.wagtailimages.fields import ALLOWED_EXTENSIONS\n from wagtail.utils.compat import render_to_string\n \n \n@@ -87,13 +81,15 @@ def add(request):\n # https://github.com/django/django/blob/stable/1.6.x/django/forms/util.py#L45\n 'error_message': '\\n'.join(['\\n'.join([force_text(i) for i in v]) for k, v in form.errors.items()]),\n })\n+ else:\n+ form = ImageForm()\n \n return render(request, 'wagtailimages/multiple/add.html', {\n- 'max_filesize': MAX_UPLOAD_SIZE,\n- 'help_text': IMAGE_FIELD_HELP_TEXT,\n+ 'max_filesize': form.fields['file'].max_upload_size,\n+ 'help_text': form.fields['file'].help_text,\n 'allowed_extensions': ALLOWED_EXTENSIONS,\n- 'error_max_file_size': FILE_TOO_LARGE_ERROR,\n- 'error_accepted_file_types': INVALID_IMAGE_ERROR,\n+ 'error_max_file_size': form.fields['file'].error_messages['file_too_large_unknown_size'],\n+ 'error_accepted_file_types': form.fields['file'].error_messages['invalid_image'],\n })\n \n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Error uploading image\nTraceback (most recent call last):\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, _callback_args, *_callback_kwargs)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/views/decorators/cache.py\", line 38, in _cache_controlled\n response = viewfunc(request, _args, *_kw)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, _args, *_kwargs)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, _args, *_kwargs)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/wagtail/wagtailimages/views/chooser.py\", line 124, in chooser_upload\n if form.is_valid():\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 162, in is_valid\n return self.is_bound and not bool(self.errors)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 154, in errors\n self.full_clean()\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 353, in full_clean\n self._clean_fields()\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 366, in _clean_fields\n value = field.clean(value, initial)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/fields.py\", line 606, in clean\n return super(FileField, self).clean(data)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/fields.py\", line 150, in clean\n value = self.to_python(value)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/wagtail/wagtailimages/fields.py\", line 127, in to_python\n self.check_image_file_size(f)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/wagtail/wagtailimages/fields.py\", line 120, in check_image_file_size\n filesizeformat(f.size),\nTypeError: format requires a mapping\n\n"},"hints_text":{"kind":"string","value":"Sorry, this happens on version 1.0b2\n\nWhat version of Django are you using?\n\nThis appears to be caused by a bad format string replacement:\nhttps://github.com/torchbox/wagtail/blob/f490c99934a7594ce4ad85c756d36a21c173a4be/wagtail/wagtailimages/fields.py#L34-L38\nhttps://github.com/torchbox/wagtail/blob/f490c99934a7594ce4ad85c756d36a21c173a4be/wagtail/wagtailimages/fields.py#L119-L121\n(using a tuple instead of a dict)\n\nI noticed a few other places in that file which could potentially cause issues so I think it's worth cleaning that up a bit.\n"},"created_at":{"kind":"string","value":"2015-06-03T14:09:48Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, _callback_args, *_callback_kwargs)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/views/decorators/cache.py\", line 38, in _cache_controlled\n response = viewfunc(request, _args, *_kw)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, _args, *_kwargs)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, _args, *_kwargs)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/wagtail/wagtailimages/views/chooser.py\", line 124, in chooser_upload\n if form.is_valid():\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 162, in is_valid\n return self.is_bound and not bool(self.errors)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 154, in errors\n self.full_clean()\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 353, in full_clean\n self._clean_fields()\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/forms.py\", line 366, in _clean_fields\n value = field.clean(value, initial)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/fields.py\", line 606, in clean\n return super(FileField, self).clean(data)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/django/forms/fields.py\", line 150, in clean\n value = self.to_python(value)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/wagtail/wagtailimages/fields.py\", line 127, in to_python\n self.check_image_file_size(f)\n File \"/home/vagrant/webproject/aroucageopark/virtualenv/local/lib/python2.7/site-packages/wagtail/wagtailimages/fields.py\", line 120, in check_image_file_size\n filesizeformat(f.size),\nTypeError: format requires a mapping\n"},"__index_level_0__":{"kind":"number","value":18363,"string":"18,363"}}},{"rowIdx":1531,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1406"},"base_commit":{"kind":"string","value":"0d5cd61b01c496322c7a74d78c4a397f4c1a0fda"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailadmin/menu.py b/wagtail/wagtailadmin/menu.py\n--- a/wagtail/wagtailadmin/menu.py\n+++ b/wagtail/wagtailadmin/menu.py\n@@ -1,13 +1,16 @@\n from __future__ import unicode_literals\n \n-from six import text_type, with_metaclass\n+from six import text_type\n \n from django.forms import MediaDefiningClass, Media\n from django.forms.utils import flatatt\n from django.utils.text import slugify\n from django.utils.safestring import mark_safe\n-from wagtail.utils.compat import render_to_string\n \n+# Must be imported from Django so we get the new implementation of with_metaclass\n+from django.utils.six import with_metaclass\n+\n+from wagtail.utils.compat import render_to_string\n from wagtail.wagtailcore import hooks\n \n \ndiff --git a/wagtail/wagtailcore/blocks/stream_block.py b/wagtail/wagtailcore/blocks/stream_block.py\n--- a/wagtail/wagtailcore/blocks/stream_block.py\n+++ b/wagtail/wagtailcore/blocks/stream_block.py\n@@ -10,7 +10,8 @@\n from django.utils.html import format_html_join\n from django.utils.safestring import mark_safe\n \n-import six\n+# Must be imported from Django so we get the new implementation of with_metaclass\n+from django.utils import six\n \n from wagtail.wagtailcore.utils import escape_script\n \ndiff --git a/wagtail/wagtailcore/blocks/struct_block.py b/wagtail/wagtailcore/blocks/struct_block.py\n--- a/wagtail/wagtailcore/blocks/struct_block.py\n+++ b/wagtail/wagtailcore/blocks/struct_block.py\n@@ -9,7 +9,8 @@\n from django.utils.functional import cached_property\n from django.utils.html import format_html, format_html_join\n \n-import six\n+# Must be imported from Django so we get the new implementation of with_metaclass\n+from django.utils import six\n \n from .base import Block, DeclarativeSubBlocksMetaclass\n from .utils import js_dict\ndiff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py\n--- a/wagtail/wagtailcore/models.py\n+++ b/wagtail/wagtailcore/models.py\n@@ -3,7 +3,6 @@\n import logging\n import json\n \n-import six\n from six import StringIO\n from six.moves.urllib.parse import urlparse\n \n@@ -29,6 +28,9 @@\n from django.utils.encoding import python_2_unicode_compatible\n from django.core import checks\n \n+# Must be imported from Django so we get the new implementation of with_metaclass\n+from django.utils import six\n+\n from treebeard.mp_tree import MP_Node\n \n from wagtail.wagtailcore.utils import camelcase_to_underscore, resolve_model_string\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Creating first site as per documentation page - db migrations fail\nShortcut guide documentation: https://wagtail.io/developers/\n\nInstalls fine:\n\n```\nsamm-mbp ~ % sudo pip install wagtail\nPassword:\nThe directory '/Users/samm/Library/Logs/pip' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.\nThe directory '/Users/samm/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.\nThe directory '/Users/samm/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.\nCollecting wagtail\n Downloading wagtail-0.8.7.tar.gz (1.8MB)\n 100% |################################| 1.8MB 70kB/s\nCollecting Django<1.8,>=1.6.2 (from wagtail)\n Downloading Django-1.7.8-py2.py3-none-any.whl (7.4MB)\n 100% |################################| 7.4MB 27kB/s\nCollecting South==1.0.0 (from wagtail)\n Downloading South-1.0.tar.gz (97kB)\n 100% |################################| 98kB 100kB/s\nCollecting django-compressor>=1.4 (from wagtail)\n Downloading django_compressor-1.5-py2.py3-none-any.whl (129kB)\n 100% |################################| 131kB 101kB/s\nCollecting django-libsass>=0.2 (from wagtail)\n Downloading django-libsass-0.3.tar.gz\nCollecting django-modelcluster>=0.4 (from wagtail)\n Downloading django-modelcluster-0.6.2.tar.gz\nCollecting django-taggit==0.12.3 (from wagtail)\n Downloading django_taggit-0.12.3-py2.py3-none-any.whl\nCollecting django-treebeard==2.0 (from wagtail)\n Downloading django-treebeard-2.0.tar.gz (92kB)\n 100% |################################| 94kB 179kB/s\nCollecting Pillow>=2.6.1 (from wagtail)\n Downloading Pillow-2.8.2-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (2.8MB)\n 100% |################################| 2.8MB 35kB/s\nCollecting beautifulsoup4>=4.3.2 (from wagtail)\n Downloading beautifulsoup4-4.3.2.tar.gz (143kB)\n 100% |################################| 143kB 97kB/s\nCollecting html5lib==0.999 (from wagtail)\n Downloading html5lib-0.999.tar.gz (885kB)\n 100% |################################| 888kB 99kB/s\nRequirement already satisfied (use --upgrade to upgrade): Unidecode>=0.04.14 in /Library/Python/2.7/site-packages (from wagtail)\nRequirement already satisfied (use --upgrade to upgrade): six>=1.7.0 in /Library/Python/2.7/site-packages (from wagtail)\nRequirement already satisfied (use --upgrade to upgrade): requests>=2.0.0 in /Library/Python/2.7/site-packages (from wagtail)\nCollecting unicodecsv>=0.9.4 (from wagtail)\n Downloading unicodecsv-0.13.0.tar.gz\nCollecting django-appconf>=0.4 (from django-compressor>=1.4->wagtail)\n Downloading django_appconf-1.0.1-py2.py3-none-any.whl\nCollecting libsass>=0.3.0 (from django-libsass>=0.2->wagtail)\n Downloading libsass-0.8.2-cp27-none-macosx_10_10_intel.whl (1.2MB)\n 100% |################################| 1.2MB 65kB/s\nCollecting pytz>=2015.2 (from django-modelcluster>=0.4->wagtail)\n Downloading pytz-2015.4-py2.py3-none-any.whl (475kB)\n 100% |################################| 475kB 118kB/s\nInstalling collected packages: pytz, libsass, django-appconf, unicodecsv, html5lib, beautifulsoup4, Pillow, django-treebeard, django-taggit, django-modelcluster, django-libsass, django-compressor, South, Django, wagtail\n Found existing installation: pytz 2013.7\n Uninstalling pytz-2013.7:\n Successfully uninstalled pytz-2013.7\n\n\n\n Running setup.py install for unicodecsv\n Running setup.py install for html5lib\n Running setup.py install for beautifulsoup4\n\n Running setup.py install for django-treebeard\n\n Running setup.py install for django-modelcluster\n Running setup.py install for django-libsass\n\n Running setup.py install for South\n\n Running setup.py install for wagtail\n Installing wagtail script to /usr/local/bin\nSuccessfully installed Django-1.7.8 Pillow-2.8.2 South-1.0 beautifulsoup4-4.3.2 django-appconf-1.0.1 django-compressor-1.5 django-libsass-0.3 django-modelcluster-0.6.2 django-taggit-0.12.3 django-treebeard-2.0 html5lib-0.999 libsass-0.8.2 pytz-2015.4 unicodecsv-0.13.0 wagtail-0.8.7\n```\n\nCreates site fine:\n\n```\nsamm-mbp ~/Desktop % wagtail start mysite\nCreating a wagtail project called mysite\nSuccess! mysite is created\n```\n\nMigrating the database - not so fine: (I'm assuming it's sqlite by default?)\n\n```\nsamm-mbp ~/Desktop/mysite % python manage.py migrate\n/Library/Python/2.7/site-packages/treebeard/mp_tree.py:102: RemovedInDjango18Warning: `MP_NodeManager.get_query_set` method should be renamed `get_queryset`.\n class MP_NodeManager(models.Manager):\n\nTraceback (most recent call last):\n File \"manage.py\", line 10, in \n execute_from_command_line(sys.argv)\n File \"/Library/Python/2.7/site-packages/django/core/management/__init__.py\", line 385, in execute_from_command_line\n utility.execute()\n File \"/Library/Python/2.7/site-packages/django/core/management/__init__.py\", line 354, in execute\n django.setup()\n File \"/Library/Python/2.7/site-packages/django/__init__.py\", line 21, in setup\n apps.populate(settings.INSTALLED_APPS)\n File \"/Library/Python/2.7/site-packages/django/apps/registry.py\", line 108, in populate\n app_config.import_models(all_models)\n File \"/Library/Python/2.7/site-packages/django/apps/config.py\", line 202, in import_models\n self.models_module = import_module(models_module_name)\n File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py\", line 37, in import_module\n __import__(name)\n File \"/Library/Python/2.7/site-packages/wagtail/wagtailcore/models.py\", line 268, in \n class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed)):\n File \"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py\", line 566, in with_metaclass\n return meta(\"NewBase\", bases, {})\n File \"/Library/Python/2.7/site-packages/django/db/models/base.py\", line 71, in __new__\n module = attrs.pop('__module__')\nKeyError: u'__module__'\n```\n- Python 2.7.6\n- pip 7.0.3 from /Library/Python/2.7/site-packages (python 2.7)\n- OSX 10.10.3\n\nMight be related to https://groups.google.com/forum/#!msg/wagtail/8zBzrIUwyHk/I20kN_dmTj4J\n\n"},"hints_text":{"kind":"string","value":"It looks like you may be using an old version of `six`. (the line `return meta(\"NewBase\", bases, {})` looks like the old implementation of `with_metaclass`).\n\nTry running `sudo pip install --upgrade six`\n\nthanks @kaedroho but it's already up to date.\n\n`Requirement already up-to-date: six in /Library/Python/2.7/site-packages`\n\nI'm off for the night now so there's no rush replying :)\n\nIt looks like `six` is being loaded from a different place to where pip is installing it (the traceback says six installed at `/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py`).\n\nI recommend installing Wagtail into a virtual environment so Python always sees a pip-installed version of six.\n"},"created_at":{"kind":"string","value":"2015-06-15T08:44:37Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"manage.py\", line 10, in \n execute_from_command_line(sys.argv)\n File \"/Library/Python/2.7/site-packages/django/core/management/__init__.py\", line 385, in execute_from_command_line\n utility.execute()\n File \"/Library/Python/2.7/site-packages/django/core/management/__init__.py\", line 354, in execute\n django.setup()\n File \"/Library/Python/2.7/site-packages/django/__init__.py\", line 21, in setup\n apps.populate(settings.INSTALLED_APPS)\n File \"/Library/Python/2.7/site-packages/django/apps/registry.py\", line 108, in populate\n app_config.import_models(all_models)\n File \"/Library/Python/2.7/site-packages/django/apps/config.py\", line 202, in import_models\n self.models_module = import_module(models_module_name)\n File \"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py\", line 37, in import_module\n __import__(name)\n File \"/Library/Python/2.7/site-packages/wagtail/wagtailcore/models.py\", line 268, in \n class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed)):\n File \"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py\", line 566, in with_metaclass\n return meta(\"NewBase\", bases, {})\n File \"/Library/Python/2.7/site-packages/django/db/models/base.py\", line 71, in __new__\n module = attrs.pop('__module__')\nKeyError: u'__module__'\n"},"__index_level_0__":{"kind":"number","value":18370,"string":"18,370"}}},{"rowIdx":1532,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1605"},"base_commit":{"kind":"string","value":"e867b4844627da5c58fd8d814c9e648b89e59bf3"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailimages/models.py b/wagtail/wagtailimages/models.py\n--- a/wagtail/wagtailimages/models.py\n+++ b/wagtail/wagtailimages/models.py\n@@ -75,6 +75,17 @@ class AbstractImage(models.Model, TagSearchable):\n \n file_size = models.PositiveIntegerField(null=True, editable=False)\n \n+ def is_stored_locally(self):\n+ \"\"\"\n+ Returns True if the image is hosted on the local filesystem\n+ \"\"\"\n+ try:\n+ self.file.path\n+\n+ return True\n+ except NotImplementedError:\n+ return False\n+\n def get_file_size(self):\n if self.file_size is None:\n try:\n@@ -107,8 +118,18 @@ def get_willow_image(self):\n # Open file if it is closed\n close_file = False\n try:\n+ image_file = self.file\n+\n if self.file.closed:\n- self.file.open('rb')\n+ # Reopen the file\n+ if self.is_stored_locally():\n+ self.file.open('rb')\n+ else:\n+ # Some external storage backends don't allow reopening\n+ # the file. Get a fresh file instance. #1397\n+ storage = self._meta.get_field('file').storage\n+ image_file = storage.open(self.file.name, 'rb')\n+\n close_file = True\n except IOError as e:\n # re-throw this as a SourceImageIOError so that calling code can distinguish\n@@ -116,13 +137,13 @@ def get_willow_image(self):\n raise SourceImageIOError(text_type(e))\n \n # Seek to beginning\n- self.file.seek(0)\n+ image_file.seek(0)\n \n try:\n- yield WillowImage.open(self.file)\n+ yield WillowImage.open(image_file)\n finally:\n if close_file:\n- self.file.close()\n+ image_file.close()\n \n def get_rect(self):\n return Rect(0, 0, self.width, self.height)\ndiff --git a/wagtail/wagtailimages/views/images.py b/wagtail/wagtailimages/views/images.py\n--- a/wagtail/wagtailimages/views/images.py\n+++ b/wagtail/wagtailimages/views/images.py\n@@ -123,15 +123,9 @@ def edit(request, image_id):\n except NoReverseMatch:\n url_generator_enabled = False\n \n- try:\n- local_path = image.file.path\n- except NotImplementedError:\n- # Image is hosted externally (eg, S3)\n- local_path = None\n-\n- if local_path:\n+ if image.is_stored_locally():\n # Give error if image file doesn't exist\n- if not os.path.isfile(local_path):\n+ if not os.path.isfile(image.file.path):\n messages.error(request, _(\"The source image file could not be found. Please change the source or delete the image.\").format(image.title), buttons=[\n messages.button(reverse('wagtailimages:delete', args=(image.id,)), _('Delete'))\n ])\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Error Uploading an Image\nWhen I click the \"Upload\" button to upload an image from a page, I get `ValueError: The file cannot be reopened.`\n\nHere is the full stack trace:\n\n```\n[11/Jun/2015 13:05:29] \"POST /cms/images/chooser/upload/ HTTP/1.1\" 500 23947\nInternal Server Error: /cms/images/chooser/upload/\nTraceback (most recent call last):\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, *args, **kwargs)\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/views/chooser.py\", line 141, in chooser_upload\n {'image_json': get_image_json(image)}\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/views/chooser.py\", line 22, in get_image_json\n preview_image = image.get_rendition('max-130x100')\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/models.py\", line 196, in get_rendition\n generated_image = filter.process_image(image_file, backend_name=backend_name, focal_point=self.get_focal_point())\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/models.py\", line 371, in process_image\n input_file.open('rb')\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/django/core/files/base.py\", line 128, in open\n raise ValueError(\"The file cannot be reopened.\")\nValueError: The file cannot be reopened.\n```\n\n"},"hints_text":{"kind":"string","value":"UPDATE:\n\nSo when this error happened, the image did actually upload just fine. After the error I went over to \"Images\" in the left menu and it showed up and I could select it for the page and everything. So this error is happening _after_ the image is uploaded successfully. \n\nThis error only happens using the modal window for uploading images while editing a page. When I upload an image using the tool under \"Images\" it works great without errors.\n\nLooks like Wagtail is trying to generate a rendition from an image that has just been uploaded (in the same view). This is probably an easy fix, just need to refresh the image object before generating a rendition from it.\n\nHi @chadsaun, can you confirm which version of Wagtail you're using? Please post the output of `pip freeze`.\n\nWhat version of Django are you using? Are you storing image files locally?\n\nHere's my `pip freeze`\n\n```\nBabel==1.3\nBabelDjango==0.2.2\nbeautifulsoup4==4.3.2\nboto==2.38.0\nbraintree==3.12.0\ncairocffi==0.6\nCairoSVG==1.0.13\ncffi==0.9.2\nclick==4.0\ncryptography==0.8.2\nDjango==1.7.8\ndjango-appconf==1.0.1\ndjango-compressor==1.5\ndjango-datetime-widget==0.9.3\ndjango-debug-toolbar==1.3.0\ndjango-images==0.4.1\ndjango-libsass==0.3\ndjango-livefield==2.1.0\ndjango-model-utils==2.0.3\ndjango-modelcluster==0.6.2\ndjango-mptt==0.7.4\ndjango-offsite-storage==0.0.5\ndjango-overextends==0.3.2\ndjango-payments==0.6.5\ndjango-prices==0.3.4\ndjango-recaptcha==1.0.3\ndjango-selectable==0.8.0\ndjango-taggit==0.12.3\ndjango-treebeard==2.0\ndjangorestframework==3.0.3\ndjrill==1.3.0\ndocopt==0.4.0\nenum34==1.0.4\nfake-factory==0.4.2\nfeedparser==5.2.0\ngoogle-measurement-protocol==0.1.3\nhtml5lib==0.999\njsonfield==1.0.0\nlibsass==0.8.2\nmailchimp==2.0.9\nMarkdown==2.5.2\nmysqlclient==1.3.6\nndg-httpsclient==0.3.3\nPillow==2.8.2\nprices==0.5.1\npsycopg2==2.5.4\npyasn1==0.1.7\npycparser==2.13\npycrypto==2.6.1\nPyJWT==1.0.1\npyOpenSSL==0.15.1\npython-dotenv==0.1.2\npytz==2015.4\nreportlab==2.7\nrequests==2.7.0\nsaleor==0.1.0a0\nsatchless==1.1.3\nsix==1.9.0\nSouth==1.0.2\nsphinx-me==0.3\nsqlparse==0.1.15\nstripe==1.22.1\nsuds-jurko==0.6\nunicodecsv==0.13.0\nUnidecode==0.4.18\nUnipath==1.0\nwagtail==0.8.7\nXlsxWriter==0.7.2\n```\n\nThese images are being stored in an S3 bucket. Everything seems to work perfectly through the \"Images\" menu page/uploader though. Just seems to be an issue with the modal window uploader tool thingymabob.\n\nI take it you're using [django-offsite-storage](https://github.com/mirumee/django-offsite-storage) for that, and you have `DEFAULT_FILE_STORAGE` set to `'offsite_storage.storages.S3MediaStorage'`...?\n\nYes\n`DEFAULT_FILE_STORAGE = 'offsite_storage.storages.S3MediaStorage'`\n\nIt might be the fact that we're calling `image.file.file.open()`. In wagtail 1.0+ we call `image.file.open()` which is probably a bit higher level and may be able to handle this.\n\nI can confirm that this issue appears in the current master as well\n"},"created_at":{"kind":"string","value":"2015-08-13T16:27:43Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/django/core/handlers/base.py\", line 111, in get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/django/contrib/auth/decorators.py\", line 21, in _wrapped_view\n return view_func(request, *args, **kwargs)\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/views/chooser.py\", line 141, in chooser_upload\n {'image_json': get_image_json(image)}\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/views/chooser.py\", line 22, in get_image_json\n preview_image = image.get_rendition('max-130x100')\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/models.py\", line 196, in get_rendition\n generated_image = filter.process_image(image_file, backend_name=backend_name, focal_point=self.get_focal_point())\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/wagtail/wagtailimages/models.py\", line 371, in process_image\n input_file.open('rb')\n File \"/Users/john/.virtualenvs/website/lib/python2.7/site-packages/django/core/files/base.py\", line 128, in open\n raise ValueError(\"The file cannot be reopened.\")\nValueError: The file cannot be reopened.\n"},"__index_level_0__":{"kind":"number","value":18384,"string":"18,384"}}},{"rowIdx":1533,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1633"},"base_commit":{"kind":"string","value":"102f8db2380bad9d493e5df783055200b66be8ee"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailimages/views/frontend.py b/wagtail/wagtailimages/views/frontend.py\n--- a/wagtail/wagtailimages/views/frontend.py\n+++ b/wagtail/wagtailimages/views/frontend.py\n@@ -2,7 +2,7 @@\n import imghdr\n \n from django.shortcuts import get_object_or_404\n-from django.http import HttpResponse\n+from django.http import HttpResponse, StreamingHttpResponse\n from django.core.exceptions import PermissionDenied\n \n from wagtail.wagtailimages.models import get_image_model\n@@ -20,6 +20,6 @@ def serve(request, signature, image_id, filter_spec):\n rendition = image.get_rendition(filter_spec)\n rendition.file.open('rb')\n image_format = imghdr.what(rendition.file)\n- return HttpResponse(FileWrapper(rendition.file), content_type='image/' + image_format)\n+ return StreamingHttpResponse(FileWrapper(rendition.file), content_type='image/' + image_format)\n except InvalidFilterSpecError:\n return HttpResponse(\"Invalid filter spec: \" + filter_spec, content_type='text/plain', status=400)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Error when serving images through the URL generator\nI posted a comment on https://github.com/torchbox/wagtail/issues/983 but probably better to open a new issue. Looks like the same problem to me though.\n\nHi guys, I think I'm having the same problem but when serving images using the URL generator. It does work if I'm logged-in in the site (cache not working) but doesn't when I'm not (cache full on).\n\nCheers,\nJordi\n\nInternal Server Error: /images/2dMQIUOPwS5DlZuprp_E_WFdfhw=/47/width-75/\nTraceback (most recent call last):\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 204, in get_response\n response = middleware_method(request, response)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/middleware/cache.py\", line 121, in process_response\n self.cache.set(cache_key, response, timeout)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/redis_cache/cache.py\", line 239, in set\n result = self._set(key, pickle.dumps(value), timeout, client, _add_only)\n File \"/var/www/buildability/venvs/buildability.co.nz/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n\nRequest repr(): \n,\nPOST:,\nCOOKIES:{'_ga': 'GA1.3.1219121887.1434427204',\n 'csrftoken': 'GNhfTEGBu40y8wRAFPa15lQTV66F9WCs'},\nMETA:{'CONTENT_LENGTH': '',\n 'CONTENT_TYPE': '',\n u'CSRF_COOKIE': u'GNhfTEGBu40y8wRAFPa15lQTV66F9WCs',\n 'DOCUMENT_ROOT': '/usr/share/nginx/html',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,_/_;q=0.8',\n 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',\n 'HTTP_CACHE_CONTROL': 'max-age=0',\n 'HTTP_CONNECTION': 'keep-alive',\n 'HTTP_COOKIE': '_ga=GA1.3.1219121887.1434427204; csrftoken=GNhfTEGBu40y8wRAFPa15lQTV66F9WCs',\n 'HTTP_HOST': 'www.buildability.co.nz',\n 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36',\n 'PATH_INFO': u'/images/2dMQIUOPwS5DlZuprp_E_WFdfhw=/47/width-75/',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '131.203.137.142',\n 'REMOTE_PORT': '51455',\n 'REQUEST_METHOD': 'GET',\n 'REQUEST_URI': '/images/2dMQIUOPwS5DlZuprp_E_WFdfhw%3D/47/width-75/',\n u'SCRIPT_NAME': u'',\n 'SERVER_NAME': 'www.buildability.co.nz',\n 'SERVER_PORT': '80',\n 'SERVER_PROTOCOL': 'HTTP/1.1',\n 'UWSGI_SCHEME': 'http',\n 'uwsgi.core': 7,\n 'uwsgi.node': 'avinton',\n 'uwsgi.version': '1.9.17.1-debian',\n 'wsgi.errors': ,\n 'wsgi.file_wrapper': ,\n 'wsgi.input': ,\n 'wsgi.multiprocess': True,\n 'wsgi.multithread': True,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>\n\n"},"hints_text":{"kind":"string","value":"Oops I've realised I was using an old version, will try with 1.0 and post the results here.\n\nCheers\n\nI can confirm it's happening with 1.0 and redis as cache backend:\n\n```\n[13/Aug/2015 22:37:18] ERROR [django.request:231] Internal Server Error: /images/eG6p_vHhTMhSV-fROD_AbEYPDXQ=/129/width-400/\nTraceback (most recent call last):\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 204, in get_response\n response = middleware_method(request, response)\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/local/lib/python2.7/site-packages/django/middleware/cache.py\", line 121, in process_response\n self.cache.set(cache_key, response, timeout)\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/local/lib/python2.7/site-packages/redis_cache/cache.py\", line 239, in set\n result = self._set(key, pickle.dumps(value), timeout, client, _add_only)\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n```\n"},"created_at":{"kind":"string","value":"2015-08-21T13:34:04Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 204, in get_response\n response = middleware_method(request, response)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/middleware/cache.py\", line 121, in process_response\n self.cache.set(cache_key, response, timeout)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/redis_cache/cache.py\", line 239, in set\n result = self._set(key, pickle.dumps(value), timeout, client, _add_only)\n File \"/var/www/buildability/venvs/buildability.co.nz/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n"},"__index_level_0__":{"kind":"number","value":18388,"string":"18,388"}}},{"rowIdx":1534,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1650"},"base_commit":{"kind":"string","value":"c072d94fe23eacf0245c6c9a5d689575a397b19f"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailimages/views/frontend.py b/wagtail/wagtailimages/views/frontend.py\n--- a/wagtail/wagtailimages/views/frontend.py\n+++ b/wagtail/wagtailimages/views/frontend.py\n@@ -2,7 +2,7 @@\n import imghdr\n \n from django.shortcuts import get_object_or_404\n-from django.http import HttpResponse\n+from django.http import HttpResponse, StreamingHttpResponse\n from django.core.exceptions import PermissionDenied\n \n from wagtail.wagtailimages.models import get_image_model\n@@ -20,6 +20,6 @@ def serve(request, signature, image_id, filter_spec):\n rendition = image.get_rendition(filter_spec)\n rendition.file.open('rb')\n image_format = imghdr.what(rendition.file)\n- return HttpResponse(FileWrapper(rendition.file), content_type='image/' + image_format)\n+ return StreamingHttpResponse(FileWrapper(rendition.file), content_type='image/' + image_format)\n except InvalidFilterSpecError:\n return HttpResponse(\"Invalid filter spec: \" + filter_spec, content_type='text/plain', status=400)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Error when serving images through the URL generator\nI posted a comment on https://github.com/torchbox/wagtail/issues/983 but probably better to open a new issue. Looks like the same problem to me though.\n\nHi guys, I think I'm having the same problem but when serving images using the URL generator. It does work if I'm logged-in in the site (cache not working) but doesn't when I'm not (cache full on).\n\nCheers,\nJordi\n\nInternal Server Error: /images/2dMQIUOPwS5DlZuprp_E_WFdfhw=/47/width-75/\nTraceback (most recent call last):\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 204, in get_response\n response = middleware_method(request, response)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/middleware/cache.py\", line 121, in process_response\n self.cache.set(cache_key, response, timeout)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/redis_cache/cache.py\", line 239, in set\n result = self._set(key, pickle.dumps(value), timeout, client, _add_only)\n File \"/var/www/buildability/venvs/buildability.co.nz/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n\nRequest repr(): \n,\nPOST:,\nCOOKIES:{'_ga': 'GA1.3.1219121887.1434427204',\n 'csrftoken': 'GNhfTEGBu40y8wRAFPa15lQTV66F9WCs'},\nMETA:{'CONTENT_LENGTH': '',\n 'CONTENT_TYPE': '',\n u'CSRF_COOKIE': u'GNhfTEGBu40y8wRAFPa15lQTV66F9WCs',\n 'DOCUMENT_ROOT': '/usr/share/nginx/html',\n 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,_/_;q=0.8',\n 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch',\n 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',\n 'HTTP_CACHE_CONTROL': 'max-age=0',\n 'HTTP_CONNECTION': 'keep-alive',\n 'HTTP_COOKIE': '_ga=GA1.3.1219121887.1434427204; csrftoken=GNhfTEGBu40y8wRAFPa15lQTV66F9WCs',\n 'HTTP_HOST': 'www.buildability.co.nz',\n 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',\n 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36',\n 'PATH_INFO': u'/images/2dMQIUOPwS5DlZuprp_E_WFdfhw=/47/width-75/',\n 'QUERY_STRING': '',\n 'REMOTE_ADDR': '131.203.137.142',\n 'REMOTE_PORT': '51455',\n 'REQUEST_METHOD': 'GET',\n 'REQUEST_URI': '/images/2dMQIUOPwS5DlZuprp_E_WFdfhw%3D/47/width-75/',\n u'SCRIPT_NAME': u'',\n 'SERVER_NAME': 'www.buildability.co.nz',\n 'SERVER_PORT': '80',\n 'SERVER_PROTOCOL': 'HTTP/1.1',\n 'UWSGI_SCHEME': 'http',\n 'uwsgi.core': 7,\n 'uwsgi.node': 'avinton',\n 'uwsgi.version': '1.9.17.1-debian',\n 'wsgi.errors': ,\n 'wsgi.file_wrapper': ,\n 'wsgi.input': ,\n 'wsgi.multiprocess': True,\n 'wsgi.multithread': True,\n 'wsgi.run_once': False,\n 'wsgi.url_scheme': 'http',\n 'wsgi.version': (1, 0)}>\n\n"},"hints_text":{"kind":"string","value":"Oops I've realised I was using an old version, will try with 1.0 and post the results here.\n\nCheers\n\nI can confirm it's happening with 1.0 and redis as cache backend:\n\n```\n[13/Aug/2015 22:37:18] ERROR [django.request:231] Internal Server Error: /images/eG6p_vHhTMhSV-fROD_AbEYPDXQ=/129/width-400/\nTraceback (most recent call last):\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 204, in get_response\n response = middleware_method(request, response)\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/local/lib/python2.7/site-packages/django/middleware/cache.py\", line 121, in process_response\n self.cache.set(cache_key, response, timeout)\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/local/lib/python2.7/site-packages/redis_cache/cache.py\", line 239, in set\n result = self._set(key, pickle.dumps(value), timeout, client, _add_only)\n File \"/var/www/madewithwagtail/venvs/madewithwagtail/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n```\n"},"created_at":{"kind":"string","value":"2015-08-28T21:45:13Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/core/handlers/base.py\", line 204, in get_response\n response = middleware_method(request, response)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/django/middleware/cache.py\", line 121, in process_response\n self.cache.set(cache_key, response, timeout)\n File \"/var/www/buildability/venvs/buildability.co.nz/local/lib/python2.7/site-packages/redis_cache/cache.py\", line 239, in set\n result = self._set(key, pickle.dumps(value), timeout, client, _add_only)\n File \"/var/www/buildability/venvs/buildability.co.nz/lib/python2.7/copy_reg.py\", line 70, in _reduce_ex\n raise TypeError, \"can't pickle %s objects\" % base.__name__\nTypeError: can't pickle instancemethod objects\n"},"__index_level_0__":{"kind":"number","value":18389,"string":"18,389"}}},{"rowIdx":1535,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-1681"},"base_commit":{"kind":"string","value":"799d0dd3ff08716511c8f607141adb4fddfe1085"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailadmin/widgets.py b/wagtail/wagtailadmin/widgets.py\n--- a/wagtail/wagtailadmin/widgets.py\n+++ b/wagtail/wagtailadmin/widgets.py\n@@ -5,6 +5,7 @@\n from django.core.urlresolvers import reverse\n from django.forms import widgets\n from django.contrib.contenttypes.models import ContentType\n+from django.utils.functional import cached_property\n from django.utils.translation import ugettext_lazy as _\n from django.template.loader import render_to_string\n \n@@ -119,11 +120,15 @@ class AdminPageChooser(AdminChooser):\n \n def __init__(self, content_type=None, **kwargs):\n super(AdminPageChooser, self).__init__(**kwargs)\n+ self._content_type = content_type\n \n- self.target_content_types = content_type or ContentType.objects.get_for_model(Page)\n+ @cached_property\n+ def target_content_types(self):\n+ target_content_types = self._content_type or ContentType.objects.get_for_model(Page)\n # Make sure target_content_types is a list or tuple\n- if not isinstance(self.target_content_types, (list, tuple)):\n- self.target_content_types = [self.target_content_types]\n+ if not isinstance(target_content_types, (list, tuple)):\n+ target_content_types = [target_content_types]\n+ return target_content_types\n \n def render_html(self, name, value, attrs):\n if len(self.target_content_types) == 1:\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"manage.py compress errors with empty db\nIn 1.1rc1 manage.py command 'compress' doesn't work anymore if the database isn't migrated yet. I need to be able to do this since i'm running django compress during a docker build.\n\nComplete stacktrace is:\n\n```\nTraceback (most recent call last):\n File \"./manage.py\", line 10, in \n execute_from_command_line(sys.argv)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/management/__init__.py\", line 338, in execute_from_command_line\n utility.execute()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/management/__init__.py\", line 312, in execute\n django.setup()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/__init__.py\", line 18, in setup\n apps.populate(settings.INSTALLED_APPS)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/apps/registry.py\", line 115, in populate\n app_config.ready()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/debug_toolbar/apps.py\", line 15, in ready\n dt_settings.patch_all()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/debug_toolbar/settings.py\", line 232, in patch_all\n patch_root_urlconf()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/debug_toolbar/settings.py\", line 220, in patch_root_urlconf\n reverse('djdt:render_panel')\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 550, in reverse\n app_list = resolver.app_dict[ns]\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 352, in app_dict\n self._populate()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 285, in _populate\n for pattern in reversed(self.url_patterns):\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 402, in url_patterns\n patterns = getattr(self.urlconf_module, \"urlpatterns\", self.urlconf_module)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 396, in urlconf_module\n self._urlconf_module = import_module(self.urlconf_name)\n File \"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py\", line 37, in import_module\n __import__(name)\n File \"/Users/mvantellingen/projects/myorg/myproj/src/myproj/urls.py\", line 7, in \n from wagtail.wagtailadmin import urls as wagtailadmin_urls\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 7, in \n from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailadmin/views/account.py\", line 12, in \n from wagtail.wagtailusers.forms import NotificationPreferencesForm\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailusers/forms.py\", line 236, in \n class GroupPagePermissionForm(forms.ModelForm):\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailusers/forms.py\", line 238, in GroupPagePermissionForm\n widget=AdminPageChooser(show_edit_link=False))\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailadmin/widgets.py\", line 123, in __init__\n self.target_content_types = content_type or ContentType.objects.get_for_model(Page)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/contrib/contenttypes/models.py\", line 78, in get_for_model\n \"Error creating new content types. Please make sure contenttypes \"\nRuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.\n```\n\n"},"hints_text":{"kind":"string","value":"Thanks for reporting! We should move https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailadmin/widgets.py#L123 into its own method I think. So it only runs when the form is being rendered.\n"},"created_at":{"kind":"string","value":"2015-09-14T14:52:21Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"./manage.py\", line 10, in \n execute_from_command_line(sys.argv)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/management/__init__.py\", line 338, in execute_from_command_line\n utility.execute()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/management/__init__.py\", line 312, in execute\n django.setup()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/__init__.py\", line 18, in setup\n apps.populate(settings.INSTALLED_APPS)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/apps/registry.py\", line 115, in populate\n app_config.ready()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/debug_toolbar/apps.py\", line 15, in ready\n dt_settings.patch_all()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/debug_toolbar/settings.py\", line 232, in patch_all\n patch_root_urlconf()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/debug_toolbar/settings.py\", line 220, in patch_root_urlconf\n reverse('djdt:render_panel')\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 550, in reverse\n app_list = resolver.app_dict[ns]\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 352, in app_dict\n self._populate()\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 285, in _populate\n for pattern in reversed(self.url_patterns):\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 402, in url_patterns\n patterns = getattr(self.urlconf_module, \"urlpatterns\", self.urlconf_module)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/core/urlresolvers.py\", line 396, in urlconf_module\n self._urlconf_module = import_module(self.urlconf_name)\n File \"/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py\", line 37, in import_module\n __import__(name)\n File \"/Users/mvantellingen/projects/myorg/myproj/src/myproj/urls.py\", line 7, in \n from wagtail.wagtailadmin import urls as wagtailadmin_urls\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 7, in \n from wagtail.wagtailadmin.views import account, chooser, home, pages, tags, userbar\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailadmin/views/account.py\", line 12, in \n from wagtail.wagtailusers.forms import NotificationPreferencesForm\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailusers/forms.py\", line 236, in \n class GroupPagePermissionForm(forms.ModelForm):\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailusers/forms.py\", line 238, in GroupPagePermissionForm\n widget=AdminPageChooser(show_edit_link=False))\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/wagtail/wagtailadmin/widgets.py\", line 123, in __init__\n self.target_content_types = content_type or ContentType.objects.get_for_model(Page)\n File \"/usr/local/opt/pyenv/versions/myproj/lib/python2.7/site-packages/django/contrib/contenttypes/models.py\", line 78, in get_for_model\n \"Error creating new content types. Please make sure contenttypes \"\nRuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.\n"},"__index_level_0__":{"kind":"number","value":18392,"string":"18,392"}}},{"rowIdx":1536,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-3973"},"base_commit":{"kind":"string","value":"f219493365c4ee9209438a6a4841dbfb108c4b6f"},"patch":{"kind":"string","value":"diff --git a/wagtail/api/v2/endpoints.py b/wagtail/api/v2/endpoints.py\n--- a/wagtail/api/v2/endpoints.py\n+++ b/wagtail/api/v2/endpoints.py\n@@ -396,7 +396,11 @@ def get_queryset(self):\n queryset = queryset.public().live()\n \n # Filter by site\n- queryset = queryset.descendant_of(request.site.root_page, inclusive=True)\n+ if request.site:\n+ queryset = queryset.descendant_of(request.site.root_page, inclusive=True)\n+ else:\n+ # No sites configured\n+ queryset = queryset.none()\n \n return queryset\n \ndiff --git a/wagtail/api/v2/utils.py b/wagtail/api/v2/utils.py\n--- a/wagtail/api/v2/utils.py\n+++ b/wagtail/api/v2/utils.py\n@@ -12,7 +12,7 @@ class BadRequestError(Exception):\n \n \n def get_base_url(request=None):\n- base_url = getattr(settings, 'WAGTAILAPI_BASE_URL', request.site.root_url if request else None)\n+ base_url = getattr(settings, 'WAGTAILAPI_BASE_URL', request.site.root_url if request and request.site else None)\n \n if base_url:\n # We only want the scheme and netloc\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Attribute error in listing_view endpoint \n### Issue Summary\r\n\r\nI get the following exception\r\n\r\n```\r\nInternal Server Error: /cms/api/v2beta/pages/\r\nTraceback (most recent call last):\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/exception.py\", line 41, in inner\r\n response = get_response(request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 249, in _legacy_get_response\r\n response = self._get_response(request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 187, in _get_response\r\n response = self.process_exception_by_middleware(e, request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 185, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/views/decorators/cache.py\", line 43, in _cache_controlled\r\n response = viewfunc(request, *args, **kw)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 96, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/wagtailadmin/decorators.py\", line 31, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/router.py\", line 65, in wrapped\r\n return func(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/views/decorators/csrf.py\", line 58, in wrapped_view\r\n return view_func(*args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/viewsets.py\", line 90, in view\r\n return self.dispatch(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/views.py\", line 489, in dispatch\r\n response = self.handle_exception(exc)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/endpoints.py\", line 95, in handle_exception\r\n return super(BaseAPIEndpoint, self).handle_exception(exc)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/views.py\", line 449, in handle_exception\r\n self.raise_uncaught_exception(exc)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/views.py\", line 486, in dispatch\r\n response = handler(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/wagtailadmin/api/endpoints.py\", line 93, in listing_view\r\n response = super(PagesAdminAPIEndpoint, self).listing_view(request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/endpoints.py\", line 81, in listing_view\r\n return self.get_paginated_response(serializer.data)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 739, in data\r\n ret = super(ListSerializer, self).data\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 263, in data\r\n self._data = self.to_representation(self.instance)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 657, in to_representation\r\n self.child.to_representation(item) for item in iterable\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 657, in \r\n self.child.to_representation(item) for item in iterable\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/serializers.py\", line 275, in to_representation\r\n attribute = field.get_attribute(instance)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/serializers.py\", line 47, in get_attribute\r\n url = get_object_detail_url(self.context, type(instance), instance.pk)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/serializers.py\", line 20, in get_object_detail_url\r\n return get_full_url(context['request'], url_path)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/utils.py\", line 25, in get_full_url\r\n base_url = get_base_url(request) or ''\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/utils.py\", line 15, in get_base_url\r\n base_url = getattr(settings, 'WAGTAILAPI_BASE_URL', request.site.root_url if request else None)\r\nAttributeError: 'NoneType' object has no attribute 'root_url'\r\n```\r\n\r\nwhen clicking on the pages section in the backend.\r\n\r\n### Steps to Reproduce\r\n\r\n1. Existing django 1.11 installation\r\n2. Added all the django apps and middleware entries in `settings.py` and all the urls as described in http://docs.wagtail.io/en/v1.13/getting_started/integrating_into_django.html\r\n3. Created a new app via `manage.py startapp home`\r\n4. Added simple page type as described in the docs:\r\n```\r\nclass HomePage(Page):\r\n body = RichTextField(blank=True)\r\n\r\n content_panels = Page.content_panels + [\r\n FieldPanel('body', classname=\"full\"),\r\n ]\r\n```\r\n5. Applied migrations\r\n6. Everything worked as expected.\r\n7. Added a new \"HomePage\" page as a subpage of the predefined sample page\r\n8. This also worked.\r\n9. Moved new page to the toplevel (subpage of root)\r\n10. Removed the sample page\r\n11. Then I got the described error\r\n\r\nEverything is done local with the django builtin webserver.\r\n\r\n### Technical details\r\n\r\n* Python version:3.5.0\r\n* Django version: 1.11\r\n* Wagtail version: 1.13\r\n* djangorestframework: 3.6.4\r\n\r\n\n"},"hints_text":{"kind":"string","value":"I tried to check where the request object is created. This seems to be inside of the rest_framework. Did not found any `site` attribute, that is added to the request there.\nHi @thorink,\r\n`request.site` is defined by the middleware class `wagtail.wagtailcore.middleware.SiteMiddleware`. If this is returning `None`, it probably means you don't have a site record set up within Settings -> Sites.\r\n\r\nIn any case, it looks like this is indeed a bug - the line `base_url = getattr(settings, 'WAGTAILAPI_BASE_URL', request.site.root_url if request else None)` is failing to consider the possibility of `request.site` being defined but set to None. Thanks for the report!\nThanks, adding a site worked for me. And also thanks for working on this project in general! I keep track of this project since over a year now and really like it. No I have the opportunity to use it in one of my project."},"created_at":{"kind":"string","value":"2017-10-26T08:54:25Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/exception.py\", line 41, in inner\r\n response = get_response(request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 249, in _legacy_get_response\r\n response = self._get_response(request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 187, in _get_response\r\n response = self.process_exception_by_middleware(e, request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/core/handlers/base.py\", line 185, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/views/decorators/cache.py\", line 43, in _cache_controlled\r\n response = viewfunc(request, *args, **kw)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 96, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/wagtailadmin/decorators.py\", line 31, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/router.py\", line 65, in wrapped\r\n return func(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/django/views/decorators/csrf.py\", line 58, in wrapped_view\r\n return view_func(*args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/viewsets.py\", line 90, in view\r\n return self.dispatch(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/views.py\", line 489, in dispatch\r\n response = self.handle_exception(exc)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/endpoints.py\", line 95, in handle_exception\r\n return super(BaseAPIEndpoint, self).handle_exception(exc)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/views.py\", line 449, in handle_exception\r\n self.raise_uncaught_exception(exc)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/views.py\", line 486, in dispatch\r\n response = handler(request, *args, **kwargs)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/wagtailadmin/api/endpoints.py\", line 93, in listing_view\r\n response = super(PagesAdminAPIEndpoint, self).listing_view(request)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/endpoints.py\", line 81, in listing_view\r\n return self.get_paginated_response(serializer.data)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 739, in data\r\n ret = super(ListSerializer, self).data\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 263, in data\r\n self._data = self.to_representation(self.instance)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 657, in to_representation\r\n self.child.to_representation(item) for item in iterable\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/rest_framework/serializers.py\", line 657, in \r\n self.child.to_representation(item) for item in iterable\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/serializers.py\", line 275, in to_representation\r\n attribute = field.get_attribute(instance)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/serializers.py\", line 47, in get_attribute\r\n url = get_object_detail_url(self.context, type(instance), instance.pk)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/serializers.py\", line 20, in get_object_detail_url\r\n return get_full_url(context['request'], url_path)\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/utils.py\", line 25, in get_full_url\r\n base_url = get_base_url(request) or ''\r\n File \"/Users/thomas/virtualenvs/djangoenv/lib/python3.5/site-packages/wagtail/api/v2/utils.py\", line 15, in get_base_url\r\n base_url = getattr(settings, 'WAGTAILAPI_BASE_URL', request.site.root_url if request else None)\r\nAttributeError: 'NoneType' object has no attribute 'root_url'\r\n"},"__index_level_0__":{"kind":"number","value":18445,"string":"18,445"}}},{"rowIdx":1537,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-4017"},"base_commit":{"kind":"string","value":"7f026d50b44946d8a2b77df91e6167feb23e7686"},"patch":{"kind":"string","value":"diff --git a/wagtail/contrib/postgres_search/backend.py b/wagtail/contrib/postgres_search/backend.py\n--- a/wagtail/contrib/postgres_search/backend.py\n+++ b/wagtail/contrib/postgres_search/backend.py\n@@ -271,9 +271,12 @@ def search_in_index(self, queryset, search_query, start, stop):\n sql, index_params + model_params + limits)\n \n def search_in_fields(self, queryset, search_query, start, stop):\n+ # Due to a Django bug, arrays are not automatically converted here.\n+ converted_weights = '{' + ','.join(map(str, WEIGHTS_VALUES)) + '}'\n+\n return (self.get_in_fields_queryset(queryset, search_query)\n .annotate(_rank_=SearchRank(F('_search_'), search_query,\n- weights=WEIGHTS_VALUES))\n+ weights=converted_weights))\n .order_by('-_rank_'))[start:stop]\n \n def search(self, config, start, stop):\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Postgres search fails on Wagtail admin page chooser search\n### Issue Summary\r\n\r\nWhen trying to search using postgres search backend on wagtail admin page chooser I get server error (500).\r\n\r\n### Steps to Reproduce\r\n\r\n1. Clone wagtaildemo https://github.com/wagtail/wagtaildemo (I am using the Vagrant VM from the repo).\r\n2. Set wagtail search backend to postgres, migrate and update index as per instructions in http://docs.wagtail.io/en/v1.13/reference/contrib/postgres_search.html\r\n - Add `wagtail.contrib.postgres_search` to `INSTALLED_APPS`.\r\n - Add the following to the settings\r\n ```\r\n WAGTAILSEARCH_BACKENDS = {\r\n 'default': {\r\n 'BACKEND': 'wagtail.contrib.postgres_search.backend',\r\n },\r\n }\r\n - run `manage.py migrate` which successfully performs the postgres backend migration ` Applying postgres_search.0001_initial... OK`\r\n - run `migrate.py update_index`\r\n3. Try to search inside a page chooser. I personally used \"Link page\" on the \"Speakers\" inline panel on an event page in wagtaildemo, e.g. http://localhost:8000/admin/pages/8/edit/\r\n4. Any AJAX request made to the search fails with 500, see the log below.\r\n\r\nSuccessfully reproduced on another project, so it seems to be an issue with the postgres search backend.\r\n\r\n```\r\n[13/Nov/2017 15:20:41] \"GET /admin/choose-page/search/?page_type=wagtailcore.page&q=a&results_only=true HTTP/1.1\" 500 21736\r\nInternal Server Error: /admin/choose-page/search/\r\nTraceback (most recent call last):\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/exception.py\", line 41, in inner\r\n response = get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 249, in _legacy_get_response\r\n response = self._get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 187, in _get_response\r\n response = self.process_exception_by_middleware(e, request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 185, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/views/decorators/cache.py\", line 43, in _cache_controlled\r\n response = viewfunc(request, *args, **kw)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 96, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/decorators.py\", line 31, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/views/chooser.py\", line 171, in search\r\n for page in pages:\r\n File \"/usr/local/lib/python3.4/_collections_abc.py\", line 634, in __iter__\r\n v = self[i]\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/paginator.py\", line 145, in __getitem__\r\n self.object_list = list(self.object_list)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 172, in __iter__\r\n return iter(self.results())\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 138, in results\r\n self._results_cache = self._do_search()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/contrib/postgres_search/backend.py\", line 297, in _do_search\r\n self.start, self.stop))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailcore/query.py\", line 369, in specific_iterator\r\n for pk, content_type in pks_and_types:\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 122, in __iter__\r\n for row in compiler.results_iter():\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 836, in results_iter\r\n results = self.execute_sql(MULTI)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 871, in execute_sql\r\n sql, params = self.as_sql()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 423, in as_sql\r\n extra_select, order_by, group_by = self.pre_sql_setup()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 47, in pre_sql_setup\r\n order_by = self.get_order_by()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 335, in get_order_by\r\n if (without_ordering, tuple(params)) in seen:\r\nTypeError: unhashable type: 'list'\r\n```\r\n\r\n### Technical details\r\n\r\n* Python version: 3.4.3\r\n* Django version: 1.11.7\r\n* Wagtail version: 1.13\r\n* Browser version: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0\n"},"hints_text":{"kind":"string","value":"Thanks @tm-kn! Confirmed on Wagtail 1.13 here. Looks like this may well be related to the issues fixed in #3947 - although this one seems to be a regression from 1.12 to 1.13, which suggests that it's not one of the fixes backported in #3957 / #3958 (which affected 1.12 and 1.13 equally). Investigating now.\nCaused by https://github.com/wagtail/wagtail/commit/4063573f9c48e035a05321e98a2c89f2c310ceaa - evidently the Postgres search backend doesn't like working on a `specific()` queryset.\nCan be reproduced on the `./manage.py shell` command line with:\r\n\r\n Page.objects.specific().search('bread', fields=['title'])\r\n\r\nBoth the `specific` clause and the `fields` param are necessary to trigger the error.\n781263d4e1d4d8c95170f19667b61700fd3751d9 has fixed this on master - will see if this can be backported. ( @BertrandBordage, please shout if you're already working on this :-) )"},"created_at":{"kind":"string","value":"2017-11-14T14:44:43Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/exception.py\", line 41, in inner\r\n response = get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 249, in _legacy_get_response\r\n response = self._get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 187, in _get_response\r\n response = self.process_exception_by_middleware(e, request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 185, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/views/decorators/cache.py\", line 43, in _cache_controlled\r\n response = viewfunc(request, *args, **kw)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 96, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/decorators.py\", line 31, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/views/chooser.py\", line 171, in search\r\n for page in pages:\r\n File \"/usr/local/lib/python3.4/_collections_abc.py\", line 634, in __iter__\r\n v = self[i]\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/paginator.py\", line 145, in __getitem__\r\n self.object_list = list(self.object_list)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 172, in __iter__\r\n return iter(self.results())\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 138, in results\r\n self._results_cache = self._do_search()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/contrib/postgres_search/backend.py\", line 297, in _do_search\r\n self.start, self.stop))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailcore/query.py\", line 369, in specific_iterator\r\n for pk, content_type in pks_and_types:\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 122, in __iter__\r\n for row in compiler.results_iter():\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 836, in results_iter\r\n results = self.execute_sql(MULTI)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 871, in execute_sql\r\n sql, params = self.as_sql()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 423, in as_sql\r\n extra_select, order_by, group_by = self.pre_sql_setup()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 47, in pre_sql_setup\r\n order_by = self.get_order_by()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 335, in get_order_by\r\n if (without_ordering, tuple(params)) in seen:\r\nTypeError: unhashable type: 'list'\r\n"},"__index_level_0__":{"kind":"number","value":18448,"string":"18,448"}}},{"rowIdx":1538,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-4018"},"base_commit":{"kind":"string","value":"857e3978708b7b7521a215a1a59bab23dfa49172"},"patch":{"kind":"string","value":"diff --git a/wagtail/contrib/postgres_search/backend.py b/wagtail/contrib/postgres_search/backend.py\n--- a/wagtail/contrib/postgres_search/backend.py\n+++ b/wagtail/contrib/postgres_search/backend.py\n@@ -266,9 +266,12 @@ def search_in_index(self, queryset, search_query, start, stop):\n sql, index_params + model_params + limits)\n \n def search_in_fields(self, queryset, search_query, start, stop):\n+ # Due to a Django bug, arrays are not automatically converted here.\n+ converted_weights = '{' + ','.join(map(str, WEIGHTS_VALUES)) + '}'\n+\n return (self.get_in_fields_queryset(queryset, search_query)\n .annotate(_rank_=SearchRank(F('_search_'), search_query,\n- weights=WEIGHTS_VALUES))\n+ weights=converted_weights))\n .order_by('-_rank_'))[start:stop]\n \n def search(self, config, start, stop):\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Postgres search fails on Wagtail admin page chooser search\n### Issue Summary\r\n\r\nWhen trying to search using postgres search backend on wagtail admin page chooser I get server error (500).\r\n\r\n### Steps to Reproduce\r\n\r\n1. Clone wagtaildemo https://github.com/wagtail/wagtaildemo (I am using the Vagrant VM from the repo).\r\n2. Set wagtail search backend to postgres, migrate and update index as per instructions in http://docs.wagtail.io/en/v1.13/reference/contrib/postgres_search.html\r\n - Add `wagtail.contrib.postgres_search` to `INSTALLED_APPS`.\r\n - Add the following to the settings\r\n ```\r\n WAGTAILSEARCH_BACKENDS = {\r\n 'default': {\r\n 'BACKEND': 'wagtail.contrib.postgres_search.backend',\r\n },\r\n }\r\n - run `manage.py migrate` which successfully performs the postgres backend migration ` Applying postgres_search.0001_initial... OK`\r\n - run `migrate.py update_index`\r\n3. Try to search inside a page chooser. I personally used \"Link page\" on the \"Speakers\" inline panel on an event page in wagtaildemo, e.g. http://localhost:8000/admin/pages/8/edit/\r\n4. Any AJAX request made to the search fails with 500, see the log below.\r\n\r\nSuccessfully reproduced on another project, so it seems to be an issue with the postgres search backend.\r\n\r\n```\r\n[13/Nov/2017 15:20:41] \"GET /admin/choose-page/search/?page_type=wagtailcore.page&q=a&results_only=true HTTP/1.1\" 500 21736\r\nInternal Server Error: /admin/choose-page/search/\r\nTraceback (most recent call last):\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/exception.py\", line 41, in inner\r\n response = get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 249, in _legacy_get_response\r\n response = self._get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 187, in _get_response\r\n response = self.process_exception_by_middleware(e, request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 185, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/views/decorators/cache.py\", line 43, in _cache_controlled\r\n response = viewfunc(request, *args, **kw)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 96, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/decorators.py\", line 31, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/views/chooser.py\", line 171, in search\r\n for page in pages:\r\n File \"/usr/local/lib/python3.4/_collections_abc.py\", line 634, in __iter__\r\n v = self[i]\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/paginator.py\", line 145, in __getitem__\r\n self.object_list = list(self.object_list)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 172, in __iter__\r\n return iter(self.results())\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 138, in results\r\n self._results_cache = self._do_search()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/contrib/postgres_search/backend.py\", line 297, in _do_search\r\n self.start, self.stop))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailcore/query.py\", line 369, in specific_iterator\r\n for pk, content_type in pks_and_types:\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 122, in __iter__\r\n for row in compiler.results_iter():\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 836, in results_iter\r\n results = self.execute_sql(MULTI)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 871, in execute_sql\r\n sql, params = self.as_sql()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 423, in as_sql\r\n extra_select, order_by, group_by = self.pre_sql_setup()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 47, in pre_sql_setup\r\n order_by = self.get_order_by()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 335, in get_order_by\r\n if (without_ordering, tuple(params)) in seen:\r\nTypeError: unhashable type: 'list'\r\n```\r\n\r\n### Technical details\r\n\r\n* Python version: 3.4.3\r\n* Django version: 1.11.7\r\n* Wagtail version: 1.13\r\n* Browser version: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0\n"},"hints_text":{"kind":"string","value":"Thanks @tm-kn! Confirmed on Wagtail 1.13 here. Looks like this may well be related to the issues fixed in #3947 - although this one seems to be a regression from 1.12 to 1.13, which suggests that it's not one of the fixes backported in #3957 / #3958 (which affected 1.12 and 1.13 equally). Investigating now.\nCaused by https://github.com/wagtail/wagtail/commit/4063573f9c48e035a05321e98a2c89f2c310ceaa - evidently the Postgres search backend doesn't like working on a `specific()` queryset.\nCan be reproduced on the `./manage.py shell` command line with:\r\n\r\n Page.objects.specific().search('bread', fields=['title'])\r\n\r\nBoth the `specific` clause and the `fields` param are necessary to trigger the error.\n781263d4e1d4d8c95170f19667b61700fd3751d9 has fixed this on master - will see if this can be backported. ( @BertrandBordage, please shout if you're already working on this :-) )"},"created_at":{"kind":"string","value":"2017-11-14T14:54:40Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/exception.py\", line 41, in inner\r\n response = get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 249, in _legacy_get_response\r\n response = self._get_response(request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 187, in _get_response\r\n response = self.process_exception_by_middleware(e, request)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/handlers/base.py\", line 185, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/views/decorators/cache.py\", line 43, in _cache_controlled\r\n response = viewfunc(request, *args, **kw)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/urls/__init__.py\", line 96, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/decorators.py\", line 31, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailadmin/views/chooser.py\", line 171, in search\r\n for page in pages:\r\n File \"/usr/local/lib/python3.4/_collections_abc.py\", line 634, in __iter__\r\n v = self[i]\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/core/paginator.py\", line 145, in __getitem__\r\n self.object_list = list(self.object_list)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 172, in __iter__\r\n return iter(self.results())\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailsearch/backends/base.py\", line 138, in results\r\n self._results_cache = self._do_search()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/contrib/postgres_search/backend.py\", line 297, in _do_search\r\n self.start, self.stop))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/wagtail/wagtailcore/query.py\", line 369, in specific_iterator\r\n for pk, content_type in pks_and_types:\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 250, in __iter__\r\n self._fetch_all()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 1118, in _fetch_all\r\n self._result_cache = list(self._iterable_class(self))\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/query.py\", line 122, in __iter__\r\n for row in compiler.results_iter():\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 836, in results_iter\r\n results = self.execute_sql(MULTI)\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 871, in execute_sql\r\n sql, params = self.as_sql()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 423, in as_sql\r\n extra_select, order_by, group_by = self.pre_sql_setup()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 47, in pre_sql_setup\r\n order_by = self.get_order_by()\r\n File \"/home/vagrant/.virtualenvs/wagtaildemo/lib/python3.4/site-packages/django/db/models/sql/compiler.py\", line 335, in get_order_by\r\n if (without_ordering, tuple(params)) in seen:\r\nTypeError: unhashable type: 'list'\r\n"},"__index_level_0__":{"kind":"number","value":18449,"string":"18,449"}}},{"rowIdx":1539,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-423"},"base_commit":{"kind":"string","value":"14228a56e14a72ff8b559296d61538d4f4bd3621"},"patch":{"kind":"string","value":"diff --git a/wagtail/wagtailsearch/models.py b/wagtail/wagtailsearch/models.py\n--- a/wagtail/wagtailsearch/models.py\n+++ b/wagtail/wagtailsearch/models.py\n@@ -76,6 +76,9 @@ class EditorsPick(models.Model):\n sort_order = models.IntegerField(null=True, blank=True, editable=False)\n description = models.TextField(blank=True)\n \n+ def __repr__(self):\n+ return 'EditorsPick(query=\"' + self.query.query_string + '\", page=\"' + self.page.title + '\")'\n+\n class Meta:\n ordering = ('sort_order', )\n \ndiff --git a/wagtail/wagtailsearch/views/editorspicks.py b/wagtail/wagtailsearch/views/editorspicks.py\n--- a/wagtail/wagtailsearch/views/editorspicks.py\n+++ b/wagtail/wagtailsearch/views/editorspicks.py\n@@ -55,6 +55,9 @@ def save_editorspicks(query, new_query, editors_pick_formset):\n for i, form in enumerate(editors_pick_formset.ordered_forms):\n form.instance.sort_order = i\n \n+ # Make sure the form is marked as changed so it gets saved with the new order\n+ form.has_changed = lambda: True\n+\n editors_pick_formset.save()\n \n # If query was changed, move all editors picks to the new query\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"test_post_reorder in editors picks unit tests failing on Sqlite\nRunning the unit tests under sqlite:\n\n```\nDATABASE_ENGINE=django.db.backends.sqlite3 ./runtests.py\n```\n\nresults in this test failure:\n\n```\nFAIL: test_post_reorder (wagtail.wagtailsearch.tests.test_editorspicks.TestEditorsPicksEditView)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"/home/vagrant/wagtail/wagtail/wagtailsearch/tests/test_editorspicks.py\", line 222, in test_post_reorder\n self.assertEqual(models.Query.get(\"Hello\").editors_picks.all()[0], self.editors_pick_2)\nAssertionError: != \n\n----------------------------------------------------------------------\nRan 446 tests in 36.358s\n\nFAILED (failures=1, skipped=9, expected failures=1)\nDestroying test database for alias 'default'...\n```\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2014-07-04T10:42:23Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"/home/vagrant/wagtail/wagtail/wagtailsearch/tests/test_editorspicks.py\", line 222, in test_post_reorder\n self.assertEqual(models.Query.get(\"Hello\").editors_picks.all()[0], self.editors_pick_2)\nAssertionError: != \n"},"__index_level_0__":{"kind":"number","value":18456,"string":"18,456"}}},{"rowIdx":1540,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-651"},"base_commit":{"kind":"string","value":"5f09dd688c650b74ed509b323a0421aad4b79ea0"},"patch":{"kind":"string","value":"diff --git a/wagtail/bin/wagtail.py b/wagtail/bin/wagtail.py\n--- a/wagtail/bin/wagtail.py\n+++ b/wagtail/bin/wagtail.py\n@@ -2,11 +2,11 @@\n from __future__ import print_function, absolute_import\n \n import os\n-import subprocess\n import errno\n import sys\n \n from optparse import OptionParser\n+from django.core.management import ManagementUtility\n \n \n def create_project(parser, options, args):\n@@ -44,15 +44,15 @@ def create_project(parser, options, args):\n template_path = os.path.join(wagtail_path, 'project_template')\n \n # Call django-admin startproject\n- result = subprocess.call([\n+ utility = ManagementUtility([\n 'django-admin.py', 'startproject',\n '--template=' + template_path,\n '--name=Vagrantfile', '--ext=html,rst',\n project_name\n ])\n+ utility.execute()\n \n- if result == 0:\n- print(\"Success! %(project_name)s is created\" % {'project_name': project_name})\n+ print(\"Success! %(project_name)s is created\" % {'project_name': project_name})\n \n \n COMMANDS = {\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"\"wagtail start project_name\" fails to run on Windows 7\nHi. So everything is compiled perfectly inside the virtualenv and I'm trying to start a new project.\n\n```\n$ wagtail start wagtailtest\nCreating a wagtail project called wagtailtest\nTraceback (most recent call last):\n File \"d:\\VirtualEnvs\\wagtail_env\\Scripts\\wagtail-script.py\", line 9, in \n load_entry_point('wagtail==0.6', 'console_scripts', 'wagtail')()\n File \"d:\\VirtualEnvs\\wagtail_env\\lib\\site-packages\\wagtail\\bin\\wagtail.py\", line 75, in main\n COMMANDS[command](parser, options, args)\n File \"d:\\VirtualEnvs\\wagtail_env\\lib\\site-packages\\wagtail\\bin\\wagtail.py\", line 51, in create_project\n project_name\n File \"C:\\Python27\\Lib\\subprocess.py\", line 522, in call\n return Popen(*popenargs, **kwargs).wait()\n File \"C:\\Python27\\Lib\\subprocess.py\", line 710, in __init__\n errread, errwrite)\n File \"C:\\Python27\\Lib\\subprocess.py\", line 958, in _execute_child\n startupinfo)\nWindowsError: [Error 193] %1 is not a valid Win32 application\n```\n\nWindows 7 x64, Python 2.7 x32.\n\n"},"hints_text":{"kind":"string","value":"Seriously guys, is there a way I fix that? VS11 and 12 is installed.\n\nThe issue I opened refers to an installation with Visual Studio 12 installed and:\n\n```\nVS90COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Tools\\\n```\n\nIf I set the VS90COMNTOOLS to point to Visual Studio 11 tools directory, the output of wagtail-script.py or wagtail.exe is:\n\n```\nwagtail.exe: Bad file number\n```\n"},"created_at":{"kind":"string","value":"2014-09-24T23:24:16Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\n File \"d:\\VirtualEnvs\\wagtail_env\\Scripts\\wagtail-script.py\", line 9, in \n load_entry_point('wagtail==0.6', 'console_scripts', 'wagtail')()\n File \"d:\\VirtualEnvs\\wagtail_env\\lib\\site-packages\\wagtail\\bin\\wagtail.py\", line 75, in main\n COMMANDS[command](parser, options, args)\n File \"d:\\VirtualEnvs\\wagtail_env\\lib\\site-packages\\wagtail\\bin\\wagtail.py\", line 51, in create_project\n project_name\n File \"C:\\Python27\\Lib\\subprocess.py\", line 522, in call\n return Popen(*popenargs, **kwargs).wait()\n File \"C:\\Python27\\Lib\\subprocess.py\", line 710, in __init__\n errread, errwrite)\n File \"C:\\Python27\\Lib\\subprocess.py\", line 958, in _execute_child\n startupinfo)\nWindowsError: [Error 193] %1 is not a valid Win32 application\n"},"__index_level_0__":{"kind":"number","value":18518,"string":"18,518"}}},{"rowIdx":1541,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-6547"},"base_commit":{"kind":"string","value":"a888d3383c25a09d0a20833364820fb19d59b309"},"patch":{"kind":"string","value":"diff --git a/wagtail/core/utils.py b/wagtail/core/utils.py\n--- a/wagtail/core/utils.py\n+++ b/wagtail/core/utils.py\n@@ -220,8 +220,23 @@ def get_content_languages():\n if content_languages is None:\n # Default to a single language based on LANGUAGE_CODE\n default_language_code = get_supported_language_variant(settings.LANGUAGE_CODE)\n+ try:\n+ language_name = languages[default_language_code]\n+ except KeyError:\n+ # get_supported_language_variant on the 'null' translation backend (used for\n+ # USE_I18N=False) returns settings.LANGUAGE_CODE unchanged without accounting for\n+ # language variants (en-us versus en), so retry with the generic version.\n+ default_language_code = default_language_code.split(\"-\")[0]\n+ try:\n+ language_name = languages[default_language_code]\n+ except KeyError:\n+ # Can't extract a display name, so fall back on displaying LANGUAGE_CODE instead\n+ language_name = settings.LANGUAGE_CODE\n+ # Also need to tweak the languages dict to get around the check below\n+ languages[default_language_code] = settings.LANGUAGE_CODE\n+\n content_languages = [\n- (default_language_code, languages[default_language_code]),\n+ (default_language_code, language_name),\n ]\n \n # Check that each content language is in LANGUAGES\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"New project fails with USE_I18N=False\n### Issue Summary\r\n\r\nInitial migrations fail on Wagtail 2.11.1 with USE_I18N = False and LANGUAGE_CODE = 'en-us' in settings.\r\n\r\n### Steps to Reproduce\r\n\r\n1. Start a new project with `wagtail start myproject`\r\n2. Edit `myproject/settings/base.py` and set `USE_I18N = False`\r\n3. Run `./manage.py migrate`\r\n\r\nThis throws the exception:\r\n```\r\nTraceback (most recent call last):\r\n File \"./manage.py\", line 10, in \r\n execute_from_command_line(sys.argv)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/__init__.py\", line 401, in execute_from_command_line\r\n utility.execute()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/__init__.py\", line 395, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py\", line 330, in run_from_argv\r\n self.execute(*args, **cmd_options)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py\", line 371, in execute\r\n output = self.handle(*args, **options)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py\", line 85, in wrapped\r\n res = handle_func(*args, **kwargs)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/commands/migrate.py\", line 92, in handle\r\n executor = MigrationExecutor(connection, self.migration_progress_callback)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/executor.py\", line 18, in __init__\r\n self.loader = MigrationLoader(self.connection)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py\", line 53, in __init__\r\n self.build_graph()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py\", line 210, in build_graph\r\n self.load_disk()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py\", line 112, in load_disk\r\n migration_module = import_module(migration_path)\r\n File \"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py\", line 127, in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\n File \"\", line 1006, in _gcd_import\r\n File \"\", line 983, in _find_and_load\r\n File \"\", line 967, in _find_and_load_unlocked\r\n File \"\", line 677, in _load_unlocked\r\n File \"\", line 728, in exec_module\r\n File \"\", line 219, in _call_with_frames_removed\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/migrations/0056_page_locale_fields_populate.py\", line 8, in \r\n class Migration(migrations.Migration):\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/migrations/0056_page_locale_fields_populate.py\", line 15, in Migration\r\n BootstrapTranslatableModel('wagtailcore.Page'),\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/models.py\", line 538, in __init__\r\n language_code = get_supported_content_language_variant(settings.LANGUAGE_CODE)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/utils.py\", line 261, in get_supported_content_language_variant\r\n supported_lang_codes = get_content_languages()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/utils.py\", line 224, in get_content_languages\r\n (default_language_code, languages[default_language_code]),\r\nKeyError: 'en-us'\r\n```\r\n\r\nThis seems to happen because with USE_I18N = False, the implementation of `get_supported_language_variant` in Django's 'null' i18n backend returns LANGUAGE_CODE unchanged, whereas the real one takes fallbacks into account (returning 'en' for 'en-us'). Wagtail's `get_content_languages` then expects to find this in settings.LANGUAGES, which fails because [Django's master LANGUAGES list](https://github.com/django/django/blob/stable/3.1.x/django/conf/global_settings.py) contains 'en', not 'en-us'.\r\n\r\n* I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes\r\n\r\n\r\n### Technical details\r\n\r\n* Python version: 3.7.2\r\n* Django version: 3.1.3\r\n* Wagtail version: 2.11.1\r\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2020-11-13T19:18:55Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"./manage.py\", line 10, in \r\n execute_from_command_line(sys.argv)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/__init__.py\", line 401, in execute_from_command_line\r\n utility.execute()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/__init__.py\", line 395, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py\", line 330, in run_from_argv\r\n self.execute(*args, **cmd_options)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py\", line 371, in execute\r\n output = self.handle(*args, **options)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/base.py\", line 85, in wrapped\r\n res = handle_func(*args, **kwargs)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/core/management/commands/migrate.py\", line 92, in handle\r\n executor = MigrationExecutor(connection, self.migration_progress_callback)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/executor.py\", line 18, in __init__\r\n self.loader = MigrationLoader(self.connection)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py\", line 53, in __init__\r\n self.build_graph()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py\", line 210, in build_graph\r\n self.load_disk()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/django/db/migrations/loader.py\", line 112, in load_disk\r\n migration_module = import_module(migration_path)\r\n File \"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py\", line 127, in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\n File \"\", line 1006, in _gcd_import\r\n File \"\", line 983, in _find_and_load\r\n File \"\", line 967, in _find_and_load_unlocked\r\n File \"\", line 677, in _load_unlocked\r\n File \"\", line 728, in exec_module\r\n File \"\", line 219, in _call_with_frames_removed\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/migrations/0056_page_locale_fields_populate.py\", line 8, in \r\n class Migration(migrations.Migration):\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/migrations/0056_page_locale_fields_populate.py\", line 15, in Migration\r\n BootstrapTranslatableModel('wagtailcore.Page'),\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/models.py\", line 538, in __init__\r\n language_code = get_supported_content_language_variant(settings.LANGUAGE_CODE)\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/utils.py\", line 261, in get_supported_content_language_variant\r\n supported_lang_codes = get_content_languages()\r\n File \"/Users/matthew/.virtualenvs/use18n/lib/python3.7/site-packages/wagtail/core/utils.py\", line 224, in get_content_languages\r\n (default_language_code, languages[default_language_code]),\r\nKeyError: 'en-us'\r\n"},"__index_level_0__":{"kind":"number","value":18519,"string":"18,519"}}},{"rowIdx":1542,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-6639"},"base_commit":{"kind":"string","value":"37684833523145e95984875efc2fff0adeab448a"},"patch":{"kind":"string","value":"diff --git a/wagtail/search/backends/base.py b/wagtail/search/backends/base.py\n--- a/wagtail/search/backends/base.py\n+++ b/wagtail/search/backends/base.py\n@@ -1,5 +1,7 @@\n from warnings import warn\n \n+from django.db.models.functions.datetime import Extract as ExtractDate\n+from django.db.models.functions.datetime import ExtractYear\n from django.db.models.lookups import Lookup\n from django.db.models.query import QuerySet\n from django.db.models.sql.where import SubqueryConstraint, WhereNode\n@@ -88,7 +90,16 @@ def _process_filter(self, field_attname, lookup, value, check_only=False):\n def _get_filters_from_where_node(self, where_node, check_only=False):\n # Check if this is a leaf node\n if isinstance(where_node, Lookup):\n- field_attname = where_node.lhs.target.attname\n+ if isinstance(where_node.lhs, ExtractDate):\n+ if isinstance(where_node.lhs, ExtractYear):\n+ field_attname = where_node.lhs.lhs.target.attname\n+ else:\n+ raise FilterError(\n+ 'Cannot apply filter on search results: \"' + where_node.lhs.lookup_name\n+ + '\" queries are not supported.'\n+ )\n+ else:\n+ field_attname = where_node.lhs.target.attname\n lookup = where_node.lookup_name\n value = where_node.rhs\n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"'ExtractYear' object has no attribute 'target'\n### Issue Summary\r\nCalling `search` queryset method on querysets that are filtered by exact year of a date throws AttributeError. This happens not only with `__year` but other exact matches also, e.g `__month`, `__day`. \r\n\r\n### Steps to Reproduce\r\n1. `wagtail start wagtail-test`\r\n2. `python manage shell`\r\n3. `from wagtail.core.models import Page`\r\n4. `Page.objects.filter(last_published_at__year=2020).search('hello')`\r\n\r\nHere is the traceback: \r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"\", line 1, in \r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/queryset.py\", line 11, in search\r\n return search_backend.search(query, self, fields=fields,\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 363, in search\r\n return self._search(\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 358, in _search\r\n search_query.check()\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 157, in check\r\n self._get_filters_from_where_node(self.queryset.query.where, check_only=True)\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 108, in _get_filters_from_where_node\r\n child_filters = [self._get_filters_from_where_node(child) for child in where_node.children]\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 108, in \r\n child_filters = [self._get_filters_from_where_node(child) for child in where_node.children]\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 91, in _get_filters_from_where_node\r\n field_attname = where_node.lhs.target.attname\r\nAttributeError: 'ExtractYear' object has no attribute 'target'\r\n\r\n```\r\n\r\n\r\n### Technical details\r\n\r\n* Python version: 3.8\r\n* Django version: 2.2.8\r\n* Wagtail version: 2.8.1\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2020-12-14T23:06:29Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"\", line 1, in \r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/queryset.py\", line 11, in search\r\n return search_backend.search(query, self, fields=fields,\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 363, in search\r\n return self._search(\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 358, in _search\r\n search_query.check()\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 157, in check\r\n self._get_filters_from_where_node(self.queryset.query.where, check_only=True)\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 108, in _get_filters_from_where_node\r\n child_filters = [self._get_filters_from_where_node(child) for child in where_node.children]\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 108, in \r\n child_filters = [self._get_filters_from_where_node(child) for child in where_node.children]\r\n File \"/Users/gadirrustamli/anaconda/envs/wagtail-test/lib/python3.8/site-packages/wagtail/search/backends/base.py\", line 91, in _get_filters_from_where_node\r\n field_attname = where_node.lhs.target.attname\r\nAttributeError: 'ExtractYear' object has no attribute 'target'\r\n"},"__index_level_0__":{"kind":"number","value":18520,"string":"18,520"}}},{"rowIdx":1543,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-7082"},"base_commit":{"kind":"string","value":"06be13fda03bc062cceac2fe724a26237ed7ff8f"},"patch":{"kind":"string","value":"diff --git a/wagtail/core/blocks/base.py b/wagtail/core/blocks/base.py\n--- a/wagtail/core/blocks/base.py\n+++ b/wagtail/core/blocks/base.py\n@@ -10,6 +10,7 @@\n from django.core.exceptions import ImproperlyConfigured\n from django.template.loader import render_to_string\n from django.utils.encoding import force_str\n+from django.utils.functional import cached_property\n from django.utils.html import format_html\n from django.utils.safestring import mark_safe\n from django.utils.text import capfirst\n@@ -475,8 +476,25 @@ class BlockWidget(forms.Widget):\n def __init__(self, block_def, attrs=None):\n super().__init__(attrs=attrs)\n self.block_def = block_def\n- self.js_context = JSContext()\n- self.block_json = json.dumps(self.js_context.pack(self.block_def))\n+ self._js_context = None\n+\n+ def _build_block_json(self):\n+ self._js_context = JSContext()\n+ self._block_json = json.dumps(self._js_context.pack(self.block_def))\n+\n+ @property\n+ def js_context(self):\n+ if self._js_context is None:\n+ self._build_block_json()\n+\n+ return self._js_context\n+\n+ @property\n+ def block_json(self):\n+ if self._js_context is None:\n+ self._build_block_json()\n+\n+ return self._block_json\n \n def render_with_errors(self, name, value, attrs=None, errors=None, renderer=None):\n value_json = json.dumps(self.block_def.get_form_state(value))\n@@ -499,7 +517,7 @@ def render_with_errors(self, name, value, attrs=None, errors=None, renderer=None\n def render(self, name, value, attrs=None, renderer=None):\n return self.render_with_errors(name, value, attrs=attrs, errors=None, renderer=renderer)\n \n- @property\n+ @cached_property\n def media(self):\n return self.js_context.media + forms.Media(\n js=[\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"Missing staticfiles manifest from Wagtail checks before collectstatic\n### Issue Summary\r\n\r\nWith Wagtail 2.13rc1, running certain Django commands which use the checks framework *before* running collectstatic will result in an exception. Quick example:\r\n\r\n```shell\r\n./manage.py makemigrations --settings=demo.settings.production --dry-run --check\r\n...\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 417, in stored_name\r\n raise ValueError(\"Missing staticfiles manifest entry for '%s'\" % clean_name)\r\nValueError: Missing staticfiles manifest entry for 'wagtailadmin/js/telepath/telepath.js'\r\n```\r\n\r\nThis might be a little bit obscure, and is something that can be worked around. My particular use case is that we run commands such as makemigrations to prevent missed migrations, and validate_templates from django-extensions - these are done before collectstatic.\r\n\r\nThe collectstatic command *does* work as expected though.\r\n\r\n### Steps to Reproduce\r\n\r\n```shell\r\npip install Wagtail==2.13rc1\r\nwagtail start demo\r\ncd demo\r\necho \"SECRET_KEY='secret'\" > demo/settings/local.py\r\ncat > home/models.py <\r\n execute_from_command_line(sys.argv)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n utility.execute()\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/__init__.py\", line 413, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/base.py\", line 354, in run_from_argv\r\n self.execute(*args, **cmd_options)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/base.py\", line 393, in execute\r\n self.check()\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/base.py\", line 419, in check\r\n all_issues = checks.run_checks(\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/checks/registry.py\", line 76, in run_checks\r\n new_errors = check(app_configs=app_configs, databases=databases)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/checks.py\", line 63, in get_form_class_check\r\n if not issubclass(edit_handler.get_form_class(), WagtailAdminPageForm):\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py\", line 355, in get_form_class\r\n return get_form_for_model(\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py\", line 67, in get_form_for_model\r\n return metaclass(class_name, (form_class,), form_class_attrs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/forms/models.py\", line 75, in __new__\r\n new_class = super(WagtailAdminModelFormMetaclass, cls).__new__(cls, name, bases, attrs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/modelcluster/forms.py\", line 234, in __new__\r\n new_class = super(ClusterFormMetaclass, cls).__new__(cls, name, bases, attrs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/forms/models.py\", line 261, in __new__\r\n fields = fields_for_model(\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/forms/models.py\", line 187, in fields_for_model\r\n formfield = formfield_callback(f, **kwargs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/forms/models.py\", line 56, in formfield_for_dbfield\r\n return db_field.formfield(**kwargs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/fields.py\", line 148, in formfield\r\n return super().formfield(**defaults)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/db/models/fields/__init__.py\", line 948, in formfield\r\n return form_class(**defaults)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/blocks/base.py\", line 531, in __init__\r\n kwargs['widget'] = BlockWidget(block)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/blocks/base.py\", line 478, in __init__\r\n self.js_context = JSContext()\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/telepath/__init__.py\", line 181, in __init__\r\n self.media = self.base_media\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/telepath.py\", line 11, in base_media\r\n versioned_static(self.telepath_js_path),\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/staticfiles.py\", line 48, in versioned_static\r\n base_url = static(path)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/templatetags/static.py\", line 167, in static\r\n return StaticNode.handle_simple(path)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/templatetags/static.py\", line 118, in handle_simple\r\n return staticfiles_storage.url(path)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 147, in url\r\n return self._url(self.stored_name, name, force)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 126, in _url\r\n hashed_name = hashed_name_func(*args)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 417, in stored_name\r\n raise ValueError(\"Missing staticfiles manifest entry for '%s'\" % clean_name)\r\nValueError: Missing staticfiles manifest entry for 'wagtailadmin/js/telepath/telepath.js'\r\n```\r\n\r\n\r\n### Technical details\r\n\r\n* Python version: 3.9\r\n* Django version: 3.2\r\n* Wagtail version: 2.13rc1\r\n\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2021-04-22T17:14:46Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/demo/./manage.py\", line 10, in \r\n execute_from_command_line(sys.argv)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n utility.execute()\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/__init__.py\", line 413, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/base.py\", line 354, in run_from_argv\r\n self.execute(*args, **cmd_options)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/base.py\", line 393, in execute\r\n self.check()\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/management/base.py\", line 419, in check\r\n all_issues = checks.run_checks(\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/core/checks/registry.py\", line 76, in run_checks\r\n new_errors = check(app_configs=app_configs, databases=databases)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/checks.py\", line 63, in get_form_class_check\r\n if not issubclass(edit_handler.get_form_class(), WagtailAdminPageForm):\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py\", line 355, in get_form_class\r\n return get_form_for_model(\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py\", line 67, in get_form_for_model\r\n return metaclass(class_name, (form_class,), form_class_attrs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/forms/models.py\", line 75, in __new__\r\n new_class = super(WagtailAdminModelFormMetaclass, cls).__new__(cls, name, bases, attrs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/modelcluster/forms.py\", line 234, in __new__\r\n new_class = super(ClusterFormMetaclass, cls).__new__(cls, name, bases, attrs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/forms/models.py\", line 261, in __new__\r\n fields = fields_for_model(\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/forms/models.py\", line 187, in fields_for_model\r\n formfield = formfield_callback(f, **kwargs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/forms/models.py\", line 56, in formfield_for_dbfield\r\n return db_field.formfield(**kwargs)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/fields.py\", line 148, in formfield\r\n return super().formfield(**defaults)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/db/models/fields/__init__.py\", line 948, in formfield\r\n return form_class(**defaults)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/blocks/base.py\", line 531, in __init__\r\n kwargs['widget'] = BlockWidget(block)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/blocks/base.py\", line 478, in __init__\r\n self.js_context = JSContext()\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/telepath/__init__.py\", line 181, in __init__\r\n self.media = self.base_media\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/core/telepath.py\", line 11, in base_media\r\n versioned_static(self.telepath_js_path),\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/wagtail/admin/staticfiles.py\", line 48, in versioned_static\r\n base_url = static(path)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/templatetags/static.py\", line 167, in static\r\n return StaticNode.handle_simple(path)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/templatetags/static.py\", line 118, in handle_simple\r\n return staticfiles_storage.url(path)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 147, in url\r\n return self._url(self.stored_name, name, force)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 126, in _url\r\n hashed_name = hashed_name_func(*args)\r\n File \"/Users/tomkins/.virtualenvs/tmp-ec5df8b3f9892a8/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py\", line 417, in stored_name\r\n raise ValueError(\"Missing staticfiles manifest entry for '%s'\" % clean_name)\r\nValueError: Missing staticfiles manifest entry for 'wagtailadmin/js/telepath/telepath.js'\r\n"},"__index_level_0__":{"kind":"number","value":18535,"string":"18,535"}}},{"rowIdx":1544,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-8391"},"base_commit":{"kind":"string","value":"484ca159d203ec54c789053b2e16305b00bd7703"},"patch":{"kind":"string","value":"diff --git a/wagtail/admin/panels.py b/wagtail/admin/panels.py\n--- a/wagtail/admin/panels.py\n+++ b/wagtail/admin/panels.py\n@@ -501,10 +501,9 @@ def __init__(\n self,\n content=\"\",\n template=\"wagtailadmin/panels/help_panel.html\",\n- heading=\"\",\n- classname=\"\",\n+ **kwargs,\n ):\n- super().__init__(heading=heading, classname=classname)\n+ super().__init__(**kwargs)\n self.content = content\n self.template = template\n \n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"HelpPanel broken in 3.0rc1\nFrom a fresh bakerydemo project, edit bakerydemo/base/models.py, change the import at the top to\r\n\r\n```\r\nfrom wagtail.admin.edit_handlers import (\r\n FieldPanel,\r\n FieldRowPanel,\r\n InlinePanel,\r\n MultiFieldPanel,\r\n PageChooserPanel,\r\n StreamFieldPanel,\r\n HelpPanel,\r\n)\r\n```\r\nand add to the top of the `content_panels` definition for HomePage:\r\n\r\n content_panels = Page.content_panels + [\r\n HelpPanel(\"

does this work?

\"),\r\n MultiFieldPanel([\r\n\r\nThis causes `manage.py runserver` to fail with:\r\n\r\n```\r\nPerforming system checks...\r\n\r\nException in thread django-main-thread:\r\nTraceback (most recent call last):\r\n File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py\", line 932, in _bootstrap_inner\r\n self.run()\r\n File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py\", line 870, in run\r\n self._target(*self._args, **self._kwargs)\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/utils/autoreload.py\", line 64, in wrapper\r\n fn(*args, **kwargs)\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/core/management/commands/runserver.py\", line 134, in inner_run\r\n self.check(display_num_errors=True)\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/core/management/base.py\", line 487, in check\r\n all_issues = checks.run_checks(\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/core/checks/registry.py\", line 88, in run_checks\r\n new_errors = check(app_configs=app_configs, databases=databases)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/checks.py\", line 69, in get_form_class_check\r\n edit_handler = cls.get_edit_handler()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/utils/decorators.py\", line 54, in __call__\r\n return self.value\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/utils/functional.py\", line 49, in __get__\r\n res = instance.__dict__[self.name] = self.func(instance)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/utils/decorators.py\", line 50, in value\r\n return self.fn(self.cls)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 1083, in get_edit_handler\r\n return edit_handler.bind_to_model(cls)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 207, in bind_to_model\r\n new.on_model_bound()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in on_model_bound\r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in \r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 207, in bind_to_model\r\n new.on_model_bound()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in on_model_bound\r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in \r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 205, in bind_to_model\r\n new = self.clone()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 120, in clone\r\n return self.__class__(**self.clone_kwargs())\r\nTypeError: __init__() got an unexpected keyword argument 'base_form_class'\r\n```\r\n\r\nTested on Wagtail 3.0rc1, Django 4.0.4, Python 3.8.0.\n"},"hints_text":{"kind":"string","value":""},"created_at":{"kind":"string","value":"2022-04-19T16:16:50Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py\", line 932, in _bootstrap_inner\r\n self.run()\r\n File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py\", line 870, in run\r\n self._target(*self._args, **self._kwargs)\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/utils/autoreload.py\", line 64, in wrapper\r\n fn(*args, **kwargs)\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/core/management/commands/runserver.py\", line 134, in inner_run\r\n self.check(display_num_errors=True)\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/core/management/base.py\", line 487, in check\r\n all_issues = checks.run_checks(\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/core/checks/registry.py\", line 88, in run_checks\r\n new_errors = check(app_configs=app_configs, databases=databases)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/checks.py\", line 69, in get_form_class_check\r\n edit_handler = cls.get_edit_handler()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/utils/decorators.py\", line 54, in __call__\r\n return self.value\r\n File \"/Users/matthew/.virtualenvs/wagtail/lib/python3.8/site-packages/django/utils/functional.py\", line 49, in __get__\r\n res = instance.__dict__[self.name] = self.func(instance)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/utils/decorators.py\", line 50, in value\r\n return self.fn(self.cls)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 1083, in get_edit_handler\r\n return edit_handler.bind_to_model(cls)\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 207, in bind_to_model\r\n new.on_model_bound()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in on_model_bound\r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in \r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 207, in bind_to_model\r\n new.on_model_bound()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in on_model_bound\r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 417, in \r\n self.children = [child.bind_to_model(self.model) for child in self.children]\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 205, in bind_to_model\r\n new = self.clone()\r\n File \"/Users/matthew/Development/tbx/wagtail/devscript/wagtail/wagtail/admin/panels.py\", line 120, in clone\r\n return self.__class__(**self.clone_kwargs())\r\nTypeError: __init__() got an unexpected keyword argument 'base_form_class'\r\n"},"__index_level_0__":{"kind":"number","value":18605,"string":"18,605"}}},{"rowIdx":1545,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-9009"},"base_commit":{"kind":"string","value":"666cc5e8e5889bc95b527b8ef2af3841ffe0d2b7"},"patch":{"kind":"string","value":"diff --git a/wagtail/admin/viewsets/chooser.py b/wagtail/admin/viewsets/chooser.py\n--- a/wagtail/admin/viewsets/chooser.py\n+++ b/wagtail/admin/viewsets/chooser.py\n@@ -163,10 +163,13 @@ def widget_class(self):\n },\n )\n \n- @cached_property\n- def block_class(self):\n+ def get_block_class(self, name=None, module_path=None):\n \"\"\"\n Returns a StreamField ChooserBlock class using this chooser.\n+\n+ :param name: Name to give to the class; defaults to the model name with \"ChooserBlock\" appended\n+ :param module_path: The dotted path of the module where the class can be imported from; used when\n+ deconstructing the block definition for migration files.\n \"\"\"\n meta = type(\n \"Meta\",\n@@ -175,8 +178,8 @@ def block_class(self):\n \"icon\": self.icon,\n },\n )\n- return type(\n- \"%sChooserBlock\" % self.model_name,\n+ cls = type(\n+ name or \"%sChooserBlock\" % self.model_name,\n (self.base_block_class,),\n {\n \"target_model\": self.model,\n@@ -184,6 +187,9 @@ def block_class(self):\n \"Meta\": meta,\n },\n )\n+ if module_path:\n+ cls.__module__ = module_path\n+ return cls\n \n def get_urlpatterns(self):\n return super().get_urlpatterns() + [\ndiff --git a/wagtail/documents/blocks.py b/wagtail/documents/blocks.py\n--- a/wagtail/documents/blocks.py\n+++ b/wagtail/documents/blocks.py\n@@ -1,7 +1,5 @@\n from wagtail.documents.views.chooser import viewset as chooser_viewset\n \n-DocumentChooserBlock = chooser_viewset.block_class\n-\n-# When deconstructing a DocumentChooserBlock instance for migrations, the module path\n-# used in migrations should point to this module\n-DocumentChooserBlock.__module__ = \"wagtail.documents.blocks\"\n+DocumentChooserBlock = chooser_viewset.get_block_class(\n+ name=\"DocumentChooserBlock\", module_path=\"wagtail.documents.blocks\"\n+)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"wagtail 4.0rc1 migration ValueError: Could not find object DocumentChooserBlock\n### Issue Summary\r\n\r\n```\r\nOperations to perform:\r\n Apply all migrations: admin, auth, contenttypes, core, custom_documents, custom_images, custom_users, home, ...,\r\n No migrations to apply.\r\nTraceback (most recent call last):\r\n File \"django/./manage.py\", line 12, in \r\n execute_from_command_line(sys.argv)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n utility.execute()\r\n File \".venv/lib/python3.10/site-packages/django/core/management/__init__.py\", line 413, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/base.py\", line 354, in run_from_argv\r\n self.execute(*args, **cmd_options)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/base.py\", line 398, in execute\r\n output = self.handle(*args, **options)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/base.py\", line 89, in wrapped\r\n res = handle_func(*args, **kwargs)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py\", line 227, in handle\r\n changes = autodetector.changes(graph=executor.loader.graph)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 41, in changes\r\n changes = self._detect_changes(convert_apps, graph)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 184, in _detect_changes\r\n self.generate_altered_fields()\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 964, in generate_altered_fields\r\n old_field_dec = self.deep_deconstruct(old_field)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in deep_deconstruct\r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in \r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in deep_deconstruct\r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in \r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in deep_deconstruct\r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in \r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in deep_deconstruct\r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in \r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in deep_deconstruct\r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in \r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in deep_deconstruct\r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in \r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 71, in deep_deconstruct\r\n deconstructed = obj.deconstruct()\r\n File \".venv/lib/python3.10/site-packages/wagtail/blocks/base.py\", line 344, in deconstruct\r\n raise ValueError(\r\nValueError: Could not find object CustomDocumentChooserBlock in wagtail.blocks.base.\r\nPlease note that you cannot serialize things like inner classes. Please move the object into the main module body to use migrations.\r\n```\r\n\r\nI'm using a custom document model (`WAGTAILDOCS_DOCUMENT_MODEL = \"custom_documents.CustomDocument\"`) so I removed `WAGTAILDOCS_DOCUMENT_MODEL` setting it see if the error persisted and when running `./manage.py migrate` the ValueError changes to:\r\n\r\n```\r\nValueError: Could not find object DocumentChooserBlock in wagtail.blocks.base.\r\n```\r\n\r\n`CustomDocumentChooserBlock` -> `DocumentChooserBlock` \r\n\r\n\r\n### Steps to Reproduce\r\n\r\n1. run `./manage.py migrate` or `./manage.py makemigrations`\r\n\r\n- I couldn't reproduce this on a fresh install of wagtail 4.0rc1 however I have been unable to find a cause for this error in my project so far.\r\n\r\n### Technical details\r\n\r\n- Python version: 3.10.5\r\n- Django version: 3.2.15\r\n- Wagtail version: 4.0rc1\r\n-\nEnsure DocumentChooserBlock can be deconstructed for migrations\nFixes #8989. Now that DocumentChooserBlock is constructed dynamically via wagtail.documents.viewsets.chooser, we need to explicitly set its `__module__` attribute so that the result of calling `deconstruct()` for migrations points back to the wagtail.documents.blocks module.\r\n\r\nAlso update the documentation for defining custom choosers, and add tests for deconstructing the other chooser blocks.\r\n\n"},"hints_text":{"kind":"string","value":"Steps to recreate from scratch:\r\n\r\n```\r\npip install wagtail==4.0rc1\r\nwagtail start mysite\r\ncd mysite\r\npip install -r requirements.txt\r\n./manage.py migrate\r\ncat > home/models.py < This reminds me of something that has surprised me in the past: when blocks that inherit from from wagtail.blocks.ChooserBlock are serialized for migrations, they don't get serialized as \"plain instances\" as documented [here](https://docs.wagtail.org/en/stable/advanced_topics/customisation/streamfield_blocks.html#handling-block-definitions-within-migrations), like, say, blocks that inherit from ChoiceBlock do. Presumably this is because ChooserBlocks require some custom code implementation in a way that other block types do not?\r\n\r\nYep, that's correct. Whenever a custom Python object (such as a block object) appears in a model definition, the result of calling `deconstruct()` on that object will be \"baked in\" to the relevant migration files, which means that the creator of that object is effectively making a commitment that its definition will remain in place forever (or else people would have to go back and fix up historical migration files). This sort of commitment is reasonable for \"extension code\" (i.e. the sort of thing you might make into a Wagtail package), but not for \"application code\" (since the whole point of migrations is that developers should be able to add and remove things freely).\r\n\r\nIn the case of StructBlock and StreamBlock, there's a standardised pattern for subclassing them in a data-driven way within application code, and the base StructBlock / StreamBlock classes know enough about that pattern to be able to deconstruct them back into basic instances (providing they're not doing any backwards-incompatible code-level customisations alongside specifying child blocks), so the application developer isn't bound by that commitment. On the other hand, subclasses of ChooserBlock are liable to differ from the base class in ways that the base class can't know about, so there's no way to build an equivalent block object inside the migration without importing the subclass. And that's fine, because subclassing ChooserBlock is within the realm of \"extension code\", and people doing that are expected to commit to keeping those definitions around (or come up with their own `deconstruct()` logic to avoid that).\n@gasman I think this hasn't been fixed completely, as it seems like it only works when the custom document model is named \"Document\".\r\nIn our case, but also the original case above, and also if you just follow the [docs](https://docs.wagtail.org/en/latest/advanced_topics/documents/custom_document_model.html), when using a different model name the error remains.\r\n\r\nOur model for example is named `ExtendedDocument`, so the error now says (tested with the latest commits containing #9004):\r\n```\r\nValueError: Could not find object ExtendedDocumentChooserBlock in wagtail.blocks.base.\r\nPlease note that you cannot serialize things like inner classes. Please move the object into the main module body to use migrations.\r\n```\r\n\r\nThe `wagtail.admin.viewsets.chooser.ChooserViewSet.block_class` creates a class named `\"%sChooserBlock\" % self.model_name`, so this seems to make problems.\nI have also tested on the latest commits and can confirm the issue persists when using a different name for the custom document model.\n:+1: Merged with blackening of the docs change + changelog entries in a6a94a9a04a70334db73672024f9cafb99f5e0c9.\nCherry picked to 4.0 stable 5324720899f5ca7e9e0e890f0f9dfe53be59b66d"},"created_at":{"kind":"string","value":"2022-08-16T14:05:43Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"django/./manage.py\", line 12, in \r\n execute_from_command_line(sys.argv)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n utility.execute()\r\n File \".venv/lib/python3.10/site-packages/django/core/management/__init__.py\", line 413, in execute\r\n self.fetch_command(subcommand).run_from_argv(self.argv)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/base.py\", line 354, in run_from_argv\r\n self.execute(*args, **cmd_options)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/base.py\", line 398, in execute\r\n output = self.handle(*args, **options)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/base.py\", line 89, in wrapped\r\n res = handle_func(*args, **kwargs)\r\n File \".venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py\", line 227, in handle\r\n changes = autodetector.changes(graph=executor.loader.graph)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 41, in changes\r\n changes = self._detect_changes(convert_apps, graph)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 184, in _detect_changes\r\n self.generate_altered_fields()\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 964, in generate_altered_fields\r\n old_field_dec = self.deep_deconstruct(old_field)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in deep_deconstruct\r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in \r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in deep_deconstruct\r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in \r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in deep_deconstruct\r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in \r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in deep_deconstruct\r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 78, in \r\n [self.deep_deconstruct(value) for value in args],\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in deep_deconstruct\r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 54, in \r\n return [self.deep_deconstruct(value) for value in obj]\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in deep_deconstruct\r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 56, in \r\n return tuple(self.deep_deconstruct(value) for value in obj)\r\n File \".venv/lib/python3.10/site-packages/django/db/migrations/autodetector.py\", line 71, in deep_deconstruct\r\n deconstructed = obj.deconstruct()\r\n File \".venv/lib/python3.10/site-packages/wagtail/blocks/base.py\", line 344, in deconstruct\r\n raise ValueError(\r\nValueError: Could not find object CustomDocumentChooserBlock in wagtail.blocks.base.\r\n"},"__index_level_0__":{"kind":"number","value":18635,"string":"18,635"}}},{"rowIdx":1546,"cells":{"repo":{"kind":"string","value":"wagtail/wagtail"},"instance_id":{"kind":"string","value":"wagtail__wagtail-9572"},"base_commit":{"kind":"string","value":"9c29e6a12e3a06a01903fd20035ba870bd7bbf58"},"patch":{"kind":"string","value":"diff --git a/wagtail/images/fields.py b/wagtail/images/fields.py\n--- a/wagtail/images/fields.py\n+++ b/wagtail/images/fields.py\n@@ -124,10 +124,11 @@ def to_python(self, data):\n if f is None:\n return None\n \n- # We need to get a file object for Pillow. We might have a path or we might\n- # have to read the data into memory.\n+ # We need to get a file object for Pillow. When we get a path, we need to open\n+ # the file first. And we have to read the data into memory to pass to Willow.\n if hasattr(data, \"temporary_file_path\"):\n- file = data.temporary_file_path()\n+ with open(data.temporary_file_path(), \"rb\") as fh:\n+ file = BytesIO(fh.read())\n else:\n if hasattr(data, \"read\"):\n file = BytesIO(data.read())\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"[Nightly] Image upload broken for some images\n### Issue Summary\r\n\r\nIn the current Nightly version, it is no longer possible for me to upload an image. Maybe it is already known or fixed, but I preferred to report it.\r\n\r\n```text\r\nInternal Server Error: /admin/images/multiple/add/\r\nTraceback (most recent call last):\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/core/handlers/exception.py\", line 55, in inner\r\n response = get_response(request)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/core/handlers/base.py\", line 197, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/decorators/cache.py\", line 62, in _wrapped_view_func\r\n response = view_func(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/urls/__init__.py\", line 170, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/auth.py\", line 205, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/generic/base.py\", line 103, in view\r\n return self.dispatch(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/utils/decorators.py\", line 46, in _wrapper\r\n return bound_method(*args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/decorators/vary.py\", line 21, in inner_func\r\n response = func(*args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/views/generic/multiple_upload.py\", line 44, in dispatch\r\n return super().dispatch(request)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/views/generic/permissions.py\", line 36, in dispatch\r\n return super().dispatch(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/generic/base.py\", line 142, in dispatch\r\n return handler(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/views/generic/multiple_upload.py\", line 144, in post\r\n if form.is_valid():\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 205, in is_valid\r\n return self.is_bound and not self.errors\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 200, in errors\r\n self.full_clean()\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 437, in full_clean\r\n self._clean_fields()\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 447, in _clean_fields\r\n value = field.clean(value, bf.initial)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/fields.py\", line 678, in clean\r\n return super().clean(data)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/fields.py\", line 198, in clean\r\n value = self.to_python(value)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/images/fields.py\", line 156, in to_python\r\n self.check_image_pixel_size(f)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/images/fields.py\", line 107, in check_image_pixel_size\r\n width, height = f.image.get_size()\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/willow/image.py\", line 78, in wrapper\r\n image = converter(image)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/willow/plugins/pillow.py\", line 248, in open\r\n image_file.f.seek(0)\r\nAttributeError: 'str' object has no attribute 'seek'\r\n[01/Nov/2022 10:28:08] \"POST /admin/images/multiple/add/ HTTP/1.1\" 500 150299\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\n1. Start a new project with `wagtail start myproject`\r\n2. Install the nightly version `pip install https://releases.wagtail.org/nightly/dist/wagtail-4.2.dev20221101-py3-none-any.whl`\r\n3. Start the server and open the wagtail admin interface\r\n4. Click on `Images` in the left sidebar\r\n5. Upload an image\r\n\r\nAny other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?\r\n\r\n- I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes\r\n\r\n### Technical details\r\n\r\n- Python version: 3.10.8\r\n- Django version: 4.1.1\r\n- Wagtail version: 4.2.dev20221101\r\n- Browser version: Firefox 106 and Chrome 107\r\n\n"},"hints_text":{"kind":"string","value":"Thank you @vorlif \r\n\r\n#8974 made changes to the image field used under the hood.\r\nI tested this locally and did not encounter any issues. One for me to double check.\n@zerolab Thanks for the quick reply. After your feedback I tried a few other pictures and many of them were working. Here once a picture which did not go. One time compressed in case Github converts the images.\r\n\r\nWith version 4.0 and 4.1rc1 the image could still be uploaded. The pictures that don't work are, I believe, all from the same smartphone. (Samsung Galaxy S8)\r\n\r\n![20210808_204140](https://user-images.githubusercontent.com/4333770/199217772-86ffab5c-df55-475c-969e-9862109fd920.jpg)\r\n[20210808_204140.zip](https://github.com/wagtail/wagtail/files/9909159/20210808_204140.zip)\r\n"},"created_at":{"kind":"string","value":"2022-11-02T09:04:55Z"},"version":{"kind":"string","value":""},"FAIL_TO_PASS":{"kind":"string","value":"[]"},"PASS_TO_PASS":{"kind":"string","value":"[]"},"environment_setup_commit":{"kind":"string","value":""},"traceback":{"kind":"string","value":"\nTraceback (most recent call last):\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/core/handlers/exception.py\", line 55, in inner\r\n response = get_response(request)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/core/handlers/base.py\", line 197, in _get_response\r\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/decorators/cache.py\", line 62, in _wrapped_view_func\r\n response = view_func(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/urls/__init__.py\", line 170, in wrapper\r\n return view_func(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/auth.py\", line 205, in decorated_view\r\n return view_func(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/generic/base.py\", line 103, in view\r\n return self.dispatch(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/utils/decorators.py\", line 46, in _wrapper\r\n return bound_method(*args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/decorators/vary.py\", line 21, in inner_func\r\n response = func(*args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/views/generic/multiple_upload.py\", line 44, in dispatch\r\n return super().dispatch(request)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/views/generic/permissions.py\", line 36, in dispatch\r\n return super().dispatch(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/views/generic/base.py\", line 142, in dispatch\r\n return handler(request, *args, **kwargs)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/admin/views/generic/multiple_upload.py\", line 144, in post\r\n if form.is_valid():\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 205, in is_valid\r\n return self.is_bound and not self.errors\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 200, in errors\r\n self.full_clean()\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 437, in full_clean\r\n self._clean_fields()\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/forms.py\", line 447, in _clean_fields\r\n value = field.clean(value, bf.initial)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/fields.py\", line 678, in clean\r\n return super().clean(data)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/django/forms/fields.py\", line 198, in clean\r\n value = self.to_python(value)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/images/fields.py\", line 156, in to_python\r\n self.check_image_pixel_size(f)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/wagtail/images/fields.py\", line 107, in check_image_pixel_size\r\n width, height = f.image.get_size()\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/willow/image.py\", line 78, in wrapper\r\n image = converter(image)\r\n File \"/wagtailNightly/.env/lib/python3.10/site-packages/willow/plugins/pillow.py\", line 248, in open\r\n image_file.f.seek(0)\r\nAttributeError: 'str' object has no attribute 'seek'\r\n"},"__index_level_0__":{"kind":"number","value":18668,"string":"18,668"}}},{"rowIdx":1547,"cells":{"repo":{"kind":"string","value":"ytdl-org/youtube-dl"},"instance_id":{"kind":"string","value":"ytdl-org__youtube-dl-10971"},"base_commit":{"kind":"string","value":"a81dc8215127b4e9247bc390ade7bcf07b5079c3"},"patch":{"kind":"string","value":"diff --git a/youtube_dl/extractor/openload.py b/youtube_dl/extractor/openload.py\n--- a/youtube_dl/extractor/openload.py\n+++ b/youtube_dl/extractor/openload.py\n@@ -70,10 +70,15 @@ def _real_extract(self, url):\n r']*>([^<]+)\\s*]*>[^<]+\\s*]+id=\"streamurl\"',\n webpage, 'encrypted data')\n \n+ magic = compat_ord(enc_data[-1])\n video_url_chars = []\n \n for idx, c in enumerate(enc_data):\n j = compat_ord(c)\n+ if j == magic:\n+ j -= 1\n+ elif j == magic - 1:\n+ j += 1\n if j >= 33 and j <= 126:\n j = ((j + 14) % 94) + 33\n if idx == len(enc_data) - 1:\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"openload.co extractor not working\n youtube-dl --get-url --verbose https://openload.co/embed/kUEfGclsU9o/\n[debug] System config: []\n[debug] User config: []\n[debug] Command-line args: [u'--get-url', u'--verbose', u'https://openload.co/embed/kUEfGclsU9o/']\n[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8\n[debug] youtube-dl version 2016.08.22\n[debug] Python version 2.6.6 - Linux-2.6.32-642.1.1.el6.x86_64-x86_64-with-centos-6.8-Final\n[debug] exe versions: ffmpeg 0.6.5, ffprobe 0.6.5\n[debug] Proxy map: {}\nERROR: Unable to extract link image; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\nTraceback (most recent call last):\n File \"/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 691, in extract_info\n ie_result = ie.extract(url)\n File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py\", line 347, in extract\n return self._real_extract(url)\n File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/openload.py\", line 62, in _real_extract\n r']+id=\"linkimg\"[^>]+src=\"([^\"]+)\"', webpage, 'link image')\n File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py\", line 650, in _search_regex\n raise RegexNotFoundError('Unable to extract %s' % _name)\nRegexNotFoundError: Unable to extract link image; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n\n"},"hints_text":{"kind":"string","value":"they've changed the video link obfuscation to a very simple method, lol\n\nopenload video link extraction script\nhttp://pastebin.com/PJ4SFqBM\n\nA nice hit! @yokrysty Did you write this script? If so could you declare this script as Public Domain or UNLICENSE so that it can be used in youtube-dl?\n\nyes i wrote it now in 5 min :), yes you can use it\n\nbefore decrypting the data make sure you replace all the html entities\ni updated the script with html replacing\n\nMany thanks @yokrysty Would you like to be listed on [AUTHORS](https://github.com/rg3/youtube-dl/blob/master/AUTHORS) for the openload algorithm?\n\ni don't mind :)\n\nOK Anyway thanks for the code :)\n\nThank you, too.\nCould anyone explain me, how i change the new code to my exist youtube-dl setups on my servers. The release 2016.08.22 didn't have the updated code.\n\nBefore a new version is released, you can download https://github.com/rg3/youtube-dl/archive/master.zip and unzip it.\n\nAmazing! Thank you very much ;)\n\nwe're getting pigeons again\n\nConfirmed.\n\n@yan12125 the change is not major: at the last char code in the array add 2 then convert it to char\nhttp://pastebin.com/xXZv59Jc\n\nMany thanks again! Updated.\n\nThey updated their site again. Add 1 instead of 2. Maybe this gets changed throughout the day?\n\nOr, they are watching this repo today. It's working two hours ago.\n\nthen do it like this\noldown.py http://pastebin.com/zW4sGyZd\naa_decode.py http://pastebin.com/jFtB8dhi\n\n:)\n\nJust tried it. The latest commit is still working. Doesn't it work for you? @yokrysty \n\nThis is not working because the number added to last char code is variable.\nAt now it is 1 not 2.\n\nI've changed 2 to 1 in 98908bc, and it's still working. Feel free to leave a comment if its algorithm is changed again.\n\n@yan12125 use my method from above where I read the number that needs to be added from the javascript\n\nI see. Will integrate it the next time `var_val` is changed.\n\nseems that they're now migrating to the canvas method, but on a different host.\n\nIts a 3 now.\n\nyes, its a 3!\n\nseems like @yokrysty's method might be a better plan since it reads the var_val, however using it's own list of emoji's to decrypt might be less robust since a small edit to the list would break the script.\n\ncheck out this method http://pastebin.com/QZRcczrN xd\n\ndependencies:\npip install pyside\npip install ghost.py\n\n@yokrysty I think it's the best approach since Openload updates their obfuscate algorithm frequently.\n\n@NitroXenon maybe if we could do this without adding two dependencies to youtube-dl.\n\n@bigmittens Alright. Take a look at this. This is working currently\n\nhttps://github.com/tknorris/script.module.urlresolver/blob/master/lib/urlresolver/plugins/ol_gmu.py\n\nBut it uses GPLv3\n\n@NitroXenon its basically my method that i posted 9 days ago, scroll up\n\n@gdkchan please help us 😩\n\n@yokrysty http://pastebin.com/jFtB8dhi and http://pastebin.com/zW4sGyZd now gives penguins.\n\n@bigmittens Help with what? Well they are not using AAEncode on the obfuscation of the main HiddenURL decoding JavaScript function, that's why the script yokristy made are all broken (including the last one that tries to decode the AAEncode, but not the one that uses an entire browser to get the link lol). Other than this the code is the same, and they are still adding 3 to the last character.\n\nThey seems to be using a moving target approach now, but the method was pretty much the same for one week now, so I think it's feasible to just keep updating the extractor when they update it. The only other solution that would require less frequen fixes would be having a entire javascript engine running the link decoding functions.\n\nnow they use jjencode (the js above the AAEncoded js)\n[here](https://hackvertor.co.uk/hvurl/49#PEBkX29jdGFsXzE+PEBkX2pqZW5jb2RlXzA+aj1+W107aj17X19fOisraiwkJCQkOighW10rIiIpW2pdLF9fJDorK2osJF8kXzooIVtdKyIiKVtqXSxfJF86KytqLCRfJCQ6KHt9KyIiKVtqXSwkJF8kOihqW2pdKyIiKVtqXSxfJCQ6KytqLCQkJF86KCEiIisiIilbal0sJF9fOisraiwkXyQ6KytqLCQkX186KHt9KyIiKVtqXSwkJF86KytqLCQkJDorK2osJF9fXzorK2osJF9fJDorK2p9O2ouJF89KGouJF89aisiIilbai4kXyRdKyhqLl8kPWouJF9bai5fXyRdKSsoai4kJD0oai4kKyIiKVtqLl9fJF0pKygoIWopKyIiKVtqLl8kJF0rKGouX189ai4kX1tqLiQkX10pKyhqLiQ9KCEiIisiIilbai5fXyRdKSsoai5fPSghIiIrIiIpW2ouXyRfXSkrai4kX1tqLiRfJF0rai5fXytqLl8kK2ouJDtqLiQkPWouJCsoISIiKyIiKVtqLl8kJF0rai5fXytqLl8rai4kK2ouJCQ7ai4kPShqLl9fXylbai4kX11bai4kX107ai4kKGouJChqLiQkKyJcIiIrIiQoIitqLiQkXyQrai5fJCtqLiQkX18rai5fKyJcXCIrai5fXyQrai4kXyQrai4kXyQrai4kJCRfKyJcXCIrai5fXyQrai4kXyQrai4kJF8rai5fXysiKS5cXCIrai5fXyQrai4kJF8rai5fJF8rai4kJCRfK2ouJF8kXytqLiQkXyQrIlxcIitqLl9fJCtqLiQkJCtqLl9fJCsiKCIrai4kJCQkK2ouXysiXFwiK2ouX18kK2ouJF8kK2ouJCRfK2ouJCRfXytqLl9fKyJcXCIrai5fXyQrai4kXyQrai5fXyQrai5fJCsiXFwiK2ouX18kK2ouJF8kK2ouJCRfKyIoKVxcIitqLiRfXytqLl9fXysie1xcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIlxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai4kJCQrai5fX18rIlxcIitqLiRfXytqLl9fXysiPVxcIitqLiRfXytqLl9fXysiJChcXFwiI1xcIitqLl9fJCtqLiRfJCtqLl9fXysiXFwiK2ouX18kK2ouJF8kK2ouX18kK2ouJCRfJCtqLiQkXyQrai4kJCRfKyJcXCIrai5fXyQrai4kXyQrai4kJF8rai5fKyJcXCIrai5fXyQrai4kJF8rai5fJF8rKCFbXSsiIilbai5fJF9dKyJcXFwiKS4iK2ouX18rai4kJCRfKyJcXCIrai5fXyQrai4kJCQrai5fX18rai5fXysiKCk7XFwiK2ouX18kK2ouJF8kKyJcXCIrai5fXyQrai5fJF8rIlxcIitqLl9fJCtqLl9fJCsiXFwiK2ouX18kK2ouJCRfK2ouJCRfK2ouJF8kXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai4kX18rai5fX18rIlxcIitqLl9fJCtqLiQkXytqLl8kJCsiPVtdOyIrai4kJCQkK2ouXyQrIlxcIitqLl9fJCtqLiQkXytqLl8kXysiKFxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai4kXyQrai5fXyQrIj0iK2ouX19fKyI7XFwiK2ouX18kK2ouJF8kK2ouX18kKyI8XFwiK2ouX18kK2ouJCQkK2ouX19fKyIuIisoIVtdKyIiKVtqLl8kX10rai4kJCRfKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCtqLl9fKyJcXCIrai5fXyQrai4kXyQrai5fX18rIjtcXCIrai5fXyQrai4kXyQrai5fXyQrIisrKXtcXCIrai5fXyQrai4kJF8rai4kJF8rai4kXyRfKyJcXCIrai5fXyQrai4kJF8rai5fJF8rIlxcIitqLiRfXytqLl9fXysiXFwiK2ouX18kK2ouJF8kK2ouXyRfKyI9XFwiK2ouX18kK2ouJCQkK2ouX19fKyIuIitqLiQkX18rIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiXFwiK2ouX18kK2ouX19fK2ouX18kK2ouX18rIihcXCIrai5fXyQrai4kXyQrai5fXyQrIik7XFwiK2ouX18kK2ouJF8kK2ouX18kK2ouJCQkJCsiKChcXCIrai5fXyQrai4kXyQrai5fJF8rIj49IitqLl8kJCtqLl8kJCsiKSYmKFxcIitqLl9fJCtqLiRfJCtqLl8kXysiPD0iK2ouX18kK2ouXyRfK2ouJCRfKyIpKXtcXCIrai5fXyQrai4kJF8rai5fJCQrIltcXCIrai5fXyQrai4kXyQrai5fXyQrIl09XFwiK2ouX18kK2ouXyRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouJF8kK2ouX18kKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCsiLiIrai4kJCQkKyJcXCIrai5fXyQrai4kJF8rai5fJF8rai5fJCsiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai5fX18rai5fJCQrIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiKCIrai5fJCQrai5fJCQrIisoKFxcIitqLl9fJCtqLiRfJCtqLl8kXysiKyIrai5fXyQrai4kX18rIiklIitqLiRfXyQrai4kX18rIikpO30iK2ouJCQkXysoIVtdKyIiKVtqLl8kX10rIlxcIitqLl9fJCtqLiQkXytqLl8kJCtqLiQkJF8rIntcXCIrai5fXyQrai4kJF8rai5fJCQrIltcXCIrai5fXyQrai4kXyQrai5fXyQrIl09XFwiK2ouX18kK2ouXyRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouJF8kK2ouX18kKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCsiLiIrai4kJCQkKyJcXCIrai5fXyQrai4kJF8rai5fJF8rai5fJCsiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai5fX18rai5fJCQrIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiKFxcIitqLl9fJCtqLiRfJCtqLl8kXysiKTt9fVxcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIlxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fK2ouX18rIlxcIitqLl9fJCtqLiRfJCtqLiRfJCsiXFwiK2ouX18kK2ouJCRfK2ouX19fKyI9XFwiK2ouX18kK2ouJCRfK2ouXyQkKyIuXFwiK2ouX18kK2ouJF8kK2ouXyRfK2ouXyQrIlxcIitqLl9fJCtqLiRfJCtqLl9fJCsiXFwiK2ouX18kK2ouJF8kK2ouJCRfKyIoXFxcIlxcXCIpO1xcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIlxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai4kJF8rai5fJCQrai5fXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai4kX18rai5fX18rIj1cXCIrai4kX18rai5fX18rai5fXysiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai4kJF8rai5fX18rIi5cXCIrai5fXyQrai4kJF8rai5fJCQrai5fK2ouJF8kJCsiXFwiK2ouX18kK2ouJCRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouJF8kK2ouX18kKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCsiKCIrai5fX18rIixcXCIrai4kX18rai5fX18rai5fXysiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai4kJF8rai5fX18rIi4iKyghW10rIiIpW2ouXyRfXStqLiQkJF8rIlxcIitqLl9fJCtqLiRfJCtqLiQkXysiXFwiK2ouX18kK2ouJF9fK2ouJCQkK2ouX18rIlxcIitqLl9fJCtqLiRfJCtqLl9fXysiXFwiK2ouJF9fK2ouX19fKyItXFwiK2ouJF9fK2ouX19fK2ouX18kKyIpXFwiK2ouJF9fK2ouX19fKyIrXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai5fJF8rai5fJCQrai5fXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai5fXyQrai4kXyQrai5fXyQrIlxcIitqLl9fJCtqLiRfJCtqLiQkXysiXFwiK2ouX18kK2ouJF9fK2ouJCQkKyIuIitqLiQkJCQrIlxcIitqLl9fJCtqLiQkXytqLl8kXytqLl8kKyJcXCIrai5fXyQrai4kXyQrai4kXyQrIlxcIitqLl9fJCtqLl9fXytqLl8kJCsiXFwiK2ouX18kK2ouJF8kK2ouX19fK2ouJF8kXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai5fXyQrai5fX18rai5fJCQrai5fJCtqLiQkXyQrai4kJCRfKyIoIitqLl9fKyJcXCIrai5fXyQrai4kXyQrai4kXyQrIlxcIitqLl9fJCtqLiQkXytqLl9fXysiLlxcIitqLl9fJCtqLiQkXytqLl8kJCsoIVtdKyIiKVtqLl8kX10rIlxcIitqLl9fJCtqLiRfJCtqLl9fJCtqLiQkX18rai4kJCRfKyIoLSIrai5fXyQrIikuIitqLiQkX18rIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiXFwiK2ouX18kK2ouX19fK2ouX18kK2ouX18rIigiK2ouX19fKyIpXFwiK2ouJF9fK2ouX19fKyIrXFwiK2ouJF9fK2ouX19fK2ouXyQkKyIpO1xcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIiQoXFxcIiNcXCIrai5fXyQrai4kJF8rai5fJCQrai5fXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfK2ouJCQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiRfJCtqLiRfJCtqLl8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysoIVtdKyIiKVtqLl8kX10rIlxcXCIpLiIrai5fXytqLiQkJF8rIlxcIitqLl9fJCtqLiQkJCtqLl9fXytqLl9fKyIoXFwiK2ouX18kK2ouJCRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiKTtcXCIrai5fXyQrai4kXyQrIlxcIitqLl9fJCtqLl8kXysifSk7XFwiK2ouX18kK2ouJF8kKyJcXCIrai5fXyQrai5fJF8rIlwiIikoKSkoKTs8QC9kX2pqZW5jb2RlXzA+PEAvZF9vY3RhbF8xPg==) is the script decoded\n\n@gdkchan is right - a real Javascript engine might be the final solution...\nI see @yokrysty proposed using a browser engine to get the video URL. It's not a good approach. In browser engines, anything can happen. User data may be uploaded to hacker's servers. So, real browser engines should not enter youtube-dl. On the other hand, modern Javascript engines have sandboxes, where only ECMAScript standard objects are accessible. I guess it's unlikely to have security issues.\n\n@yan12125 I didn't proposed cause those are licensed and writing one from scratch, not worth the time, I just did a demo, btw I am pretty sure ghost.py is sandboxed\n\nEdit:\n@yan12125 can you use [this ](https://github.com/crackinglandia/python-jjdecoder) decoder for jjEncode?\n\nI see - I was concerning things like file uploading. Seems both ghost.py and PhantomJS handles it well. \n\nLicense is not a problem if youtube-dl does not bundle ghost.py files. A previous case is PyCrypto (#8201).\n\njjencode/aaencode isnt an issue, but does someone actually know where the #streamurl lies?\n\nIs it on the:\n\n```\n',\n+ webpage, 'encrypted code')\n+\n+ js_code = self.openload_decode(enc_code)\n+ jsi = JSInterpreter(js_code)\n+\n+ m_offset_fun = self._search_regex(r'slice\\(0\\s*-\\s*(%s)\\(\\)' % _NAME_RE, js_code, 'javascript offset function')\n+ m_diff_fun = self._search_regex(r'charCodeAt\\(0\\)\\s*\\+\\s*(%s)\\(\\)' % _NAME_RE, js_code, 'javascript diff function')\n+\n+ offset = jsi.call_function(m_offset_fun)\n+ diff = jsi.call_function(m_diff_fun)\n+\n video_url_chars = []\n \n for idx, c in enumerate(enc_data):\n j = compat_ord(c)\n- if j == magic:\n- j -= 1\n- elif j == magic - 1:\n- j += 1\n if j >= 33 and j <= 126:\n j = ((j + 14) % 94) + 33\n- if idx == len(enc_data) - 1:\n- j += 3\n+ if idx == len(enc_data) - offset:\n+ j += diff\n video_url_chars += compat_chr(j)\n \n video_url = 'https://openload.co/stream/%s?mime=true' % ''.join(video_url_chars)\ndiff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py\n--- a/youtube_dl/jsinterp.py\n+++ b/youtube_dl/jsinterp.py\n@@ -198,12 +198,12 @@ def interpret_expression(self, expr, local_vars, allow_recursion):\n return opfunc(x, y)\n \n m = re.match(\n- r'^(?P%s)\\((?P[a-zA-Z0-9_$,]+)\\)$' % _NAME_RE, expr)\n+ r'^(?P%s)\\((?P[a-zA-Z0-9_$,]*)\\)$' % _NAME_RE, expr)\n if m:\n fname = m.group('func')\n argvals = tuple([\n int(v) if v.isdigit() else local_vars[v]\n- for v in m.group('args').split(',')])\n+ for v in m.group('args').split(',')]) if len(m.group('args')) > 0 else tuple()\n if fname not in self._functions:\n self._functions[fname] = self.extract_function(fname)\n return self._functions[fname](argvals)\n"},"test_patch":{"kind":"string","value":""},"problem_statement":{"kind":"string","value":"openload.co extractor not working\n youtube-dl --get-url --verbose https://openload.co/embed/kUEfGclsU9o/\n[debug] System config: []\n[debug] User config: []\n[debug] Command-line args: [u'--get-url', u'--verbose', u'https://openload.co/embed/kUEfGclsU9o/']\n[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8\n[debug] youtube-dl version 2016.08.22\n[debug] Python version 2.6.6 - Linux-2.6.32-642.1.1.el6.x86_64-x86_64-with-centos-6.8-Final\n[debug] exe versions: ffmpeg 0.6.5, ffprobe 0.6.5\n[debug] Proxy map: {}\nERROR: Unable to extract link image; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\nTraceback (most recent call last):\n File \"/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py\", line 691, in extract_info\n ie_result = ie.extract(url)\n File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py\", line 347, in extract\n return self._real_extract(url)\n File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/openload.py\", line 62, in _real_extract\n r']+id=\"linkimg\"[^>]+src=\"([^\"]+)\"', webpage, 'link image')\n File \"/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py\", line 650, in _search_regex\n raise RegexNotFoundError('Unable to extract %s' % _name)\nRegexNotFoundError: Unable to extract link image; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n\n"},"hints_text":{"kind":"string","value":"they've changed the video link obfuscation to a very simple method, lol\n\nopenload video link extraction script\nhttp://pastebin.com/PJ4SFqBM\n\nA nice hit! @yokrysty Did you write this script? If so could you declare this script as Public Domain or UNLICENSE so that it can be used in youtube-dl?\n\nyes i wrote it now in 5 min :), yes you can use it\n\nbefore decrypting the data make sure you replace all the html entities\ni updated the script with html replacing\n\nMany thanks @yokrysty Would you like to be listed on [AUTHORS](https://github.com/rg3/youtube-dl/blob/master/AUTHORS) for the openload algorithm?\n\ni don't mind :)\n\nOK Anyway thanks for the code :)\n\nThank you, too.\nCould anyone explain me, how i change the new code to my exist youtube-dl setups on my servers. The release 2016.08.22 didn't have the updated code.\n\nBefore a new version is released, you can download https://github.com/rg3/youtube-dl/archive/master.zip and unzip it.\n\nAmazing! Thank you very much ;)\n\nwe're getting pigeons again\n\nConfirmed.\n\n@yan12125 the change is not major: at the last char code in the array add 2 then convert it to char\nhttp://pastebin.com/xXZv59Jc\n\nMany thanks again! Updated.\n\nThey updated their site again. Add 1 instead of 2. Maybe this gets changed throughout the day?\n\nOr, they are watching this repo today. It's working two hours ago.\n\nthen do it like this\noldown.py http://pastebin.com/zW4sGyZd\naa_decode.py http://pastebin.com/jFtB8dhi\n\n:)\n\nJust tried it. The latest commit is still working. Doesn't it work for you? @yokrysty \n\nThis is not working because the number added to last char code is variable.\nAt now it is 1 not 2.\n\nI've changed 2 to 1 in 98908bc, and it's still working. Feel free to leave a comment if its algorithm is changed again.\n\n@yan12125 use my method from above where I read the number that needs to be added from the javascript\n\nI see. Will integrate it the next time `var_val` is changed.\n\nseems that they're now migrating to the canvas method, but on a different host.\n\nIts a 3 now.\n\nyes, its a 3!\n\nseems like @yokrysty's method might be a better plan since it reads the var_val, however using it's own list of emoji's to decrypt might be less robust since a small edit to the list would break the script.\n\ncheck out this method http://pastebin.com/QZRcczrN xd\n\ndependencies:\npip install pyside\npip install ghost.py\n\n@yokrysty I think it's the best approach since Openload updates their obfuscate algorithm frequently.\n\n@NitroXenon maybe if we could do this without adding two dependencies to youtube-dl.\n\n@bigmittens Alright. Take a look at this. This is working currently\n\nhttps://github.com/tknorris/script.module.urlresolver/blob/master/lib/urlresolver/plugins/ol_gmu.py\n\nBut it uses GPLv3\n\n@NitroXenon its basically my method that i posted 9 days ago, scroll up\n\n@gdkchan please help us 😩\n\n@yokrysty http://pastebin.com/jFtB8dhi and http://pastebin.com/zW4sGyZd now gives penguins.\n\n@bigmittens Help with what? Well they are not using AAEncode on the obfuscation of the main HiddenURL decoding JavaScript function, that's why the script yokristy made are all broken (including the last one that tries to decode the AAEncode, but not the one that uses an entire browser to get the link lol). Other than this the code is the same, and they are still adding 3 to the last character.\n\nThey seems to be using a moving target approach now, but the method was pretty much the same for one week now, so I think it's feasible to just keep updating the extractor when they update it. The only other solution that would require less frequen fixes would be having a entire javascript engine running the link decoding functions.\n\nnow they use jjencode (the js above the AAEncoded js)\n[here](https://hackvertor.co.uk/hvurl/49#PEBkX29jdGFsXzE+PEBkX2pqZW5jb2RlXzA+aj1+W107aj17X19fOisraiwkJCQkOighW10rIiIpW2pdLF9fJDorK2osJF8kXzooIVtdKyIiKVtqXSxfJF86KytqLCRfJCQ6KHt9KyIiKVtqXSwkJF8kOihqW2pdKyIiKVtqXSxfJCQ6KytqLCQkJF86KCEiIisiIilbal0sJF9fOisraiwkXyQ6KytqLCQkX186KHt9KyIiKVtqXSwkJF86KytqLCQkJDorK2osJF9fXzorK2osJF9fJDorK2p9O2ouJF89KGouJF89aisiIilbai4kXyRdKyhqLl8kPWouJF9bai5fXyRdKSsoai4kJD0oai4kKyIiKVtqLl9fJF0pKygoIWopKyIiKVtqLl8kJF0rKGouX189ai4kX1tqLiQkX10pKyhqLiQ9KCEiIisiIilbai5fXyRdKSsoai5fPSghIiIrIiIpW2ouXyRfXSkrai4kX1tqLiRfJF0rai5fXytqLl8kK2ouJDtqLiQkPWouJCsoISIiKyIiKVtqLl8kJF0rai5fXytqLl8rai4kK2ouJCQ7ai4kPShqLl9fXylbai4kX11bai4kX107ai4kKGouJChqLiQkKyJcIiIrIiQoIitqLiQkXyQrai5fJCtqLiQkX18rai5fKyJcXCIrai5fXyQrai4kXyQrai4kXyQrai4kJCRfKyJcXCIrai5fXyQrai4kXyQrai4kJF8rai5fXysiKS5cXCIrai5fXyQrai4kJF8rai5fJF8rai4kJCRfK2ouJF8kXytqLiQkXyQrIlxcIitqLl9fJCtqLiQkJCtqLl9fJCsiKCIrai4kJCQkK2ouXysiXFwiK2ouX18kK2ouJF8kK2ouJCRfK2ouJCRfXytqLl9fKyJcXCIrai5fXyQrai4kXyQrai5fXyQrai5fJCsiXFwiK2ouX18kK2ouJF8kK2ouJCRfKyIoKVxcIitqLiRfXytqLl9fXysie1xcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIlxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai4kJCQrai5fX18rIlxcIitqLiRfXytqLl9fXysiPVxcIitqLiRfXytqLl9fXysiJChcXFwiI1xcIitqLl9fJCtqLiRfJCtqLl9fXysiXFwiK2ouX18kK2ouJF8kK2ouX18kK2ouJCRfJCtqLiQkXyQrai4kJCRfKyJcXCIrai5fXyQrai4kXyQrai4kJF8rai5fKyJcXCIrai5fXyQrai4kJF8rai5fJF8rKCFbXSsiIilbai5fJF9dKyJcXFwiKS4iK2ouX18rai4kJCRfKyJcXCIrai5fXyQrai4kJCQrai5fX18rai5fXysiKCk7XFwiK2ouX18kK2ouJF8kKyJcXCIrai5fXyQrai5fJF8rIlxcIitqLl9fJCtqLl9fJCsiXFwiK2ouX18kK2ouJCRfK2ouJCRfK2ouJF8kXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai4kX18rai5fX18rIlxcIitqLl9fJCtqLiQkXytqLl8kJCsiPVtdOyIrai4kJCQkK2ouXyQrIlxcIitqLl9fJCtqLiQkXytqLl8kXysiKFxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai4kXyQrai5fXyQrIj0iK2ouX19fKyI7XFwiK2ouX18kK2ouJF8kK2ouX18kKyI8XFwiK2ouX18kK2ouJCQkK2ouX19fKyIuIisoIVtdKyIiKVtqLl8kX10rai4kJCRfKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCtqLl9fKyJcXCIrai5fXyQrai4kXyQrai5fX18rIjtcXCIrai5fXyQrai4kXyQrai5fXyQrIisrKXtcXCIrai5fXyQrai4kJF8rai4kJF8rai4kXyRfKyJcXCIrai5fXyQrai4kJF8rai5fJF8rIlxcIitqLiRfXytqLl9fXysiXFwiK2ouX18kK2ouJF8kK2ouXyRfKyI9XFwiK2ouX18kK2ouJCQkK2ouX19fKyIuIitqLiQkX18rIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiXFwiK2ouX18kK2ouX19fK2ouX18kK2ouX18rIihcXCIrai5fXyQrai4kXyQrai5fXyQrIik7XFwiK2ouX18kK2ouJF8kK2ouX18kK2ouJCQkJCsiKChcXCIrai5fXyQrai4kXyQrai5fJF8rIj49IitqLl8kJCtqLl8kJCsiKSYmKFxcIitqLl9fJCtqLiRfJCtqLl8kXysiPD0iK2ouX18kK2ouXyRfK2ouJCRfKyIpKXtcXCIrai5fXyQrai4kJF8rai5fJCQrIltcXCIrai5fXyQrai4kXyQrai5fXyQrIl09XFwiK2ouX18kK2ouXyRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouJF8kK2ouX18kKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCsiLiIrai4kJCQkKyJcXCIrai5fXyQrai4kJF8rai5fJF8rai5fJCsiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai5fX18rai5fJCQrIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiKCIrai5fJCQrai5fJCQrIisoKFxcIitqLl9fJCtqLiRfJCtqLl8kXysiKyIrai5fXyQrai4kX18rIiklIitqLiRfXyQrai4kX18rIikpO30iK2ouJCQkXysoIVtdKyIiKVtqLl8kX10rIlxcIitqLl9fJCtqLiQkXytqLl8kJCtqLiQkJF8rIntcXCIrai5fXyQrai4kJF8rai5fJCQrIltcXCIrai5fXyQrai4kXyQrai5fXyQrIl09XFwiK2ouX18kK2ouXyRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouJF8kK2ouX18kKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCsiLiIrai4kJCQkKyJcXCIrai5fXyQrai4kJF8rai5fJF8rai5fJCsiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai5fX18rai5fJCQrIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiKFxcIitqLl9fJCtqLiRfJCtqLl8kXysiKTt9fVxcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIlxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fK2ouX18rIlxcIitqLl9fJCtqLiRfJCtqLiRfJCsiXFwiK2ouX18kK2ouJCRfK2ouX19fKyI9XFwiK2ouX18kK2ouJCRfK2ouXyQkKyIuXFwiK2ouX18kK2ouJF8kK2ouXyRfK2ouXyQrIlxcIitqLl9fJCtqLiRfJCtqLl9fJCsiXFwiK2ouX18kK2ouJF8kK2ouJCRfKyIoXFxcIlxcXCIpO1xcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIlxcIitqLl9fJCtqLiQkXytqLiQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai4kJF8rai5fJCQrai5fXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai4kX18rai5fX18rIj1cXCIrai4kX18rai5fX18rai5fXysiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai4kJF8rai5fX18rIi5cXCIrai5fXyQrai4kJF8rai5fJCQrai5fK2ouJF8kJCsiXFwiK2ouX18kK2ouJCRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouJF8kK2ouX18kKyJcXCIrai5fXyQrai4kXyQrai4kJF8rIlxcIitqLl9fJCtqLiRfXytqLiQkJCsiKCIrai5fX18rIixcXCIrai4kX18rai5fX18rai5fXysiXFwiK2ouX18kK2ouJF8kK2ouJF8kKyJcXCIrai5fXyQrai4kJF8rai5fX18rIi4iKyghW10rIiIpW2ouXyRfXStqLiQkJF8rIlxcIitqLl9fJCtqLiRfJCtqLiQkXysiXFwiK2ouX18kK2ouJF9fK2ouJCQkK2ouX18rIlxcIitqLl9fJCtqLiRfJCtqLl9fXysiXFwiK2ouJF9fK2ouX19fKyItXFwiK2ouJF9fK2ouX19fK2ouX18kKyIpXFwiK2ouJF9fK2ouX19fKyIrXFwiK2ouJF9fK2ouX19fKyJcXCIrai5fXyQrai5fJF8rai5fJCQrai5fXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai5fXyQrai4kXyQrai5fXyQrIlxcIitqLl9fJCtqLiRfJCtqLiQkXysiXFwiK2ouX18kK2ouJF9fK2ouJCQkKyIuIitqLiQkJCQrIlxcIitqLl9fJCtqLiQkXytqLl8kXytqLl8kKyJcXCIrai5fXyQrai4kXyQrai4kXyQrIlxcIitqLl9fJCtqLl9fXytqLl8kJCsiXFwiK2ouX18kK2ouJF8kK2ouX19fK2ouJF8kXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfKyJcXCIrai5fXyQrai5fX18rai5fJCQrai5fJCtqLiQkXyQrai4kJCRfKyIoIitqLl9fKyJcXCIrai5fXyQrai4kXyQrai4kXyQrIlxcIitqLl9fJCtqLiQkXytqLl9fXysiLlxcIitqLl9fJCtqLiQkXytqLl8kJCsoIVtdKyIiKVtqLl8kX10rIlxcIitqLl9fJCtqLiRfJCtqLl9fJCtqLiQkX18rai4kJCRfKyIoLSIrai5fXyQrIikuIitqLiQkX18rIlxcIitqLl9fJCtqLiRfJCtqLl9fXytqLiRfJF8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiXFwiK2ouX18kK2ouX19fK2ouXyQkK2ouXyQrai4kJF8kK2ouJCQkXysiXFwiK2ouX18kK2ouX19fK2ouX18kK2ouX18rIigiK2ouX19fKyIpXFwiK2ouJF9fK2ouX19fKyIrXFwiK2ouJF9fK2ouX19fK2ouXyQkKyIpO1xcIitqLl9fJCtqLiRfJCsiXFwiK2ouX18kK2ouXyRfKyJcXCIrai5fXyQrai5fXyQrIiQoXFxcIiNcXCIrai5fXyQrai4kJF8rai5fJCQrai5fXysiXFwiK2ouX18kK2ouJCRfK2ouXyRfK2ouJCQkXytqLiRfJF8rIlxcIitqLl9fJCtqLiRfJCtqLiRfJCtqLl8rIlxcIitqLl9fJCtqLiQkXytqLl8kXysoIVtdKyIiKVtqLl8kX10rIlxcXCIpLiIrai5fXytqLiQkJF8rIlxcIitqLl9fJCtqLiQkJCtqLl9fXytqLl9fKyIoXFwiK2ouX18kK2ouJCRfK2ouXyQkK2ouX18rIlxcIitqLl9fJCtqLiQkXytqLl8kXysiKTtcXCIrai5fXyQrai4kXyQrIlxcIitqLl9fJCtqLl8kXysifSk7XFwiK2ouX18kK2ouJF8kKyJcXCIrai5fXyQrai5fJF8rIlwiIikoKSkoKTs8QC9kX2pqZW5jb2RlXzA+PEAvZF9vY3RhbF8xPg==) is the script decoded\n\n@gdkchan is right - a real Javascript engine might be the final solution...\nI see @yokrysty proposed using a browser engine to get the video URL. It's not a good approach. In browser engines, anything can happen. User data may be uploaded to hacker's servers. So, real browser engines should not enter youtube-dl. On the other hand, modern Javascript engines have sandboxes, where only ECMAScript standard objects are accessible. I guess it's unlikely to have security issues.\n\n@yan12125 I didn't proposed cause those are licensed and writing one from scratch, not worth the time, I just did a demo, btw I am pretty sure ghost.py is sandboxed\n\nEdit:\n@yan12125 can you use [this ](https://github.com/crackinglandia/python-jjdecoder) decoder for jjEncode?\n\nI see - I was concerning things like file uploading. Seems both ghost.py and PhantomJS handles it well. \n\nLicense is not a problem if youtube-dl does not bundle ghost.py files. A previous case is PyCrypto (#8201).\n\njjencode/aaencode isnt an issue, but does someone actually know where the #streamurl lies?\n\nIs it on the:\n\n```\n