Patchwork [1,of,6] py3: suppress DeprecationWarning about deprecated base64 module aliases

login
register
mail settings
Submitter Manuel Jacob
Date June 16, 2020, 12:49 p.m.
Message ID <a1d235193ad132ed0da7.1592311763@tmp>
Download mbox | patch
Permalink /patch/46516/
State Accepted
Headers show

Comments

Manuel Jacob - June 16, 2020, 12:49 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1592305185 -7200
#      Tue Jun 16 12:59:45 2020 +0200
# Branch stable
# Node ID a1d235193ad132ed0da790f26489a66b7fdc3b1d
# Parent  0c27d981131a3d7404b1bc1731835a9d98552369
# EXP-Topic convert-svn
py3: suppress DeprecationWarning about deprecated base64 module aliases

base64.encodestring() / base64.decodestring() were renamed to
base64.encodebytes() / base64.decodebytes() in Python 3. The old names still
worked, but raised a DeprecationWarning.
Yuya Nishihara - June 16, 2020, 1:48 p.m.
On Tue, 16 Jun 2020 14:49:23 +0200, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1592305185 -7200
> #      Tue Jun 16 12:59:45 2020 +0200
> # Branch stable
> # Node ID a1d235193ad132ed0da790f26489a66b7fdc3b1d
> # Parent  0c27d981131a3d7404b1bc1731835a9d98552369
> # EXP-Topic convert-svn
> py3: suppress DeprecationWarning about deprecated base64 module aliases

Queued for stable, thanks.

Patch

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -84,9 +84,17 @@ 
     return l
 
 
+if pycompat.ispy3:
+    base64_encodebytes = base64.encodebytes
+    base64_decodebytes = base64.decodebytes
+else:
+    base64_encodebytes = base64.encodestring
+    base64_decodebytes = base64.decodestring
+
+
 def encodeargs(args):
     def encodearg(s):
-        lines = base64.encodestring(s)
+        lines = base64_encodebytes(s)
         lines = [l.splitlines()[0] for l in pycompat.iterbytestr(lines)]
         return b''.join(lines)
 
@@ -95,7 +103,7 @@ 
 
 
 def decodeargs(s):
-    s = base64.decodestring(s)
+    s = base64_decodebytes(s)
     return pickle.loads(s)