aboutsummaryrefslogtreecommitdiffstats
path: root/interfaces/email/interactive/be-handle-mail
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-18 10:48:37 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-18 10:48:37 -0400
commit111b5358db203c6d4116f285c7112353e03e79c9 (patch)
tree758bfd7bd2d847a0eddee24cade67a1e0ea78eef /interfaces/email/interactive/be-handle-mail
parent9952f26c3f63ff6525e0bd3e6392dea8600f3ae0 (diff)
downloadbugseverywhere-111b5358db203c6d4116f285c7112353e03e79c9.tar.gz
In be-handle-mail, don't mess with stdin if the command doesn't need it.
This fixes problems with StringIO(None).
Diffstat (limited to 'interfaces/email/interactive/be-handle-mail')
-rwxr-xr-xinterfaces/email/interactive/be-handle-mail10
1 files changed, 6 insertions, 4 deletions
diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail
index cb31f1c..5409a37 100755
--- a/interfaces/email/interactive/be-handle-mail
+++ b/interfaces/email/interactive/be-handle-mail
@@ -149,13 +149,14 @@ def run_message(msg_text):
stdin = body
info["command-args"] = command_args
# set stdin and catch stdout and stderr
- new_stdin = StringIO.StringIO(stdin)
+ if stdin != None:
+ new_stdin = StringIO.StringIO(stdin)
+ orig_stdin = sys.stdin
+ sys.stdin = new_stdin
new_stdout = codecs.getwriter(ENCODING)(StringIO.StringIO())
new_stderr = codecs.getwriter(ENCODING)(StringIO.StringIO())
- orig_stdin = sys.stdin
orig_stdout = sys.stdout
orig_stderr = sys.stderr
- sys.stdin = new_stdin
sys.stdout = new_stdout
sys.stderr = new_stderr
# run the command
@@ -173,9 +174,10 @@ def run_message(msg_text):
except libbe.cmdutil.UserError, e:
err = InvalidCommand(msg, info, e)
# restore stdin, stdout, and stderr
+ if stdin != None:
+ sys.stdin = orig_stdin
sys.stdout.flush()
sys.stderr.flush()
- sys.stdin = orig_stdin
sys.stdout = orig_stdout
sys.stderr = orig_stderr
out_text = codecs.decode(new_stdout.getvalue(), ENCODING)