For 3.x, the "backslashreplace" error handling is plugged on the "write" method.

Recorded merge of revisions 78488 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78488 | florent.xicluna | 2010-02-27 14:31:23 +0100 (sam, 27 fév 2010) | 2 lines

  Issue #1729305: Fix doctest to handle encode error with "backslashreplace".  It fixes #7667 too.
........
diff --git a/Misc/NEWS b/Misc/NEWS
index a870564..ee43e63 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -260,6 +260,8 @@
 Library
 -------
 
+- Issue #1729305: Fix doctest to handle encode error with "backslashreplace".
+
 - Issue #691291: codecs.open() should not convert end of lines on reading and
   writing.