code: def escape(cls, s):
          
          rv = escape(s)
          if rv.__class__ is not cls:
              return cls(rv)
          return rv
docs: Escape a string. Calls :func:`escape` and ensures that for
          subclasses the correct type is returned.