[Asterisk-code-review] asterisk.py: Fix TypeError when replacing instanceid (testsuite[16])

Friendly Automation asteriskteam at digium.com
Thu Oct 7 14:27:45 CDT 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/16572 )

Change subject: asterisk.py: Fix TypeError when replacing instanceid
......................................................................

asterisk.py: Fix TypeError when replacing instanceid

id = 23
value = "test <<instanceid>> test"
value.replace("<<instanceid>>", id) fails with a TypeError because
replace doesn't automatically convert the numeric replacement
argument to a string.

Now doing value.replace("<<instanceid>>", str(id))

ASTERISK-29675

Change-Id: I16ec4dc84303ae3c3bdd1884959559675f6143c8
---
M lib/python/asterisk/asterisk.py
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/lib/python/asterisk/asterisk.py b/lib/python/asterisk/asterisk.py
index f1371db..08c4e9a 100644
--- a/lib/python/asterisk/asterisk.py
+++ b/lib/python/asterisk/asterisk.py
@@ -675,7 +675,7 @@
         for key in self.directories.keys():
             value = value.replace("<<%s>>" % key,
                               "%s%s" % (self.base, self.directories[key]))
-            value = value.replace("<<instanceid>>", self.instance_id)
+        value = value.replace("<<instanceid>>", str(self.instance_id))
         return value
 
 # Quick little function for doing search and replace in a file used below.

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/16572
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 16
Gerrit-Change-Id: I16ec4dc84303ae3c3bdd1884959559675f6143c8
Gerrit-Change-Number: 16572
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211007/aff28baa/attachment.html>


More information about the asterisk-code-review mailing list