Opened 13 years ago
Last modified 12 years ago
#209 closed defect
foolscap assumesinput from stdin will not be unicode — at Initial Version
| Reported by: | zancas | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 0.6.5 |
| Component: | appserver | Version: | 0.6.4 |
| Keywords: | Cc: |
Description
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)
Note: See
TracTickets for help on using
tickets.
