class open(object):
    """Wrapper providing key part of Python 3 open() interface.

    From IPython's py3compat.py module. License: BSD.
    """
    def __init__(self, fname, mode="r", encoding="utf-8"):
        self.f = orig_open(fname, mode)
        self.enc = encoding

    def write(self, s):
        return self.f.write(s.encode(self.enc))

    def read(self, size=-1):
        return self.f.read(size).decode(self.enc)

    def close(self):
        return self.f.close()

    def __enter__(self):
        return self

    def __exit__(self, etype, value, traceback):
        self.f.close()


@@ -1,8 +1,205 @@
+%22%22%22%0AA substitute for the Python 3 open() function.%0A%0ANote that io.open() is more complete but maybe slower. Even so, the%0Acompleteness may be a better default. TODO: compare these%0A%22%22%22%0A%0Aopen_ = open%0A%0A
 class op
@@ -417,17 +417,13 @@
 f = 
-orig_
 open
+_
 (fna

Update new open() function docs (and fix bug)