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/

 import functools
 import argparse
 import logging
+import itertools
 import pkg_resources
 					if random.random() > rate:
-					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:
 		self._handle_output(channel, messages)

File pmxbot/

 from __future__ import unicode_literals
-from __future__ import absolute_import
 import io
-import itertools
 def always_iterable(item):
 	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):