code: def RFC3156_canonicalize(text):
      
      text = re.sub("\r?\n", "\r\n", text)
      text = re.sub("^From ", "From=20", text, flags=re.MULTILINE)
      return text
docs: Canonicalizes plain text (MIME-encoded usually) according to RFC3156.
  
      This function works as follows (in that order):
  
      1. Convert all line endings to \\\\r\\\\n (DOS line endings).
      2. Encode all occurrences of "From " at the beginning of a line
         to "From=20" in order to prevent other mail programs to replace
         this with "> From" (to avoid MBox conflicts) and thus invalidate
         the signature.
  
      :param text: text to canonicalize (already encoded as quoted-printable)
      :rtype: str