linux-bench
linux-bench copied to clipboard
Django Error
I cloned the repository today and ran linux-bench-minimal.sh. Everything ran as expected until the very end when a Django error was presented.
`
NameError at /upload_file/
global name 'codecs' is not defined
Server time: | Wed, 4 Dec 2019 15:59:02 +0000 |
---|
Traceback Switch to copy-and-paste view
<li class="frame django">
<code>/home/linux-bench/django/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py</code> in <code>get_response</code>
<div class="context" id="c140613786664832">
<ol start="142" class="pre-context" id="pre140613786664832">
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> break</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre></pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> if response is None:</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> wrapped_callback = self.make_view_atomic(callback)</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> try:</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> response = wrapped_callback(request, *callback_args, **callback_kwargs)</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> except Exception as e:</pre></li>
</ol>
<ol start="149" class="context-line">
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre>
response = self.process_exception_by_middleware(e, request)</pre> <span>...</span></li></ol>
<ol start='150' class="post-context" id="post140613786664832">
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre></pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> # Complain if the view returned None (a common error).</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> if response is None:</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> if isinstance(callback, types.FunctionType): # FBV</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> view_name = callback.__name__</pre></li>
<li onclick="toggle('pre140613786664832', 'post140613786664832')"><pre> else: # CBV</pre></li>
</ol>
</div>
<div class="commands">
<a href="#" onclick="return varToggle(this, '140613786664832')"><span>▶</span> Local vars</a>
</div>
<table class="vars" id="v140613786664832">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>e</td>
<td class="code"><pre>NameError("global name 'codecs' is not defined",)</pre></td>
</tr>
<tr>
<td>callback_args</td>
<td class="code"><pre>()</pre></td>
</tr>
<tr>
<td>resolver_match</td>
<td class="code"><pre>ResolverMatch(func=linuxbench.views.upload_file, args=(), kwargs={}, url_name=upload_file, app_names=[], namespaces=['linuxbench'])</pre></td>
</tr>
<tr>
<td>response_is_rendered</td>
<td class="code"><pre>False</pre></td>
</tr>
<tr>
<td>middleware_method</td>
<td class="code"><pre><bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x7fe332f4a550>></pre></td>
</tr>
<tr>
<td>self</td>
<td class="code"><pre><django.core.handlers.wsgi.WSGIHandler object at 0x7fe334357c10></pre></td>
</tr>
<tr>
<td>request</td>
<td class="code"><pre><WSGIRequest: POST '/upload_file/'></pre></td>
</tr>
100 147k 0 13886 100 133k 28968 279k --:--:-- --:--:-- --:--:-- 279k
<function upload_file at 0x7fe332e8f7d0>
<tr>
<td>wrapped_callback</td>
<td class="code"><pre><function upload_file at 0x7fe332e8f7d0></pre></td>
</tr>
<tr>
<td>resolver</td>
<td class="code"><pre><RegexURLResolver 'mysite.urls' (None:None) ^/></pre></td>
</tr>
<tr>
<td>callback_kwargs</td>
<td class="code"><pre>{}</pre></td>
</tr>
<tr>
<td>response</td>
<td class="code"><pre>None</pre></td>
</tr>
<tr>
<td>urlconf</td>
<td class="code"><pre>'mysite.urls'</pre></td>
</tr>
</tbody>
</table>
</li>
<li class="frame django">
<code>/home/linux-bench/django/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py</code> in <code>get_response</code>
<div class="context" id="c140613785560128">
<ol start="140" class="pre-context" id="pre140613785560128">
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> response = middleware_method(request, callback, callback_args, callback_kwargs)</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> if response:</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> break</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre></pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> if response is None:</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> wrapped_callback = self.make_view_atomic(callback)</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> try:</pre></li>
</ol>
<ol start="147" class="context-line">
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre>
response = wrapped_callback(request, *callback_args, **callback_kwargs)</pre> <span>...</span></li></ol>
<ol start='148' class="post-context" id="post140613785560128">
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> except Exception as e:</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> response = self.process_exception_by_middleware(e, request)</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre></pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> # Complain if the view returned None (a common error).</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> if response is None:</pre></li>
<li onclick="toggle('pre140613785560128', 'post140613785560128')"><pre> if isinstance(callback, types.FunctionType): # FBV</pre></li>
</ol>
</div>
<div class="commands">
<a href="#" onclick="return varToggle(this, '140613785560128')"><span>▶</span> Local vars</a>
</div>
<table class="vars" id="v140613785560128">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>e</td>
<td class="code"><pre>NameError("global name 'codecs' is not defined",)</pre></td>
</tr>
<tr>
<td>callback_args</td>
<td class="code"><pre>()</pre></td>
</tr>
<tr>
<td>resolver_match</td>
<td class="code"><pre>ResolverMatch(func=linuxbench.views.upload_file, args=(), kwargs={}, url_name=upload_file, app_names=[], namespaces=['linuxbench'])</pre></td>
</tr>
<tr>
<td>response_is_rendered</td>
<td class="code"><pre>False</pre></td>
</tr>
<tr>
<td>middleware_method</td>
<td class="code"><pre><bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x7fe332f4a550>></pre></td>
</tr>
<tr>
<td>self</td>
<td class="code"><pre><django.core.handlers.wsgi.WSGIHandler object at 0x7fe334357c10></pre></td>
</tr>
<tr>
<td>request</td>
<td class="code"><pre><WSGIRequest: POST '/upload_file/'></pre></td>
</tr>
<tr>
<td>callback</td>
<td class="code"><pre><function upload_file at 0x7fe332e8f7d0></pre></td>
</tr>
<tr>
<td>wrapped_callback</td>
<td class="code"><pre><function upload_file at 0x7fe332e8f7d0></pre></td>
</tr>
<tr>
<td>resolver</td>
<td class="code"><pre><RegexURLResolver 'mysite.urls' (None:None) ^/></pre></td>
</tr>
<tr>
<td>callback_kwargs</td>
<td class="code"><pre>{}</pre></td>
</tr>
<tr>
<td>response</td>
<td class="code"><pre>None</pre></td>
</tr>
<tr>
<td>urlconf</td>
<td class="code"><pre>'mysite.urls'</pre></td>
</tr>
</tbody>
</table>
</li>
<li class="frame django">
<code>/home/linux-bench/django/venv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py</code> in <code>wrapped_view</code>
<div class="context" id="c140613785440696">
<ol start="51" class="pre-context" id="pre140613785440696">
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> """</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> Marks a view function as being exempt from the CSRF view protection.</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> """</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> # We could just do view_func.csrf_exempt = True, but decorators</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> # are nicer if they don't have side-effects, so we return a new</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> # function.</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> def wrapped_view(*args, **kwargs):</pre></li>
</ol>
<ol start="58" class="context-line">
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre>
return view_func(*args, **kwargs)</pre> <span>...</span></li></ol>
<ol start='59' class="post-context" id="post140613785440696">
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> wrapped_view.csrf_exempt = True</pre></li>
<li onclick="toggle('pre140613785440696', 'post140613785440696')"><pre> return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)</pre></li>
</ol>
</div>
<div class="commands">
<a href="#" onclick="return varToggle(this, '140613785440696')"><span>▶</span> Local vars</a>
</div>
<table class="vars" id="v140613785440696">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>args</td>
<td class="code"><pre>(<WSGIRequest: POST '/upload_file/'>,)</pre></td>
</tr>
<tr>
<td>view_func</td>
<td class="code"><pre><function upload_file at 0x7fe332e8f758></pre></td>
</tr>
<tr>
<td>kwargs</td>
<td class="code"><pre>{}</pre></td>
</tr>
</tbody>
</table>
</li>
<li class="frame user">
<code>./linuxbench/views.py</code> in <code>upload_file</code>
<div class="context" id="c140613785442208">
<ol start="175" class="pre-context" id="pre140613785442208">
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> if request.method == 'POST':</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> form = UploadFileForm(request.POST, request.FILES)</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> if form.is_valid():</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> # lets save this file.</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> filename = str(request.FILES['file']) # received file name</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> print "uploading " + filename</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre></pre></li>
</ol>
<ol start="182" class="context-line">
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre>
utf8_file = codecs.EncodedFile(request.FILES['file'],"utf-8")</pre> <span>...</span></li></ol>
<ol start='183' class="post-context" id="post140613785442208">
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> filename = saveFileToDisk(utf8_file,utf8_file.readlines())</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> context = parse_data(filename,utf8_file.readlines())</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> return HttpResponseRedirect('/')</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> else:</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> form = UploadFileForm()</pre></li>
<li onclick="toggle('pre140613785442208', 'post140613785442208')"><pre> return render_to_response('upload.html', {'form': form}, RequestContext(request))</pre></li>
</ol>
</div>
<div class="commands">
<a href="#" onclick="return varToggle(this, '140613785442208')"><span>▶</span> Local vars</a>
</div>
<table class="vars" id="v140613785442208">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>request</td>
<td class="code"><pre><WSGIRequest: POST '/upload_file/'></pre></td>
</tr>
<tr>
<td>form</td>
<td class="code"><pre><UploadFileForm bound=True, valid=True, fields=(file)></pre></td>
</tr>
<tr>
<td>filename</td>
<td class="code"><pre>'linux-bench12.19_qss-freeswitch_2019_1204_145129.log'</pre></td>
</tr>
</tbody>
</table>
</li>
</ul>
Request information
GET
<p>No GET data</p>
POST
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>press</td>
<td class="code"><pre>u'Upload'</pre></td>
</tr>
</tbody>
</table>
FILES
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>file</td>
<td class="code"><pre><InMemoryUploadedFile: linux-bench12.19_qss-freeswitch_2019_1204_145129.log (application/octet-stream)></pre></td>
</tr>
</tbody>
</table>
COOKIES
<p>No cookie data</p>
META
Variable | Value |
---|
Settings
Using settings module mysite.settings
Setting | Value |
---|
You're seeing this error because you have DEBUG = True
in your
Django settings file. Change that to False
, and Django will
display a standard page generated by the handler for this status code.
ref_link: 39041575474819 `