python - Bottle GET request is broken with certain strings when running with paste server -




i have problem similar one: python bottle: utf8 path string invalid when using app.mount()

when try /languages/inglês receive error below (notice accent "ê"). when passing [az] strings works fine.

critical error while processing request: /languages/inglês

i tried fix mentioned on link above without success.

working example:

from bottle import route, run, debug  @route('/languages/<name>') def hello(name):     return name  if __name__ == '__main__':     debug(false)     #run(reloader=false, port = 8080) # works     run(server='paste', port = 8080)  # fails 

running server='paste' causes crash, using bottle server runs ok. problem seems happen @ bottle._handle() method, unicodeerror thrown (bottle.py line 844):

def _handle(self, environ):         path = environ['bottle.raw_path'] = environ['path_info']         if py3k:             try:                 environ['path_info'] = path.encode('latin1').decode('utf8')             except unicodeerror:                 return httperror(400, 'invalid path string. expected utf-8') 

i'm using python 3.6.2, bottle v0.12.13 , paste 2.0.3 on windows 10 machine. what's going on? problem bottle or paste?

note: i've solved problem refactoring code use integer ids instead of names. still learn more this.

stack trace:

critical error while processing request: /hello/inglês  error:  runtimeerror('request context not initialized.',) traceback:  traceback (most recent call last):   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 1661, in fget     try: return ls.var attributeerror: '_thread._local' object has no attribute 'var'  during handling of above exception, exception occurred:  traceback (most recent call last):   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 954, in wsgi     out = self._cast(self._handle(environ))   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 907, in _cast     out = self.error_handler.get(out.status_code, self.default_error_handler)(out)   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 842, in default_error_handler     return tob(template(error_page_template, e=res))   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 3619, in template     return templates[tplid].render(kwargs)   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 3409, in render     self.execute(stdout, env)   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 3396, in execute     eval(self.co, env)   file "<string>", line 17, in <module>   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 1249, in url     return self.urlparts.geturl()   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 165, in __get__     key, storage = self.key, getattr(obj, self.attr)   file "c:\users\fernando.filho\appdata\local\programs\python\python36\lib\site-packages\bottle.py", line 1663, in fget     raise runtimeerror("request context not initialized.") runtimeerror: request context not initialized. 

answering own question, quoting @grahamdumpleton:

the paste server not tolerant of being sent non ascii characters.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -