{"action":"closed","issue":{"url":"https://api.github.com/repos/jdswinbank/Comet/issues/43","repository_url":"https://api.github.com/repos/jdswinbank/Comet","labels_url":"https://api.github.com/repos/jdswinbank/Comet/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/jdswinbank/Comet/issues/43/comments","events_url":"https://api.github.com/repos/jdswinbank/Comet/issues/43/events","html_url":"https://github.com/jdswinbank/Comet/issues/43","id":167222392,"number":43,"title":"External command handler fails (for Python 3)","user":{"login":"evertrol","id":735460,"avatar_url":"https://avatars.githubusercontent.com/u/735460?v=3","gravatar_id":"","url":"https://api.github.com/users/evertrol","html_url":"https://github.com/evertrol","followers_url":"https://api.github.com/users/evertrol/followers","following_url":"https://api.github.com/users/evertrol/following{/other_user}","gists_url":"https://api.github.com/users/evertrol/gists{/gist_id}","starred_url":"https://api.github.com/users/evertrol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evertrol/subscriptions","organizations_url":"https://api.github.com/users/evertrol/orgs","repos_url":"https://api.github.com/users/evertrol/repos","events_url":"https://api.github.com/users/evertrol/events{/privacy}","received_events_url":"https://api.github.com/users/evertrol/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-24T07:57:37Z","updated_at":"2016-07-31T22:16:10Z","closed_at":"2016-07-31T22:16:10Z","body":"The external command handler using the option `--cmd` appears to fail when using current master (3.0.0a0) and Python 3.\r\n\r\nAfter switching back a few times to 2.0.1 with Python 2, I gave the issue a closer look: it appears `spawn.py` is still using the `text` attribute for `event`, while the corresponding `xml_document` class in `xml.py` is using `raw_bytes`. Simply replacing `text` with `raw_bytes`, and removing an `.encoding()` method call, fixes this for me.\r\n\r\nWhat confuses me somewhat is that changes to `xml_document` and in `spawn.py` were made on the same day, which somewhat suggests this should just work and I'm overlooking something.\r\n\r\nA very quick test shows that the same issue actually occurs for Python 2, and the same diff below fixes it there as well.\r\n\r\nThe diff is\r\n```python\r\n@@ -14,12 +14,12 @@\r\n __all__ = [\"SpawnCommand\"]\r\n\r\n class SpawnCommandProtocol(ProcessProtocol):\r\n-    def __init__(self, deferred, raw_bytes):\r\n+    def __init__(self, deferred, text):\r\n         self.deferred = deferred\r\n-        self.raw_bytes = raw_bytes\r\n+        self.text = text\r\n\r\n     def connectionMade(self):\r\n-        self.transport.write(self.raw_bytes)\r\n+        self.transport.write(self.text.encode('utf-8'))\r\n         self.transport.closeStdin()\r\n\r\n     def processEnded(self, reason):\r\n@@ -47,7 +47,7 @@\r\n         d = defer.Deferred()\r\n         log.info(\"Running external command: %s\" % (self.cmd,))\r\n         reactor.spawnProcess(\r\n-            SpawnCommandProtocol(d, event.raw_bytes),\r\n+            SpawnCommandProtocol(d, event.text),\r\n             self.cmd,\r\n             args=self.args,\r\n             env=os.environ\r\n```\r\n"}}
{"actor":{"display_login":"jdswinbank"}}