From f54b007a5c9ae22b91a329925c242e23921bf974 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 19 Dec 2015 23:49:25 -0500 Subject: Also include ValueError. Fixes failing test on Python 3.5. --- cherrypy/lib/static.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cherrypy/lib/static.py b/cherrypy/lib/static.py index a26dd4ac..6a78fc13 100644 --- a/cherrypy/lib/static.py +++ b/cherrypy/lib/static.py @@ -49,7 +49,10 @@ def serve_file(path, content_type=None, disposition=None, name=None, try: st = os.stat(path) - except (OSError, TypeError): + except (OSError, TypeError, ValueError): + # OSError when file fails to stat + # TypeError on Python 2 when there's a null byte + # ValueError on Python 3 when there's a null byte if debug: cherrypy.log('os.stat(%r) failed' % path, 'TOOLS.STATIC') raise cherrypy.NotFound() -- cgit v1.2.1