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()



open_ = open

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 = 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()


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

+ 
+ open_ = open
+ 
  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.f = 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()
  
  
Update new open() function docs (and fix bug)
## Code Before:
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()


## Instruction:
Update new open() function docs (and fix bug)
## Code After:

open_ = open

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 = 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()

