Merge branch 'master' into 326-miniterm.py-exclusive-access
diff --git a/serial/tools/hexlify_codec.py b/serial/tools/hexlify_codec.py
index 1371da2..bd8f6b0 100644
--- a/serial/tools/hexlify_codec.py
+++ b/serial/tools/hexlify_codec.py
@@ -18,6 +18,8 @@
 
 """
 
+from __future__ import absolute_import
+
 import codecs
 import serial
 
diff --git a/serial/tools/list_ports.py b/serial/tools/list_ports.py
index 827e81f..0d7e3d4 100644
--- a/serial/tools/list_ports.py
+++ b/serial/tools/list_ports.py
@@ -16,6 +16,8 @@
 based on their descriptions or hardware ID.
 """
 
+from __future__ import absolute_import
+
 import sys
 import os
 import re
diff --git a/serial/tools/list_ports_common.py b/serial/tools/list_ports_common.py
index aa91e5e..122e0a2 100644
--- a/serial/tools/list_ports_common.py
+++ b/serial/tools/list_ports_common.py
@@ -7,6 +7,9 @@
 # (C) 2015 Chris Liechti <cliechti@gmx.net>
 #
 # SPDX-License-Identifier:    BSD-3-Clause
+
+from __future__ import absolute_import
+
 import re
 import glob
 import os
@@ -32,7 +35,7 @@
 class ListPortInfo(object):
     """Info collection base class for serial ports"""
 
-    def __init__(self, device=None):
+    def __init__(self, device, skip_link_detection=False):
         self.device = device
         self.name = os.path.basename(device)
         self.description = 'n/a'
@@ -46,7 +49,7 @@
         self.product = None
         self.interface = None
         # special handling for links
-        if device is not None and os.path.islink(device):
+        if not skip_link_detection and device is not None and os.path.islink(device):
             self.hwid = 'LINK={}'.format(os.path.realpath(device))
 
     def usb_description(self):
@@ -91,6 +94,7 @@
         else:
             raise IndexError('{} > 2'.format(index))
 
+
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 def list_links(devices):
     """\
@@ -103,6 +107,7 @@
             links.append(device)
     return links
 
+
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 # test
 if __name__ == '__main__':
diff --git a/serial/tools/list_ports_linux.py b/serial/tools/list_ports_linux.py
index 4ee7877..3f7eadb 100644
--- a/serial/tools/list_ports_linux.py
+++ b/serial/tools/list_ports_linux.py
@@ -8,6 +8,8 @@
 #
 # SPDX-License-Identifier:    BSD-3-Clause
 
+from __future__ import absolute_import
+
 import glob
 import os
 from serial.tools import list_ports_common
diff --git a/serial/tools/list_ports_osx.py b/serial/tools/list_ports_osx.py
index 79ce4f1..f46a820 100644
--- a/serial/tools/list_ports_osx.py
+++ b/serial/tools/list_ports_osx.py
@@ -21,6 +21,8 @@
 
 # Also see the 'IORegistryExplorer' for an idea of what we are actually searching
 
+from __future__ import absolute_import
+
 import ctypes
 import ctypes.util
 
diff --git a/serial/tools/list_ports_posix.py b/serial/tools/list_ports_posix.py
index 0d580b0..79bc8ed 100644
--- a/serial/tools/list_ports_posix.py
+++ b/serial/tools/list_ports_posix.py
@@ -16,6 +16,8 @@
 currently just identical to the port name.
 """
 
+from __future__ import absolute_import
+
 import glob
 import sys
 import os
diff --git a/serial/tools/list_ports_windows.py b/serial/tools/list_ports_windows.py
index f28047b..19b9499 100644
--- a/serial/tools/list_ports_windows.py
+++ b/serial/tools/list_ports_windows.py
@@ -8,6 +8,8 @@
 #
 # SPDX-License-Identifier:    BSD-3-Clause
 
+from __future__ import absolute_import
+
 # pylint: disable=invalid-name,too-few-public-methods
 import re
 import ctypes
@@ -113,7 +115,7 @@
 RegCloseKey.restype = LONG
 
 RegQueryValueEx = advapi32.RegQueryValueExW
-RegQueryValueEx.argtypes = [HKEY, LPCTSTR , LPDWORD, LPDWORD, LPBYTE, LPDWORD]
+RegQueryValueEx.argtypes = [HKEY, LPCTSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD]
 RegQueryValueEx.restype = LONG
 
 
@@ -206,7 +208,7 @@
             # stringify
             szHardwareID_str = szHardwareID.value
 
-            info = list_ports_common.ListPortInfo(port_name_buffer.value)
+            info = list_ports_common.ListPortInfo(port_name_buffer.value, skip_link_detection=True)
 
             # in case of USB, make a more readable string, similar to that form
             # that we also generate on other platforms
diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py
index b2d4adb..3b8d5d2 100644
--- a/serial/tools/miniterm.py
+++ b/serial/tools/miniterm.py
@@ -3,10 +3,12 @@
 # Very simple serial terminal
 #
 # This file is part of pySerial. https://github.com/pyserial/pyserial
-# (C)2002-2015 Chris Liechti <cliechti@gmx.net>
+# (C)2002-2017 Chris Liechti <cliechti@gmx.net>
 #
 # SPDX-License-Identifier:    BSD-3-Clause
 
+from __future__ import absolute_import
+
 import codecs
 import os
 import sys
@@ -347,8 +349,8 @@
         self.eol = eol
         self.filters = filters
         self.update_transformations()
-        self.exit_character = 0x1d  # GS/CTRL+]
-        self.menu_character = 0x14  # Menu: CTRL+T
+        self.exit_character = unichr(0x1d)  # GS/CTRL+]
+        self.menu_character = unichr(0x14)  # Menu: CTRL+T
         self.alive = None
         self._reader_alive = None
         self.receiver_thread = None
@@ -520,7 +522,7 @@
         elif c == '\x06':                       # CTRL+F -> edit filters
             self.change_filter()
         elif c == '\x0c':                       # CTRL+L -> EOL mode
-            modes = list(EOL_TRANSFORMATIONS)  # keys
+            modes = list(EOL_TRANSFORMATIONS)   # keys
             eol = modes.index(self.eol) + 1
             if eol >= len(modes):
                 eol = 0
@@ -760,130 +762,130 @@
     import argparse
 
     parser = argparse.ArgumentParser(
-        description="Miniterm - A simple terminal program for the serial port.")
+        description='Miniterm - A simple terminal program for the serial port.')
 
     parser.add_argument(
-        "port",
+        'port',
         nargs='?',
-        help="serial port name ('-' to show port list)",
+        help='serial port name ("-" to show port list)',
         default=default_port)
 
     parser.add_argument(
-        "baudrate",
+        'baudrate',
         nargs='?',
         type=int,
-        help="set baud rate, default: %(default)s",
+        help='set baud rate, default: %(default)s',
         default=default_baudrate)
 
-    group = parser.add_argument_group("port settings")
+    group = parser.add_argument_group('port settings')
 
     group.add_argument(
-        "--parity",
+        '--parity',
         choices=['N', 'E', 'O', 'S', 'M'],
         type=lambda c: c.upper(),
-        help="set parity, one of {N E O S M}, default: N",
+        help='set parity, one of {N E O S M}, default: N',
         default='N')
 
     group.add_argument(
-        "--rtscts",
-        action="store_true",
-        help="enable RTS/CTS flow control (default off)",
+        '--rtscts',
+        action='store_true',
+        help='enable RTS/CTS flow control (default off)',
         default=False)
 
     group.add_argument(
-        "--xonxoff",
-        action="store_true",
-        help="enable software flow control (default off)",
+        '--xonxoff',
+        action='store_true',
+        help='enable software flow control (default off)',
         default=False)
 
     group.add_argument(
-        "--rts",
+        '--rts',
         type=int,
-        help="set initial RTS line state (possible values: 0, 1)",
+        help='set initial RTS line state (possible values: 0, 1)',
         default=default_rts)
 
     group.add_argument(
-        "--dtr",
+        '--dtr',
         type=int,
-        help="set initial DTR line state (possible values: 0, 1)",
+        help='set initial DTR line state (possible values: 0, 1)',
         default=default_dtr)
 
     group.add_argument(
-        "--non-exclusive",
-        dest="exclusive",
-        action="store_false",
-        help="disable locking for native ports",
+        '--non-exclusive',
+        dest='exclusive',
+        action='store_false',
+        help='disable locking for native ports',
         default=True)
 
     group.add_argument(
-        "--ask",
-        action="store_true",
-        help="ask again for port when open fails",
+        '--ask',
+        action='store_true',
+        help='ask again for port when open fails',
         default=False)
 
-    group = parser.add_argument_group("data handling")
+    group = parser.add_argument_group('data handling')
 
     group.add_argument(
-        "-e", "--echo",
-        action="store_true",
-        help="enable local echo (default off)",
+        '-e', '--echo',
+        action='store_true',
+        help='enable local echo (default off)',
         default=False)
 
     group.add_argument(
-        "--encoding",
-        dest="serial_port_encoding",
-        metavar="CODEC",
-        help="set the encoding for the serial port (e.g. hexlify, Latin1, UTF-8), default: %(default)s",
+        '--encoding',
+        dest='serial_port_encoding',
+        metavar='CODEC',
+        help='set the encoding for the serial port (e.g. hexlify, Latin1, UTF-8), default: %(default)s',
         default='UTF-8')
 
     group.add_argument(
-        "-f", "--filter",
-        action="append",
-        metavar="NAME",
-        help="add text transformation",
+        '-f', '--filter',
+        action='append',
+        metavar='NAME',
+        help='add text transformation',
         default=[])
 
     group.add_argument(
-        "--eol",
+        '--eol',
         choices=['CR', 'LF', 'CRLF'],
         type=lambda c: c.upper(),
-        help="end of line mode",
+        help='end of line mode',
         default='CRLF')
 
     group.add_argument(
-        "--raw",
-        action="store_true",
-        help="Do no apply any encodings/transformations",
+        '--raw',
+        action='store_true',
+        help='Do no apply any encodings/transformations',
         default=False)
 
-    group = parser.add_argument_group("hotkeys")
+    group = parser.add_argument_group('hotkeys')
 
     group.add_argument(
-        "--exit-char",
+        '--exit-char',
         type=int,
         metavar='NUM',
-        help="Unicode of special character that is used to exit the application, default: %(default)s",
+        help='Unicode of special character that is used to exit the application, default: %(default)s',
         default=0x1d)  # GS/CTRL+]
 
     group.add_argument(
-        "--menu-char",
+        '--menu-char',
         type=int,
         metavar='NUM',
-        help="Unicode code of special character that is used to control miniterm (menu), default: %(default)s",
+        help='Unicode code of special character that is used to control miniterm (menu), default: %(default)s',
         default=0x14)  # Menu: CTRL+T
 
-    group = parser.add_argument_group("diagnostics")
+    group = parser.add_argument_group('diagnostics')
 
     group.add_argument(
-        "-q", "--quiet",
-        action="store_true",
-        help="suppress non-error messages",
+        '-q', '--quiet',
+        action='store_true',
+        help='suppress non-error messages',
         default=False)
 
     group.add_argument(
-        "--develop",
-        action="store_true",
-        help="show Python traceback on error",
+        '--develop',
+        action='store_true',
+        help='show Python traceback on error',
         default=False)
 
     args = parser.parse_args()
@@ -977,7 +979,7 @@
     except KeyboardInterrupt:
         pass
     if not args.quiet:
-        sys.stderr.write("\n--- exit ---\n")
+        sys.stderr.write('\n--- exit ---\n')
     miniterm.join()
     miniterm.close()