From 7e2f7e78697a0a9126cdbc69bbea699c00b7c121 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 9 Sep 2019 00:50:58 -0700 Subject: LimitedLengthFile: Handle io.UnsupportedOperation from socket.tell(). (#35) On Python 3, socket.makefile() returns an object with a tell() method, but one that always raises io.UnsupportedOperation. --- paste/httpserver.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'paste/httpserver.py') diff --git a/paste/httpserver.py b/paste/httpserver.py index 063c180..7709c60 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -20,6 +20,7 @@ if pyOpenSSL is installed, it also provides SSL capabilities. from __future__ import print_function import atexit import traceback +import io import socket, sys, threading import posixpath import six @@ -523,9 +524,11 @@ class LimitedLengthFile(object): def tell(self): if hasattr(self.file, 'tell'): - return self.file.tell() - else: - return self._consumed + try: + return self.file.tell() + except io.UnsupportedOperation: + pass + return self._consumed class ThreadPool(object): """ -- cgit v1.2.1