docs: def to_bytes(self, obj, encoding=None):
          """
          Converts the given resource to bytes representation in the encoding
          specified by :param:`encoding` and returns it.
          """
          if encoding is None:
              encoding = self.encoding
          text = self.to_string(obj)
          return bytes_(text, encoding=self.encoding)