summaryrefslogtreecommitdiff
path: root/Python/ast.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-12 22:46:19 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-12 22:46:19 +0100
commite2360e9f21daa7f630fc6cd6a48938c2e4e1f845 (patch)
tree3cd51f0863e61cd79dba77eada341b2d26a6ca5c /Python/ast.c
parente8d39bb184f94f6a2f954863d1f05acc69d84ca0 (diff)
downloadcpython-e2360e9f21daa7f630fc6cd6a48938c2e4e1f845.tar.gz
Issue #13748: Raw bytes literals can now be written with the `rb` prefix as well as `br`.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 48aef4815d..110754bfd4 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -3744,13 +3744,18 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
int rawmode = 0;
int need_encoding;
if (isalpha(quote)) {
- if (quote == 'b' || quote == 'B') {
- quote = *++s;
- *bytesmode = 1;
- }
- if (quote == 'r' || quote == 'R') {
- quote = *++s;
- rawmode = 1;
+ while (!*bytesmode || !rawmode) {
+ if (quote == 'b' || quote == 'B') {
+ quote = *++s;
+ *bytesmode = 1;
+ }
+ else if (quote == 'r' || quote == 'R') {
+ quote = *++s;
+ rawmode = 1;
+ }
+ else {
+ break;
+ }
}
}
if (quote != '\'' && quote != '\"') {