Commits

Jason R. Coombs committed dd63977

Restore generate_results to focus on the function output. Now exceptions don't incidentally trap other generated output.

  • Participants
  • Parent commits 6836787

Comments (0)

Files changed (2)

File pmxbot/core.py

 import functools
 import argparse
 import logging
+import itertools
 
 import irc.bot
 import pkg_resources
 						):
 					if random.random() > rate:
 						continue
-					messages = pmxbot.itertools.trap_exceptions(
-						pmxbot.itertools.generate_results(f, messages),
-						exception_handler
-					)
+					messages = itertools.chain(messages,
+						pmxbot.itertools.trap_exceptions(
+							pmxbot.itertools.generate_results(f),
+							exception_handler
+					)	)
 					if not pmxbot.config.chain_contains:
 						break
 		self._handle_output(channel, messages)

File pmxbot/itertools.py

 from __future__ import unicode_literals
-from __future__ import absolute_import
 
 import io
-import itertools
 
 def always_iterable(item):
 	r"""
 
 	return item
 
-def generate_results(function, messages=()):
+def generate_results(function):
 	"""
 	Take a function, which may return an iterator or a static result
 	and convert it to a late-dispatched generator.
 	"""
-	for item in itertools.chain(messages, always_iterable(function())):
+	for item in always_iterable(function()):
 		yield item
 
 def trap_exceptions(results, handler, exceptions=Exception):