<p>Michael Bradeen <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/starpy/+/18244">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Michael Bradeen: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add support for Python 3<br><br>manager: Replace 'async' reference with 'nowait'. This change breaks<br>backwards compatibility with previous versions of the testsuite,<br>requiring a matching change there. 'async' is now a reserved word<br>in python and can not be used.<br><br>manager and fastagi: twisted in general uses bytes for passing data back<br>and forth while internally we generally want to deal with strings. This<br>requires converting between the two as we interact with the twisted<br>library.<br><br>ASTERISK-26826<br><br>Change-Id: I2fab42abb5318a5db2af3bcd291fc2db95b87e15<br>---<br>M starpy/fastagi.py<br>M starpy/manager.py<br>2 files changed, 7 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/starpy/fastagi.py b/starpy/fastagi.py</span><br><span>index 85de054..7a39f43 100644</span><br><span>--- a/starpy/fastagi.py</span><br><span>+++ b/starpy/fastagi.py</span><br><span>@@ -81,7 +81,7 @@</span><br><span> """</span><br><span> readingVariables = False</span><br><span> lostConnectionDeferred = None</span><br><span style="color: hsl(0, 100%, 40%);">- delimiter = '\n'</span><br><span style="color: hsl(120, 100%, 40%);">+ delimiter = b'\n'</span><br><span> </span><br><span> def __init__(self, *args, **named):</span><br><span> """Initialise the AMIProtocol, arguments are ignored"""</span><br><span>@@ -117,6 +117,7 @@</span><br><span> </span><br><span> def lineReceived(self, line):</span><br><span> """(Internal) Handle Twisted's report of an incoming line from AMI"""</span><br><span style="color: hsl(120, 100%, 40%);">+ line = line.decode("utf-8")</span><br><span> log.debug('Line In: %r', line)</span><br><span> if self.readingVariables:</span><br><span> if not line.strip():</span><br><span>@@ -157,7 +158,7 @@</span><br><span> commandString = commandString.rstrip('\n').rstrip('\r')</span><br><span> df = defer.Deferred()</span><br><span> self.pendingMessages.append(df)</span><br><span style="color: hsl(0, 100%, 40%);">- self.sendLine(commandString)</span><br><span style="color: hsl(120, 100%, 40%);">+ self.sendLine(bytes(commandString,"utf-8"))</span><br><span> return df</span><br><span> </span><br><span> def checkFailure(self, result, failure='-1'):</span><br><span>diff --git a/starpy/manager.py b/starpy/manager.py</span><br><span>index 70c93b3..077b39a 100644</span><br><span>--- a/starpy/manager.py</span><br><span>+++ b/starpy/manager.py</span><br><span>@@ -168,6 +168,7 @@</span><br><span> </span><br><span> def lineReceived(self, line):</span><br><span> """Handle Twisted's report of an incoming line from the manager"""</span><br><span style="color: hsl(120, 100%, 40%);">+ line = line.decode("utf-8")</span><br><span> log.debug('Line In: %r', line)</span><br><span> self.messageCache.append(line)</span><br><span> if not line.strip():</span><br><span>@@ -716,7 +717,7 @@</span><br><span> def originate(</span><br><span> self, channel, context=None, exten=None, priority=None,</span><br><span> timeout=None, callerid=None, account=None, application=None,</span><br><span style="color: hsl(0, 100%, 40%);">- data=None, variable={}, async=False, channelid=None,</span><br><span style="color: hsl(120, 100%, 40%);">+ data=None, variable={}, nowait=False, channelid=None,</span><br><span> otherchannelid=None, codecs=None):</span><br><span> """Originate call to connect channel to given context/exten/priority</span><br><span> </span><br><span>@@ -730,7 +731,7 @@</span><br><span> application -- alternate application to Dial to use for outbound dial</span><br><span> data -- data to pass to application</span><br><span> variable -- variables associated to the call</span><br><span style="color: hsl(0, 100%, 40%);">- async -- make the origination asynchronous</span><br><span style="color: hsl(120, 100%, 40%);">+ nowait -- make the origination asynchronous</span><br><span> """</span><br><span> message = [(k, v) for (k, v) in (</span><br><span> ('action', 'originate'),</span><br><span>@@ -742,7 +743,7 @@</span><br><span> ('account', account),</span><br><span> ('application', application),</span><br><span> ('data', data),</span><br><span style="color: hsl(0, 100%, 40%);">- ('async', str(async)),</span><br><span style="color: hsl(120, 100%, 40%);">+ ('async', str(nowait)),</span><br><span> ('channelid', channelid),</span><br><span> ('otherchannelid', otherchannelid),</span><br><span> ('codecs', codecs),</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/starpy/+/18244">change 18244</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/starpy/+/18244"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: starpy </div>
<div style="display:none"> Gerrit-Branch: 1.1 </div>
<div style="display:none"> Gerrit-Change-Id: I2fab42abb5318a5db2af3bcd291fc2db95b87e15 </div>
<div style="display:none"> Gerrit-Change-Number: 18244 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Michael Bradeen <mbradeen@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>