﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
209	flappclient assumes input from stdin will not be unicode	zancas	zancas	"I've registered an application with a flappserver with the --accept-stdin flag.  I then invoked the application with unicode type arguments.   The flappserver behaves in a difficult to understand manner.

I've traced the data that I input (the unicode) as far as the {{{appserver.services.Command.remote_feed_stdin}}} method at which point it was still passing the data around.  At some point subsequent to that the data was converted to {{{''}}}.

This patch zooko wrote should make the client much pickier about the data types it can receive.

{{{
diff --git a/foolscap/appserver/client.py b/foolscap/appserver/client.py
index 44e6671..18ed0da 100644
--- a/foolscap/appserver/client.py
+++ b/foolscap/appserver/client.py
@@ -103,6 +103,8 @@ class RunCommand(Referenceable, Protocol):
         return self.d
 
     def dataReceived(self, data):
+        if not isinstance(data, str):
+            usage.error('stdin can accept only strings of bytes, not ""%s""' % (type(data),))
         # this is from stdin. It shouldn't be called until after _started
         # sets up stdio and self.stdin_writer
         self.stdin_writer.callRemoteOnly(""feed_stdin"", data)
diff --git a/foolscap/appserver/services.py b/foolscap/appserver/services.py
index f75248e..749ef70 100644
--- a/foolscap/appserver/services.py
+++ b/foolscap/appserver/services.py
@@ -235,6 +235,8 @@ class Command(Referenceable):
         self.log_stdin = log_stdin
         self.closed = False
     def remote_feed_stdin(self, data):
+        if not isinstance(data, str):
+            usage.error('stdin can accept only strings of bytes, not ""%s""' % (type(data),))
         if self.log_stdin:
             log.msg(""stdin: %r"" % data)
         self.process.write(data)
}}}"	defect	closed	major	0.6.5	appserver	0.6.4	fixed		
