# Buggy code
def __init__(self, include_lsb=True, os_release_file="", distro_release_file=""):
    """
    The initialization method of this class gathers information from the
    available data sources, and stores that in private instance attributes.
    Subsequent access to the information items uses these private instance
    attributes, so that the data sources are read only once.

    Parameters:

    * ``include_lsb`` (bool): Controls whether the
      `lsb_release command output`_ is included as a data source.

      If the lsb_release command is not available in the program execution
      path, the data source for the lsb_release command will be empty.

    * ``os_release_file`` (string): The path name of the
      `os-release file`_ that is to be used as a data source.

      An empty string (the default) will cause the default path name to
      be used (see `os-release file`_ for details).

      If the specified or defaulted os-release file does not exist, the
      data source for the os-release file will be empty.

    * ``distro_release_file`` (string): The path name of the
      `distro release file`_ that is to be used as a data source.

      An empty string (the default) will cause a default search algorithm
      to be used (see `distro release file`_ for details).

      If the specified distro release file does not exist, or if no default
      distro release file can be found, the data source for the distro
      release file will be empty.

    Public instance attributes:

    * ``os_release_file`` (string): The path name of the
      `os-release file`_ that is actually used as a data source. The
      empty string if no distro release file is used as a data source.

    * ``distro_release_file`` (string): The path name of the
      `distro release file`_ that is actually used as a data source. The
      empty string if no distro release file is used as a data source.

    Raises:

    * :py:exc:`IOError`: Some I/O issue with an os-release file or distro
      release file.

    * :py:exc:`subprocess.CalledProcessError`: The lsb_release command had
      some issue (other than not being available in the program execution
      path).

    * :py:exc:`UnicodeError`: A data source has unexpected characters or
      uses an unexpected encoding.
    """
    self.os_release_file = os_release_file or os.path.join(
        _UNIXCONFDIR, _OS_RELEASE_BASENAME
    )
    self.distro_release_file = distro_release_file or ""  # updated later
    self._os_release_info = self._get_os_release_info()
    self._lsb_release_info = self._get_lsb_release_info() if include_lsb else {}
    self._distro_release_info = self._get_distro_release_info()


# Traceback (UnicodeDecodeError)
51_billappxz%pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.1)
setuptools (38.2.4)
Traceback (most recent call last):
File "/data01/billappxz/scripts/ThirdParty/python27/bin/pip", line 11, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 922, in _get_lsb_release_info
stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd5 in position 24: invalid continuation byte

# Fixed code
def __init__(self, include_lsb=True, os_release_file="", distro_release_file=""):
    """
    The initialization method of this class gathers information from the
    available data sources, and stores that in private instance attributes.
    Subsequent access to the information items uses these private instance
    attributes, so that the data sources are read only once.

    Parameters:

    * ``include_lsb`` (bool): Controls whether the
      `lsb_release command output`_ is included as a data source.

      If the lsb_release command is not available in the program execution
      path, the data source for the lsb_release command will be empty.

    * ``os_release_file`` (string): The path name of the
      `os-release file`_ that is to be used as a data source.

      An empty string (the default) will cause the default path name to
      be used (see `os-release file`_ for details).

      If the specified or defaulted os-release file does not exist, the
      data source for the os-release file will be empty.

    * ``distro_release_file`` (string): The path name of the
      `distro release file`_ that is to be used as a data source.

      An empty string (the default) will cause a default search algorithm
      to be used (see `distro release file`_ for details).

      If the specified distro release file does not exist, or if no default
      distro release file can be found, the data source for the distro
      release file will be empty.

    Public instance attributes:

    * ``os_release_file`` (string): The path name of the
      `os-release file`_ that is actually used as a data source. The
      empty string if no distro release file is used as a data source.

    * ``distro_release_file`` (string): The path name of the
      `distro release file`_ that is actually used as a data source. The
      empty string if no distro release file is used as a data source.

    * ``include_lsb`` (bool): The result of the ``include_lsb`` parameter.
      This controls whether the lsb information will be loaded.

    Raises:

    * :py:exc:`IOError`: Some I/O issue with an os-release file or distro
      release file.

    * :py:exc:`subprocess.CalledProcessError`: The lsb_release command had
      some issue (other than not being available in the program execution
      path).

    * :py:exc:`UnicodeError`: A data source has unexpected characters or
      uses an unexpected encoding.
    """
    self.os_release_file = os_release_file or os.path.join(
        _UNIXCONFDIR, _OS_RELEASE_BASENAME
    )
    self.distro_release_file = distro_release_file or ""  # updated later
    self.include_lsb = include_lsb