File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -875,8 +875,18 @@ parsestr(s)
875875 int c ;
876876 int first = * s ;
877877 int quote = first ;
878- if (isalpha (quote ) || quote == '_' )
879- quote = * ++ s ;
878+ int rawmode = 0 ;
879+ int unicode = 0 ;
880+ if (isalpha (quote ) || quote == '_' ) {
881+ if (quote == 'u' || quote == 'U' ) {
882+ quote = * ++ s ;
883+ unicode = 1 ;
884+ }
885+ if (quote == 'r' || quote == 'R' ) {
886+ quote = * ++ s ;
887+ rawmode = 1 ;
888+ }
889+ }
880890 if (quote != '\'' && quote != '\"' ) {
881891 PyErr_BadInternalCall ();
882892 return NULL ;
@@ -895,8 +905,17 @@ parsestr(s)
895905 return NULL ;
896906 }
897907 }
898- if (first != quote || strchr (s , '\\' ) == NULL )
908+ if (unicode ) {
909+ if (rawmode )
910+ return PyUnicode_DecodeRawUnicodeEscape (
911+ s , len , NULL );
912+ else
913+ return PyUnicode_DecodeUnicodeEscape (
914+ s , len , NULL );
915+ }
916+ else if (rawmode || strchr (s , '\\' ) == NULL ) {
899917 return PyString_FromStringAndSize (s , len );
918+ }
900919 v = PyString_FromStringAndSize ((char * )NULL , len );
901920 p = buf = PyString_AsString (v );
902921 end = s + len ;
You can’t perform that action at this time.
0 commit comments