# Buggy code
def attr_matches(self, text):
    """Compute matches when text contains a dot.

    Assuming the text is of the form NAME.NAME....[NAME], and is
    evaluatable in self.namespace or self.global_namespace, it will be
    evaluated and its attributes (as revealed by dir()) are used as
    possible completions.  (For class instances, class members are are
    also considered.)

    WARNING: this can still invoke arbitrary C code, if an object
    with a __getattr__ hook is evaluated.

    """

    # io.rprint('Completer->attr_matches, txt=%r' % text) # dbg
    # Another option, seems to work great. Catches things like ''.<tab>
    m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)

    if m:
        expr, attr = m.group(1, 3)
    elif self.greedy:
        m2 = re.match(r"(.+)\.(\w*)$", self.line_buffer)
        if not m2:
            return []
        expr, attr = m2.group(1, 2)
    else:
        return []

    try:
        obj = eval(expr, self.namespace)
    except:
        try:
            obj = eval(expr, self.global_namespace)
        except:
            return []

    if self.limit_to__all__ and hasattr(obj, "__all__"):
        words = get__all__entries(obj)
    else:
        words = dir2(obj)

    try:
        words = generics.complete_object(obj, words)
    except TryNext:
        pass
    except Exception:
        # Silence errors from completion function
        # raise # dbg
        pass
    # Build match list to return
    n = len(attr)
    res = ["%s.%s" % (expr, w) for w in words if w[:n] == attr]
    return res


# Traceback (TypeError)
Python 2.7.11+ (default, Mar 30 2016, 21:00:42)
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: dException in thread Thread-7:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interface.py", line 742, in run
completions = list(buffer.completer.get_completions(document, complete_event))
File "/home/bwillar0/projects/python/ipython/IPython/terminal/ptshell.py", line 55, in gets
m = unicodedata.normalize('NFC', m)
TypeError: normalize() argument 2 must be unicode, not str

# Fixed code
def attr_matches(self, text):
    """Compute matches when text contains a dot.

    Assuming the text is of the form NAME.NAME....[NAME], and is
    evaluatable in self.namespace or self.global_namespace, it will be
    evaluated and its attributes (as revealed by dir()) are used as
    possible completions.  (For class instances, class members are are
    also considered.)

    WARNING: this can still invoke arbitrary C code, if an object
    with a __getattr__ hook is evaluated.

    """

    # io.rprint('Completer->attr_matches, txt=%r' % text) # dbg
    # Another option, seems to work great. Catches things like ''.<tab>
    m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)

    if m:
        expr, attr = m.group(1, 3)
    elif self.greedy:
        m2 = re.match(r"(.+)\.(\w*)$", self.line_buffer)
        if not m2:
            return []
        expr, attr = m2.group(1, 2)
    else:
        return []

    try:
        obj = eval(expr, self.namespace)
    except:
        try:
            obj = eval(expr, self.global_namespace)
        except:
            return []

    if self.limit_to__all__ and hasattr(obj, "__all__"):
        words = get__all__entries(obj)
    else:
        words = dir2(obj)

    try:
        words = generics.complete_object(obj, words)
    except TryNext:
        pass
    except Exception:
        # Silence errors from completion function
        # raise # dbg
        pass
    # Build match list to return
    n = len(attr)
    return ["%s.%s" % (expr, w) for w in words if w[:n] == attr]