[Asterisk-code-review] lib/python: asterisk.voicemail compatibility of maxint for Python 3: (...testsuite[16])

Friendly Automation asteriskteam at digium.com
Mon Jul 22 16:19:12 CDT 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/testsuite/+/11600 )

Change subject: lib/python: asterisk.voicemail compatibility of maxint for Python 3:
......................................................................

lib/python: asterisk.voicemail compatibility of maxint for Python 3:

maxint was remove in Python 3. This change include a port compatibility
for this function for Python 3 using maxsize.

This is accord to the python3 compatibility done in
ChangeId: If76c2d3e11e4ab4552d0df7841287c8bb2de7918

Change-Id: Ie321376d7234ff054dfb9964f5995866879199a3
---
M lib/python/asterisk/voicemail.py
1 file changed, 9 insertions(+), 1 deletion(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/lib/python/asterisk/voicemail.py b/lib/python/asterisk/voicemail.py
index 3c4c7d5..0c1c088 100644
--- a/lib/python/asterisk/voicemail.py
+++ b/lib/python/asterisk/voicemail.py
@@ -429,8 +429,16 @@
                             'c': context, 'm': mailbox, 'f': folder, 'n': msg_env_name})
 
         random.seed()
+
+        # `maxint` was removed in Python 3
+        # https://docs.python.org/3.0/whatsnew/3.0.html#integers
+        if sys.version_info.major == 2:
+           maxint = sys.maxint
+        else:
+           maxint = sys.maxsize
+
         msg_id = (str(int(time.time())) + "-" +
-                  str(random.randrange(0, 1, sys.maxint - 1)))
+                  str(random.randrange(0, 1, maxint - 1)))
 
         with open(msg_env_path, 'w') as envelope_file:
             envelope_file.write(';\n')

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

Gerrit-Project: testsuite
Gerrit-Branch: 16
Gerrit-Change-Id: Ie321376d7234ff054dfb9964f5995866879199a3
Gerrit-Change-Number: 11600
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190722/0558ec0a/attachment-0001.html>


More information about the asterisk-code-review mailing list