diff Objects/stringobject.c @ 25173:f4e9f09df4f2 legacy-trunk

Fix escaping of non-ASCII characters.
author Martin v. Löwis <martin@v.loewis.de>
date Mon, 09 Sep 2002 06:17:05 +0000
parents bc590beadf0b
children 8d751b62ecc4
line wrap: on
line diff
--- a/Objects/stringobject.c	Sun Sep 08 22:26:13 2002 +0000
+++ b/Objects/stringobject.c	Mon Sep 09 06:17:05 2002 +0000
@@ -541,6 +541,7 @@
 	end = s + len;
 	while (s < end) {
 		if (*s != '\\') {
+		  non_esc:
 #ifdef Py_USING_UNICODE
 			if (recode_encoding && (*s & 0x80)) {
 				PyObject *u, *w;
@@ -656,8 +657,9 @@
 #endif
 		default:
 			*p++ = '\\';
-			*p++ = s[-1];
-			break;
+			s--;
+			goto non_esc; /* an arbitry number of unescaped
+					 UTF-8 bytes may follow. */
 		}
 	}
 	if (p-buf < newlen)