diff -r d75393f1eb8d src/org/python/modules/time/Time.java --- a/src/org/python/modules/time/Time.java Sat Jun 04 18:00:50 2011 -0700 +++ b/src/org/python/modules/time/Time.java Thu Jun 09 02:42:05 2011 +0200 @@ -780,6 +780,11 @@ builder.append("'"); inQuote = needsQuote; } + if (charAt == '\'') { + // a single quote always needs to be escaped, regardless + // whether already in a quote or not + builder.append("'"); + } builder.append(charAt); continue; } else if (inQuote) {