# Buggy code
def __init__(self, args):
    """
    :param args: CLI args
    """
    global manager
    if not self.unit_test:
        assert not manager, "Only one instance of Manager should be created at a time!"
    elif manager:
        log.info("last manager was not torn down correctly")

    if args is None:
        # Decode all arguments to unicode before parsing
        args = unicode_argv()[1:]
    self.args = args
    self.autoreload_config = False
    self.config_file_hash = None
    self.config_base = None
    self.config_name = None
    self.config_path = None
    self.db_filename = None
    self.engine = None
    self.lockfile = None
    self.database_uri = None
    self.db_upgraded = False
    self._has_lock = False
    self.is_daemon = False
    self.ipc_server = None
    self.task_queue = None
    self.persist = None
    self.initialized = False

    self.config = {}

    if "--help" in args or "-h" in args:
        # TODO: This is a bit hacky, but we can't call parse on real arguments when --help is used because it will
        # cause a system exit before plugins are loaded and print incomplete help. This will get us a default
        # options object and we'll parse the real args later, or send them to daemon. #2807
        self.options, _ = CoreArgumentParser().parse_known_args(["execute"])
    else:
        try:
            self.options, _ = CoreArgumentParser().parse_known_args(args)
        except ParserError:
            try:
                # If a non-built-in command was used, we need to parse with a parser that
                # doesn't define the subparsers
                self.options, _ = manager_parser.parse_known_args(args)
            except ParserError as e:
                manager_parser.print_help()
                print("\nError: %s" % e.message)
                sys.exit(1)
    try:
        self.find_config(create=False)
    except:
        logger.start(level=self.options.loglevel.upper(), to_file=False)
        raise
    else:
        log_file = os.path.expanduser(self.options.logfile)
        # If an absolute path is not specified, use the config directory.
        if not os.path.isabs(log_file):
            log_file = os.path.join(self.config_base, log_file)

        logger.start(
            log_file, self.options.loglevel.upper(), to_console=not self.options.cron
        )

    manager = self

    log.debug("sys.defaultencoding: %s" % sys.getdefaultencoding())
    log.debug("sys.getfilesystemencoding: %s" % sys.getfilesystemencoding())
    log.debug(
        "os.path.supports_unicode_filenames: %s" % os.path.supports_unicode_filenames
    )
    if (
        codecs.lookup(sys.getfilesystemencoding()).name == "ascii"
        and not os.path.supports_unicode_filenames
    ):
        log.warning(
            "Your locale declares ascii as the filesystem encoding. Any plugins reading filenames from "
            "disk will not work properly for filenames containing non-ascii characters. Make sure your "
            "locale env variables are set up correctly for the environment which is launching FlexGet."
        )


# Traceback (UnicodeEncodeError)
--- Logging error ---
Traceback (most recent call last):
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\logging\__init__.py", line 982, in emit
stream.write(msg)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\colorclass\windows.py", line 275, in write
print(segment, file=self._original_stream, end='')
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2022' in position 67: character maps to <undefined>
Call stack:
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\task_queue.py", line 48, in run
self.current_task.execute()
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\task.py", line 72, in wrapper
return func(self, *args, **kw)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\task.py", line 646, in execute
self._execute()
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\task.py", line 612, in _execute
self.__run_task_phase(phase)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\task.py", line 453, in __run_task_phase
response = self.__run_plugin(plugin, phase, args)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\task.py", line 483, in __run_plugin
return method(*args, **kwargs)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\event.py", line 23, in __call__
return self.func(*args, **kwargs)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\plugins\filter\quality.py", line 37, in on_task_filter
entry.reject('%s does not match quality requirement %s' % (entry['quality'], reqs))
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\entry.py", line 152, in reject
self.run_hooks('reject', reason=reason, **kwargs)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\entry.py", line 80, in run_hooks
func(self, **kwargs)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\plugins\operate\verbose.py", line 34, in verbose_details
task_log.verbose(msg)
File "c:\users\andy\appdata\local\programs\python\python35-32\lib\site-packages\flexget\logger.py", line 127, in verbose
self.log(VERBOSE, msg, *args, **kwargs)

# Fixed code
def __init__(self, args):
    """
    :param args: CLI args
    """
    global manager
    if not self.unit_test:
        assert not manager, "Only one instance of Manager should be created at a time!"
    elif manager:
        log.info("last manager was not torn down correctly")

    if args is None:
        # Decode all arguments to unicode before parsing
        args = unicode_argv()[1:]
    self.args = args
    self.autoreload_config = False
    self.config_file_hash = None
    self.config_base = None
    self.config_name = None
    self.config_path = None
    self.db_filename = None
    self.engine = None
    self.lockfile = None
    self.database_uri = None
    self.db_upgraded = False
    self._has_lock = False
    self.is_daemon = False
    self.ipc_server = None
    self.task_queue = None
    self.persist = None
    self.initialized = False

    self.config = {}

    if "--help" in args or "-h" in args:
        # TODO: This is a bit hacky, but we can't call parse on real arguments when --help is used because it will
        # cause a system exit before plugins are loaded and print incomplete help. This will get us a default
        # options object and we'll parse the real args later, or send them to daemon. #2807
        self.options, _ = CoreArgumentParser().parse_known_args(["execute"])
    else:
        try:
            self.options, _ = CoreArgumentParser().parse_known_args(args)
        except ParserError:
            try:
                # If a non-built-in command was used, we need to parse with a parser that
                # doesn't define the subparsers
                self.options, _ = manager_parser.parse_known_args(args)
            except ParserError as e:
                manager_parser.print_help()
                print("\nError: %s" % e.message)
                sys.exit(1)
    try:
        self.find_config(create=False)
    except:
        logger.start(level=self.options.loglevel.upper(), to_file=False)
        raise
    else:
        log_file = os.path.expanduser(self.options.logfile)
        # If an absolute path is not specified, use the config directory.
        if not os.path.isabs(log_file):
            log_file = os.path.join(self.config_base, log_file)

        logger.start(
            log_file, self.options.loglevel.upper(), to_console=not self.options.cron
        )

    manager = self

    log.debug("sys.defaultencoding: %s", sys.getdefaultencoding())
    log.debug("sys.getfilesystemencoding: %s", sys.getfilesystemencoding())
    log.debug("flexget detected io encoding: %s", io_encoding)
    log.debug(
        "os.path.supports_unicode_filenames: %s" % os.path.supports_unicode_filenames
    )
    if (
        codecs.lookup(sys.getfilesystemencoding()).name == "ascii"
        and not os.path.supports_unicode_filenames
    ):
        log.warning(
            "Your locale declares ascii as the filesystem encoding. Any plugins reading filenames from "
            "disk will not work properly for filenames containing non-ascii characters. Make sure your "
            "locale env variables are set up correctly for the environment which is launching FlexGet."
        )