# Buggy code
def copy_flow(part, scope, flow, master, state):
    """
    part: _c_ontent, _h_eaders+content, _u_rl
    scope: _a_ll, re_q_uest, re_s_ponse
    """
    data, err = copy_flow_format_data(part, scope, flow)

    if err:
        signals.status_message.send(message=err)
        return

    if not data:
        if scope == "q":
            signals.status_message.send(message="No request content to copy.")
        elif scope == "s":
            signals.status_message.send(message="No response content to copy.")
        else:
            signals.status_message.send(message="No contents to copy.")
        return

    try:
        master.add_event(str(len(data)))
        pyperclip.copy(data)
    except (RuntimeError, UnicodeDecodeError):

        def save(k):
            if k == "y":
                ask_save_path("Save data", data, master, state)

        signals.status_prompt_onekey.send(
            prompt="Cannot copy binary data to clipboard. Save as file?",
            keys=(
                ("yes", "y"),
                ("no", "n"),
            ),
            callback=save,
        )


# Traceback (AttributeError)
Traceback (most recent call last):?
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/libmproxy/console/__init__.py", line 457, in run
self.loop.run()
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/main_loop.py", line 375, in _run
self.event_loop.run()
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/main_loop.py", line 678, in run
self._loop()
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/main_loop.py", line 715, in _loop
self._watch_files[fd]()
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/raw_display.py", line 392, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/raw_display.py", line 492, in parse_input
callback(processed, processed_codes)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/main_loop.py", line 399, in _update
self.process_input(keys)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/main_loop.py", line 499, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/libmproxy/console/window.py", line 21, in keypress
k = super(self.__class__, self).keypress(size, k)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/urwid/container.py", line 1116, in keypress
return self.footer.keypress((maxcol,),key)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/libmproxy/console/statusbar.py", line 123, in keypress
return self.ab.keypress(*args, **kwargs)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/libmproxy/console/statusbar.py", line 80, in keypress
self.prompt_execute(k)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/libmproxy/console/statusbar.py", line 104, in prompt_execute
msg = p(txt, *args)
File "/home/yujie/envwanhuijie/local/lib/python2.7/site-packages/libmproxy/console/common.py", line 289, in copy_flow
pyperclip.copy(data)
AttributeError: 'bool' object has no attribute 'copy'

# Fixed code
def copy_flow(part, scope, flow, master, state):
    """
    part: _c_ontent, _h_eaders+content, _u_rl
    scope: _a_ll, re_q_uest, re_s_ponse
    """
    data, err = copy_flow_format_data(part, scope, flow)

    if err:
        signals.status_message.send(message=err)
        return

    if not data:
        if scope == "q":
            signals.status_message.send(message="No request content to copy.")
        elif scope == "s":
            signals.status_message.send(message="No response content to copy.")
        else:
            signals.status_message.send(message="No contents to copy.")
        return

    try:
        master.add_event(str(len(data)))
        pyperclip.copy(data)
    except (RuntimeError, UnicodeDecodeError, AttributeError):

        def save(k):
            if k == "y":
                ask_save_path("Save data", data, master, state)

        signals.status_prompt_onekey.send(
            prompt="Cannot copy data to clipboard. Save as file?",
            keys=(
                ("yes", "y"),
                ("no", "n"),
            ),
            callback=save,
        )