summaryrefslogtreecommitdiff
path: root/cherrypy/lib/cptools.py
diff options
context:
space:
mode:
authorAllan Crooks <allan@amcone.net>2014-04-15 17:52:58 -0400
committerAllan Crooks <allan@amcone.net>2014-04-15 17:52:58 -0400
commitab0ca3c15d293894d938e64c547e75d3497d50d3 (patch)
tree020dacb8e45adb294be221c555b86c2baab4867e /cherrypy/lib/cptools.py
parent2210cfadff4b59b673f8762bd2561b4d3a3558fa (diff)
downloadcherrypy-git-ab0ca3c15d293894d938e64c547e75d3497d50d3.tar.gz
Use is_iterator function to determine if the response content is iterable, rather than just testing if it is a generator.
This is in preparation for a fix for #1288. Note - we could test against collections.Iterator, but this seems like a cleaner way of doing it for now.
Diffstat (limited to 'cherrypy/lib/cptools.py')
-rw-r--r--cherrypy/lib/cptools.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py
index 134c8e47..66c9c1b8 100644
--- a/cherrypy/lib/cptools.py
+++ b/cherrypy/lib/cptools.py
@@ -6,6 +6,7 @@ import re
import cherrypy
from cherrypy._cpcompat import basestring, md5, set, unicodestr
from cherrypy.lib import httputil as _httputil
+from cherrypy.lib import is_iterator
# Conditional HTTP request support #
@@ -493,12 +494,10 @@ def flatten(debug=False):
This allows cherrypy.response.body to consist of 'nested generators';
that is, a set of generators that yield generators.
"""
- import types
-
def flattener(input):
numchunks = 0
for x in input:
- if not isinstance(x, types.GeneratorType):
+ if not is_iterator(x):
numchunks += 1
yield x
else: