{"action":"created","issue":{"url":"https://api.github.com/repos/rdegges/pyst2/issues/19","labels_url":"https://api.github.com/repos/rdegges/pyst2/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/rdegges/pyst2/issues/19/comments","events_url":"https://api.github.com/repos/rdegges/pyst2/issues/19/events","html_url":"https://github.com/rdegges/pyst2/issues/19","id":117480566,"number":19,"title":"agi.verbose(\"string\") bug","user":{"login":"Scinawa","id":2940017,"avatar_url":"https://avatars.githubusercontent.com/u/2940017?v=3","gravatar_id":"","url":"https://api.github.com/users/Scinawa","html_url":"https://github.com/Scinawa","followers_url":"https://api.github.com/users/Scinawa/followers","following_url":"https://api.github.com/users/Scinawa/following{/other_user}","gists_url":"https://api.github.com/users/Scinawa/gists{/gist_id}","starred_url":"https://api.github.com/users/Scinawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scinawa/subscriptions","organizations_url":"https://api.github.com/users/Scinawa/orgs","repos_url":"https://api.github.com/users/Scinawa/repos","events_url":"https://api.github.com/users/Scinawa/events{/privacy}","received_events_url":"https://api.github.com/users/Scinawa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-18T00:07:31Z","updated_at":"2015-12-09T18:54:17Z","closed_at":null,"body":" File \"/opt/agi/unknow\", line 13, in <module>\r\n     agi.verbose(\"python agi started\")\r\n File \"/usr/local/lib/python3.4/dist-packages/pyst2-0.4.7-py3.4.egg/asterisk/agi.py\", line 606, in verbose\r\n      self.execute('VERBOSE', self._quote(message), level)\r\nFile \"/usr/local/lib/python3.4/dist-packages/pyst2-0.4.7-py3.4.egg/asterisk/agi.py\", line 121, in _quote\r\n     return ''.join(['\"', string.encode('ascii', 'ignore'), '\"'])\r\nTypeError: sequence item 1: expected str instance, bytes found\r\n"},"comment":{"url":"https://api.github.com/repos/rdegges/pyst2/issues/comments/163356389","html_url":"https://github.com/rdegges/pyst2/issues/19#issuecomment-163356389","issue_url":"https://api.github.com/repos/rdegges/pyst2/issues/19","id":163356389,"user":{"login":"tuxpowered","id":2959347,"avatar_url":"https://avatars.githubusercontent.com/u/2959347?v=3","gravatar_id":"","url":"https://api.github.com/users/tuxpowered","html_url":"https://github.com/tuxpowered","followers_url":"https://api.github.com/users/tuxpowered/followers","following_url":"https://api.github.com/users/tuxpowered/following{/other_user}","gists_url":"https://api.github.com/users/tuxpowered/gists{/gist_id}","starred_url":"https://api.github.com/users/tuxpowered/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuxpowered/subscriptions","organizations_url":"https://api.github.com/users/tuxpowered/orgs","repos_url":"https://api.github.com/users/tuxpowered/repos","events_url":"https://api.github.com/users/tuxpowered/events{/privacy}","received_events_url":"https://api.github.com/users/tuxpowered/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T18:54:17Z","updated_at":"2015-12-09T18:54:17Z","body":"Eill, Asterisk AGI works by standard in/out. And this stdin/out is expected to be plain text. The previous code converted everything passed to it to text str(). This had the side effect of if you passed a string that contained string encodings, as shown below, that the data would not be translated \r\n\r\n  r = '\\xc2\\xae' # The ® trademark symbol.\r\n\r\nBecause python can not determine the actual encoding used on the string, this can not be converted. Furthermore it can cause your asterisk application to crash. \r\nThe code change assures that only valid 'ascii' text is sent back to asterisk to be processed, thus preventing crashes.\r\n\r\n**Enter Python 3.**\r\nUnfortunately strings in python 3 are not really strings. they are byte strings, in Python 2 we have str and unicode, and unicode is not the same as byte strings. There is many more articles about the differences documented elsewhere on the web, which is better at explaining them. \r\n\r\nThe issue comes from python3 when it performs the encoding it returns a byte string, and in python 2 it returns an ascii string.\r\n\r\nFinally, if you care to look at the first line of the agi.py file. *this module is designed to work with python2 not python3.*\r\n\r\nI am happy to review alternative methods, if you present them. BUT  do keep in mind that things should remain compatible with python2.\r\n\r\nAs to your question \"did you ever test your own patches?\", yes, obviously I have. Under the conditions that the script is designed to work, using the correct python interpreter, this functions correctly.\r\n*Did you ever run them under the supported interpreter?*\r\n\r\nIs PyST2 compatible with Python3? No. Not fully. It's getting there.\r\n\r\nCan you submit a test condition and code to be reviewed? Absolutely, and I would be happy to run tests against it. Keep in mind the code should remain backward compatible with python2 installations.\r\n\r\n "}}