diff options
author | Allan Crooks <allan@amcone.net> | 2014-04-15 17:52:58 -0400 |
---|---|---|
committer | Allan Crooks <allan@amcone.net> | 2014-04-15 17:52:58 -0400 |
commit | ab0ca3c15d293894d938e64c547e75d3497d50d3 (patch) | |
tree | 020dacb8e45adb294be221c555b86c2baab4867e /cherrypy/lib/cptools.py | |
parent | 2210cfadff4b59b673f8762bd2561b4d3a3558fa (diff) | |
download | cherrypy-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.py | 5 |
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: |