update file headers with license information (SPDX)
diff --git a/LICENSE.txt b/LICENSE.txt
index ed15d37..ab75467 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -29,3 +29,11 @@
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+---------------------------------------------------------------------------
+Note:
+Individual files contain the following tag instead of the full license text.
+
+    SPDX-License-Identifier:    BSD-3-Clause
+
+This enables machine processing of license information based on the SPDX
+License Identifiers that are here available: http://spdx.org/licenses/
diff --git a/examples/port_publisher.py b/examples/port_publisher.py
index 8786733..a87be65 100755
--- a/examples/port_publisher.py
+++ b/examples/port_publisher.py
@@ -1,4 +1,8 @@
 #! /usr/bin/env python

+#

+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>

+#

+# SPDX-License-Identifier:    BSD-3-Clause

 """\

 Multi-port serial<->TCP/IP forwarder.

 - RFC 2217

diff --git a/examples/rfc2217_server.py b/examples/rfc2217_server.py
index 886925a..fb89627 100755
--- a/examples/rfc2217_server.py
+++ b/examples/rfc2217_server.py
@@ -1,9 +1,11 @@
 #!/usr/bin/env python
-
-# (C) 2009 Chris Liechti <cliechti@gmx.net>
+#
 # redirect data from a TCP/IP connection to a serial port and vice versa
 # using RFC 2217
-
+#
+# (C) 2009 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 import logging
 import os
diff --git a/examples/setup-miniterm-py2exe.py b/examples/setup-miniterm-py2exe.py
index 0df67ee..0bc5c19 100644
--- a/examples/setup-miniterm-py2exe.py
+++ b/examples/setup-miniterm-py2exe.py
@@ -1,4 +1,8 @@
 # setup script for py2exe to create the miniterm.exe
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 from distutils.core import setup
 import glob
diff --git a/examples/setup-rfc2217_server-py2exe.py b/examples/setup-rfc2217_server-py2exe.py
index 4c98dd7..04670ca 100644
--- a/examples/setup-rfc2217_server-py2exe.py
+++ b/examples/setup-rfc2217_server-py2exe.py
@@ -1,4 +1,8 @@
 # setup script for py2exe to create the rfc2217_server.exe
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 from distutils.core import setup
 import glob
diff --git a/examples/setup-wxTerminal-py2exe.py b/examples/setup-wxTerminal-py2exe.py
index 018515b..9e0add7 100644
--- a/examples/setup-wxTerminal-py2exe.py
+++ b/examples/setup-wxTerminal-py2exe.py
@@ -1,14 +1,19 @@
 # This is a setup.py example script for the use with py2exe
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
+
 from distutils.core import setup
 import os
 import sys
 import py2exe
 
-#this script is only useful for py2exe so just run that distutils command.
-#that allows to run it with a simple double click.
+# this script is only useful for py2exe so just run that distutils command.
+# that allows to run it with a simple double click.
 sys.argv.append('py2exe')
 
-#get an icon from somewhere.. the python installation should have one:
+# get an icon from somewhere.. the python installation should have one:
 icon = os.path.join(os.path.dirname(sys.executable), 'py.ico')
 
 setup(
diff --git a/examples/tcp_serial_redirect.py b/examples/tcp_serial_redirect.py
index e821b74..0ac5c5a 100755
--- a/examples/tcp_serial_redirect.py
+++ b/examples/tcp_serial_redirect.py
@@ -1,9 +1,10 @@
 #!/usr/bin/env python
-
+#
+# Redirect data from a TCP/IP connection to a serial port and vice versa.
+#
 # (C) 2002-2009 Chris Liechti <cliechti@gmx.net>
-# redirect data from a TCP/IP connection to a serial port and vice versa
-# requires Python 2.2 'cause socket.sendall is used
-
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 import sys
 import os
diff --git a/examples/wxSerialConfigDialog.py b/examples/wxSerialConfigDialog.py
index 6b1a1db..3a2a83d 100755
--- a/examples/wxSerialConfigDialog.py
+++ b/examples/wxSerialConfigDialog.py
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
-# generated by wxGlade 0.3.1 on Thu Oct 02 23:25:44 2003
+#
+# A serial port configuration dialog for wxPython. A number of flags can
+# be used to cinfugure the fields that are displayed.
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
-#from wxPython.wx import *
 import wx
 import serial
 import serial.tools.list_ports
diff --git a/examples/wxTerminal.py b/examples/wxTerminal.py
index 5ba8ba7..47ee698 100755
--- a/examples/wxTerminal.py
+++ b/examples/wxTerminal.py
@@ -1,5 +1,10 @@
 #!/usr/bin/env python
-# generated by wxGlade 0.3.1 on Fri Oct 03 23:23:45 2003
+#
+# A simple terminal application with wxPython.
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 #from wxPython.wx import *
 import wx
diff --git a/serial/__init__.py b/serial/__init__.py
index d7dcde3..f40ed3e 100644
--- a/serial/__init__.py
+++ b/serial/__init__.py
@@ -1,10 +1,11 @@
 #!/usr/bin/env python
-
+#
 # portable serial port access with python
 # this is a wrapper module for different platform implementations
 #
-# (C) 2001-2010 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 VERSION = '3.0a'
 
diff --git a/serial/rfc2217.py b/serial/rfc2217.py
index d075e4e..8776f09 100644
--- a/serial/rfc2217.py
+++ b/serial/rfc2217.py
@@ -8,7 +8,8 @@
 # modem control lines etc.
 #
 # (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 # TODO:
 # - setting control line -> answer is not checked (had problems with one of the
diff --git a/serial/rs485.py b/serial/rs485.py
index cc17378..6f2145b 100644
--- a/serial/rs485.py
+++ b/serial/rs485.py
@@ -3,6 +3,8 @@
 # RS485 support
 #
 # (C) 2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 """\
 The settings for RS485 are stored in a dedicated object that can be applied to
diff --git a/serial/serialcli.py b/serial/serialcli.py
index 622611c..622f737 100644
--- a/serial/serialcli.py
+++ b/serial/serialcli.py
@@ -4,7 +4,8 @@
 # see __init__.py
 #
 # (C) 2008 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 import clr
 import System
diff --git a/serial/serialjava.py b/serial/serialjava.py
index e36ecf5..d9ee515 100644
--- a/serial/serialjava.py
+++ b/serial/serialjava.py
@@ -5,7 +5,8 @@
 # see __init__.py
 #
 # (C) 2002-2008 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 from serial.serialutil import *
 
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 2052f74..4db261b 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -5,7 +5,8 @@
 # see __init__.py
 #
 # (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 #
 # parts based on code from Grant B. Edwards  <grante@visi.com>:
 #  ftp://ftp.visi.com/users/grante/python/PosixSerial.py
diff --git a/serial/serialutil.py b/serial/serialutil.py
index 4d2c7e0..a71bd37 100644
--- a/serial/serialutil.py
+++ b/serial/serialutil.py
@@ -3,7 +3,8 @@
 # see __init__.py
 #
 # (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 import io
 
diff --git a/serial/serialwin32.py b/serial/serialwin32.py
index cf54a17..d360d9c 100644
--- a/serial/serialwin32.py
+++ b/serial/serialwin32.py
@@ -4,7 +4,8 @@
 # see __init__.py
 #
 # (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 #
 # Initial patch to use ctypes by Giovanni Bajo <rasky@develer.com>
 
diff --git a/serial/tools/list_ports.py b/serial/tools/list_ports.py
index 403b405..468411a 100644
--- a/serial/tools/list_ports.py
+++ b/serial/tools/list_ports.py
@@ -5,7 +5,8 @@
 # port enumeration feature
 #
 # (C) 2011-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 """\
 This module will provide a function called comports that returns an
diff --git a/serial/tools/list_ports_linux.py b/serial/tools/list_ports_linux.py
index 8ca1565..11092b5 100644
--- a/serial/tools/list_ports_linux.py
+++ b/serial/tools/list_ports_linux.py
@@ -1,12 +1,13 @@
 #!/usr/bin/env python

-

+#

 # portable serial port access with python

 #

 # This is a module that gathers a list of serial ports including details on

 # GNU/Linux systems

 #

-# (C) 2011-2013 Chris Liechti <cliechti@gmx.net>

-# this is distributed under a free software license, see license.txt

+# (C) 2011-2015 Chris Liechti <cliechti@gmx.net>

+#

+# SPDX-License-Identifier:    BSD-3-Clause

 

 import glob

 import sys

diff --git a/serial/tools/list_ports_osx.py b/serial/tools/list_ports_osx.py
index fbce6f2..a451ae6 100644
--- a/serial/tools/list_ports_osx.py
+++ b/serial/tools/list_ports_osx.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-
+#
 # portable serial port access with python
 #
 # This is a module that gathers a list of serial ports including details on OSX
@@ -8,7 +8,9 @@
 # with contributions from cibomahto, dgs3, FarMcKon, tedbrandston
 # and modifications by cliechti
 #
-# this is distributed under a free software license, see license.txt
+# (C) 2013-2015
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 
 
diff --git a/serial/tools/list_ports_posix.py b/serial/tools/list_ports_posix.py
index d90d6af..a1a3faf 100644
--- a/serial/tools/list_ports_posix.py
+++ b/serial/tools/list_ports_posix.py
@@ -8,8 +8,9 @@
 # this is a wrapper module for different platform implementations of the

 # port enumeration feature

 #

-# (C) 2011-2013 Chris Liechti <cliechti@gmx.net>

-# this is distributed under a free software license, see license.txt

+# (C) 2011-2015 Chris Liechti <cliechti@gmx.net>

+#

+# SPDX-License-Identifier:    BSD-3-Clause

 

 """\

 The ``comports`` function is expected to return an iterable that yields tuples

@@ -102,3 +103,4 @@
 if __name__ == '__main__':

     for port, desc, hwid in sorted(comports()):

         print("%s: %s [%s]" % (port, desc, hwid))

+

diff --git a/serial/tools/list_ports_windows.py b/serial/tools/list_ports_windows.py
index 4d52d3f..c285dde 100644
--- a/serial/tools/list_ports_windows.py
+++ b/serial/tools/list_ports_windows.py
@@ -1,3 +1,12 @@
+#! python

+#

+# Enumerate serial ports on Windows including a human readable description

+# and hardware information.

+#

+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>

+#

+# SPDX-License-Identifier:    BSD-3-Clause

+

 import ctypes

 import re

 

@@ -239,3 +248,4 @@
 

     for port, desc, hwid in sorted(comports()):

         print("%s: %s [%s]" % (port, desc, hwid))

+

diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py
index 85cc75a..2bee68b 100644
--- a/serial/tools/miniterm.py
+++ b/serial/tools/miniterm.py
@@ -1,6 +1,10 @@
 #!/usr/bin/env python
+#
 # Very simple serial terminal
+#
 # (C)2002-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 # Input characters are sent directly (only LF -> CR/LF/CRLF translation is
 # done), received characters are displayed as is (or escaped through pythons
diff --git a/serial/urlhandler/protocol_hwgrep.py b/serial/urlhandler/protocol_hwgrep.py
index f7bf2e7..471f6d0 100644
--- a/serial/urlhandler/protocol_hwgrep.py
+++ b/serial/urlhandler/protocol_hwgrep.py
@@ -7,7 +7,8 @@
 # find ports by searching the string descriptions.
 #
 # (C) 2011-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 #
 # URL format:    hwgrep://regexp
 
@@ -32,7 +33,8 @@
 
     def fromURL(self, url):
         """extract host and port from an URL string"""
-        if url.lower().startswith("hwgrep://"): url = url[9:]
+        if url.lower().startswith("hwgrep://"):
+            url = url[9:]
         # use a for loop to get the 1st element from the generator
         for port, desc, hwid in serial.tools.list_ports.grep(url):
             return port
diff --git a/serial/urlhandler/protocol_loop.py b/serial/urlhandler/protocol_loop.py
index 6883b4c..756704b 100644
--- a/serial/urlhandler/protocol_loop.py
+++ b/serial/urlhandler/protocol_loop.py
@@ -9,7 +9,8 @@
 # and it was so easy to implement ;-)
 #
 # (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 #
 # URL format:    loop://[option[/option...]]
 # options:
diff --git a/serial/urlhandler/protocol_rfc2217.py b/serial/urlhandler/protocol_rfc2217.py
index 981ba45..fba67d5 100644
--- a/serial/urlhandler/protocol_rfc2217.py
+++ b/serial/urlhandler/protocol_rfc2217.py
@@ -6,6 +6,7 @@
 # This is a thin wrapper to load the rfc2271 implementation.
 #
 # (C) 2011 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 from serial.rfc2217 import Serial
diff --git a/serial/urlhandler/protocol_socket.py b/serial/urlhandler/protocol_socket.py
index 44702c3..4fe188d 100644
--- a/serial/urlhandler/protocol_socket.py
+++ b/serial/urlhandler/protocol_socket.py
@@ -11,22 +11,24 @@
 # TCP/IP to serial port converters that do not support RFC 2217.
 #
 # (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 #
 # URL format:    socket://<host>:<port>[/option[/option...]]
 # options:
 # - "debug" print diagnostic messages
 
-from serial.serialutil import *
-import time
-import socket
-import select
 import logging
+import select
+import socket
+import time
 try:
     import urlparse
 except ImportError:
     import urllib.parse as urlparse
 
+from serial.serialutil import *
+
 # map log level names to constants. used in fromURL()
 LOGGER_LEVELS = {
         'debug': logging.DEBUG,
@@ -271,7 +273,7 @@
     sys.stdout.write('%s\n' % s)
 
     sys.stdout.write("write...\n")
-    s.write("hello\n")
+    s.write(b"hello\n")
     s.flush()
     sys.stdout.write("read: %s\n" % s.read(5))
 
diff --git a/serial/win32.py b/serial/win32.py
index ec380ec..88a1335 100644
--- a/serial/win32.py
+++ b/serial/win32.py
@@ -1,3 +1,9 @@
+#! python
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
+
 from ctypes import *
 from ctypes.wintypes import HANDLE
 from ctypes.wintypes import BOOL
diff --git a/setup.py b/setup.py
index 17f4df0..fec5039 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,10 @@
 #
 # For Python 3.x use the corresponding Python executable,
 # e.g. "python3 setup.py ..."
+#
+# (C) 2001-2015 Chris Liechti <cliechti@gmx.net>
+#
+# SPDX-License-Identifier:    BSD-3-Clause
 
 try:
     from setuptools import setup