# Buggy code
def _update_defaults(self, defaults):
    """Updates the given defaults with values from the config files and
    the environ. Does a little special handling for certain types of
    options (lists)."""

    # Load the configuration
    self.config.load()

    # Accumulate complex default state.
    self.values = optparse.Values(self.defaults)
    late_eval = set()
    # Then set the options with those values
    for key, val in self._get_ordered_configuration_items():
        # '--' because configuration supports only long names
        option = self.get_option("--" + key)

        # Ignore options not present in this parser. E.g. non-globals put
        # in [global] by users that want them to apply to all applicable
        # commands.
        if option is None:
            continue

        if option.action in ("store_true", "store_false", "count"):
            val = strtobool(val)
        elif option.action == "append":
            val = val.split()
            val = [self.check_default(option, key, v) for v in val]
        elif option.action == "callback":
            late_eval.add(option.dest)
            opt_str = option.get_opt_string()
            val = option.convert_value(opt_str, val)
            # From take_action
            args = option.callback_args or ()
            kwargs = option.callback_kwargs or {}
            option.callback(option, opt_str, val, self, *args, **kwargs)
        else:
            val = self.check_default(option, key, val)

        defaults[option.dest] = val

    for key in late_eval:
        defaults[key] = getattr(self.values, key)
    self.values = None
    return defaults


# Traceback (UnicodeDecodeError)
C:\Users\cyl>pip list
Traceback (most recent call last):
File "C:\Users\cyl\AppData\Local\Programs\Python\Python35\Scripts\pip-script.py", line 11, in <module>
load_entry_point('pip==10.0.0.dev0', 'console_scripts', 'pip')()
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\__init__.py", line 229, in main
cmd_name, cmd_args = parseopts(args)
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\__init__.py", line 178, in parseopts
general_options, args_else = parser.parse_args(args)
File "C:\Users\cyl\AppData\Local\Programs\Python\Python35\lib\optparse.py", line 1370, in parse_args
values = self.get_default_values()
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\baseparser.py", line 227, in get_default_values
defaults = self._update_defaults(self.defaults.copy())  # ours
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\baseparser.py", line 181, in _update_defaults
self.config.load()
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\configuration.py", line 111, in load
self._load_config_files()
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\configuration.py", line 262, in _load_config_files
parser = self._load_file(variant, fname)
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\configuration.py", line 270, in _load_file
parser = self._construct_parser(fname)
File "c:\users\cyl\appdata\local\programs\python\python35\lib\site-packages\pip-10.0.0.dev0-py3.5.egg\pip\_internal\configuration.py", line 286, in _construct_parser
parser.read(fname)
File "C:\Users\cyl\AppData\Local\Programs\Python\Python35\lib\configparser.py", line 696, in read
self._read(fp, filename)
File "C:\Users\cyl\AppData\Local\Programs\Python\Python35\lib\configparser.py", line 1012, in _read
for lineno, line in enumerate(fp, start=1):
UnicodeDecodeError: 'gbk' codec can't decode byte 0x90 in position 101: illegal multibyte sequence

# Fixed code
def _update_defaults(self, defaults):
    """Updates the given defaults with values from the config files and
    the environ. Does a little special handling for certain types of
    options (lists)."""

    # Accumulate complex default state.
    self.values = optparse.Values(self.defaults)
    late_eval = set()
    # Then set the options with those values
    for key, val in self._get_ordered_configuration_items():
        # '--' because configuration supports only long names
        option = self.get_option("--" + key)

        # Ignore options not present in this parser. E.g. non-globals put
        # in [global] by users that want them to apply to all applicable
        # commands.
        if option is None:
            continue

        if option.action in ("store_true", "store_false", "count"):
            val = strtobool(val)
        elif option.action == "append":
            val = val.split()
            val = [self.check_default(option, key, v) for v in val]
        elif option.action == "callback":
            late_eval.add(option.dest)
            opt_str = option.get_opt_string()
            val = option.convert_value(opt_str, val)
            # From take_action
            args = option.callback_args or ()
            kwargs = option.callback_kwargs or {}
            option.callback(option, opt_str, val, self, *args, **kwargs)
        else:
            val = self.check_default(option, key, val)

        defaults[option.dest] = val

    for key in late_eval:
        defaults[key] = getattr(self.values, key)
    self.values = None
    return defaults