[PATCH 2 of 4 py3] smcposix: pass unicode as first argument to array.array

Pulkit Goyal 7895pulkit at gmail.com
Sun Mar 12 13:19:49 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1489337873 -19800
#      Sun Mar 12 22:27:53 2017 +0530
# Node ID 782455a21077bef9c13532ad8dfa69fde1e5ebfc
# Parent  0d6acdc8385488a3dfd18cb413af4f9a2ba71512
smcposix: pass unicode as first argument to array.array

This is an instance where we can safely convert the first argument, rest are
the cases except one where we are using 'c' which is not there in Python 3. So
that needs to be handled differently. This will help in making `hg help` run on
Python 3.

diff -r 0d6acdc83854 -r 782455a21077 mercurial/scmposix.py
--- a/mercurial/scmposix.py	Sun Mar 12 07:35:13 2017 +0530
+++ b/mercurial/scmposix.py	Sun Mar 12 22:27:53 2017 +0530
@@ -66,7 +66,7 @@
             if not os.isatty(fd):
                 continue
             arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8)
-            height, width = array.array('h', arri)[:2]
+            height, width = array.array(r'h', arri)[:2]
             if width > 0 and height > 0:
                 return width, height
         except ValueError:


More information about the Mercurial-devel mailing list