Author rhansen
Recipients ezio.melotti, lemburg, rhansen
Date 2010-01-03.23:13:05
SpamBayes Score 1.42167e-10
Marked as misclassified No
Message-id <1262560387.27.0.249041630869.issue7615@psf.upfronthosting.co.za>
In-reply-to
Content
> If we change this, the encoder should quote both single and double 
> quotes - simply because it is not known whether the literal 
> will use single or double quotes.

Or document that single quotes are always escaped so that the user knows he/she can safely use u''.  I'm not sure if there is a use case where both would *need* to be escaped, and escaping both has a size penalty.

I've attached an untested patch that escapes both.

If both are escaped, then the behavior of the string_escape codec should also be changed for consistency (it only escapes single quotes).

> The raw_unicode_escape codec would have to be fixed as well.

I'm not sure there's anything to fix.  Adding backslashes to quotes in raw strings changes the value of the string -- the backslashes prevent the quotes from ending the string literal, but they are not removed when the raw literal is evaluated.

Perhaps raw_unicode_escape should be "fixed" by raising an exception when it contains any quotes.
History
Date User Action Args
2010-01-03 23:13:08rhansensetrecipients: + rhansen, lemburg, ezio.melotti
2010-01-03 23:13:07rhansensetmessageid: <1262560387.27.0.249041630869.issue7615@psf.upfronthosting.co.za>
2010-01-03 23:13:06rhansenlinkissue7615 messages
2010-01-03 23:13:05rhansencreate