Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamer.py handles IOError exception in non-python3 compatible way #1905

Closed
ASalazarMX opened this issue Apr 19, 2018 · 1 comment
Closed

Comments

@ASalazarMX
Copy link

Under python 3 and the latest repository, browsing to http://127.0.0.1:8000/welcome/favicon.ico causes streamer.py to crash because it treats the IOError exception in a non-python3 compatible way. The IOError exception occurs because favicon.ico is not found at / . No error ticket is generated.

except IOError as e:
    if e[0] == errno.EISDIR:
        raise HTTP(403, error_message, web2py_error='file is a directory')
    elif e[0] == errno.EACCES:
        raise HTTP(403, error_message, web2py_error='inaccessible file')
    else:
        raise HTTP(404, error_message, web2py_error='invalid file')

This works in python 2, but e[0] should be accesed as e.errno under python 3

Partial stack trace:

Traceback (most recent call last):
  File "C:\web2py\gluon\main.py", line 329, in wsgibase
    response.stream(static_file, request=request)
  File "C:\web2py\gluon\globals.py", line 617, in stream
    status=self.status)
  File "C:\web2py\gluon\streamer.py", line 66, in stream_file_or_304_or_206
    if e[0] == errno.EISDIR:
TypeError: 'FileNotFoundError' object is not subscriptable
@ASalazarMX
Copy link
Author

ASalazarMX commented Apr 24, 2018

The only other file who uses exceptions in the same incompatible way is gluon/contrib/gateways/fcgi.py .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant