diff hgext3rd/evolve/compat.py @ 4745:854637e3d2d0

py3: use array.array.{to,from}bytes() on py3 array.array.{to,from}string() still exists on py3, but they're deprecated and generate warnings. I've put the compat function in compat.pt for now. We can move into a dedicated pycompat.py if we end up with a lot of py3 compat stuff.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 09 Jul 2019 10:56:42 -0700
parents d587611d0c78
children 724c67878d98
line wrap: on
line diff
--- a/hgext3rd/evolve/compat.py	Thu Jul 11 14:31:32 2019 -0700
+++ b/hgext3rd/evolve/compat.py	Tue Jul 09 10:56:42 2019 -0700
@@ -7,6 +7,7 @@
 """
 
 import inspect
+import array
 
 from mercurial import (
     context,
@@ -15,6 +16,7 @@
     mdiff,
     obsolete,
     obsutil,
+    pycompat,
     repair,
     scmutil,
     util,
@@ -22,6 +24,13 @@
 )
 from mercurial.hgweb import hgweb_mod
 
+if pycompat.ispy3:
+    arraytobytes = array.array.tobytes
+    arrayfrombytes = array.array.frombytes
+else:
+    arraytobytes = array.array.tostring
+    arrayfrombytes = array.array.fromstring
+
 # hg < 4.6 compat (c8e2d6ed1f9e)
 try:
     from mercurial import logcmdutil