@@ -35,7 +35,7 @@ static stmt_ty ast_for_classdef(struct compiling *, const node *, asdl_seq *);
3535static expr_ty ast_for_call (struct compiling * , const node * , expr_ty );
3636
3737static PyObject * parsenumber (const char * );
38- static PyObject * parsestr (const node * n , const char * encoding , int * bytesmode );
38+ static PyObject * parsestr (struct compiling * , const node * n , int * bytesmode );
3939static PyObject * parsestrplus (struct compiling * , const node * n ,
4040 int * bytesmode );
4141
@@ -3191,14 +3191,13 @@ decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
31913191 * parsestr parses it, and returns the decoded Python string object.
31923192 */
31933193static PyObject *
3194- parsestr (const node * n , const char * encoding , int * bytesmode )
3194+ parsestr (struct compiling * c , const node * n , int * bytesmode )
31953195{
31963196 size_t len ;
31973197 const char * s = STR (n );
31983198 int quote = Py_CHARMASK (* s );
31993199 int rawmode = 0 ;
32003200 int need_encoding ;
3201-
32023201 if (isalpha (quote )) {
32033202 if (quote == 'b' || quote == 'B' ) {
32043203 quote = * ++ s ;
@@ -3233,7 +3232,7 @@ parsestr(const node *n, const char *encoding, int *bytesmode)
32333232 }
32343233 }
32353234 if (!* bytesmode && !rawmode ) {
3236- return decode_unicode (s , len , rawmode , encoding );
3235+ return decode_unicode (s , len , rawmode , c -> c_encoding );
32373236 }
32383237 if (* bytesmode ) {
32393238 /* Disallow non-ascii characters (but not escapes) */
@@ -3246,28 +3245,27 @@ parsestr(const node *n, const char *encoding, int *bytesmode)
32463245 }
32473246 }
32483247 }
3249- need_encoding = (!* bytesmode && encoding != NULL &&
3250- strcmp (encoding , "utf-8" ) != 0 &&
3251- strcmp (encoding , "iso-8859-1" ) != 0 );
3248+ need_encoding = (!* bytesmode && c -> c_encoding != NULL &&
3249+ strcmp (c -> c_encoding , "utf-8" ) != 0 &&
3250+ strcmp (c -> c_encoding , "iso-8859-1" ) != 0 );
32523251 if (rawmode || strchr (s , '\\' ) == NULL ) {
32533252 if (need_encoding ) {
32543253 PyObject * v , * u = PyUnicode_DecodeUTF8 (s , len , NULL );
32553254 if (u == NULL || !* bytesmode )
32563255 return u ;
3257- v = PyUnicode_AsEncodedString (u , encoding , NULL );
3256+ v = PyUnicode_AsEncodedString (u , c -> c_encoding , NULL );
32583257 Py_DECREF (u );
32593258 return v ;
32603259 } else if (* bytesmode ) {
32613260 return PyString_FromStringAndSize (s , len );
3262- } else if (strcmp (encoding , "utf-8" ) == 0 ) {
3261+ } else if (strcmp (c -> c_encoding , "utf-8" ) == 0 ) {
32633262 return PyUnicode_FromStringAndSize (s , len );
32643263 } else {
32653264 return PyUnicode_DecodeLatin1 (s , len , NULL );
32663265 }
32673266 }
3268-
32693267 return PyString_DecodeEscape (s , len , NULL , 1 ,
3270- need_encoding ? encoding : NULL );
3268+ need_encoding ? c -> c_encoding : NULL );
32713269}
32723270
32733271/* Build a Python string object out of a STRING+ atom. This takes care of
@@ -3280,13 +3278,13 @@ parsestrplus(struct compiling *c, const node *n, int *bytesmode)
32803278 PyObject * v ;
32813279 int i ;
32823280 REQ (CHILD (n , 0 ), STRING );
3283- v = parsestr (CHILD (n , 0 ), c -> c_encoding , bytesmode );
3281+ v = parsestr (c , CHILD (n , 0 ), bytesmode );
32843282 if (v != NULL ) {
32853283 /* String literal concatenation */
32863284 for (i = 1 ; i < NCH (n ); i ++ ) {
32873285 PyObject * s ;
32883286 int subbm = 0 ;
3289- s = parsestr (CHILD (n , i ), c -> c_encoding , & subbm );
3287+ s = parsestr (c , CHILD (n , i ), & subbm );
32903288 if (s == NULL )
32913289 goto onError ;
32923290 if (* bytesmode != subbm ) {
0 commit comments