diff --git a/Lib/_codecs.py b/Lib/_codecs.py index 807218687..f9b8f17b8 100644 --- a/Lib/_codecs.py +++ b/Lib/_codecs.py @@ -1610,8 +1610,8 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): while (pos < len(s)): ch = s[pos] #/* Non-escape characters are interpreted as Unicode ordinals */ - if (ch != '\\'): - p += chr(ord(ch)) + if (ch != ord('\\')): + p.append(chr(ch)) pos += 1 continue startinpos = pos @@ -1619,20 +1619,20 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): ## backslashes is odd */ bs = pos while pos < size: - if (s[pos] != '\\'): + if (s[pos] != ord('\\')): break - p += chr(ord(s[pos])) + p.append(chr(s[pos])) pos += 1 if (((pos - bs) & 1) == 0 or pos >= size or - (s[pos] != 'u' and s[pos] != 'U')) : - p += chr(ord(s[pos])) + (s[pos] != ord('u') and s[pos] != ord('U'))) : + p.append(chr(s[pos])) pos += 1 continue p.pop(-1) - if s[pos] == 'u': + if s[pos] == ord('u'): count = 4 else: count = 8 @@ -1646,7 +1646,7 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): res = unicode_call_errorhandler( errors, "rawunicodeescape", "truncated \\uXXXX", s, size, pos, pos+count) - p += res[0] + p.append(res[0]) pos = res[1] else: #ifndef Py_UNICODE_WIDE @@ -1656,9 +1656,9 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): errors, "rawunicodeescape", "\\Uxxxxxxxx out of range", s, size, pos, pos+1) pos = res[1] - p += res[0] + p.append(res[0]) else: - p += chr(x) + p.append(chr(x)) pos += count else: if (x > 0x10000): @@ -1666,11 +1666,11 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): errors, "rawunicodeescape", "\\Uxxxxxxxx out of range", s, size, pos, pos+1) pos = res[1] - p += res[0] + p.append(res[0]) #endif else: - p += chr(x) + p.append(chr(x)) pos += count return p diff --git a/Lib/pickle.py b/Lib/pickle.py index c8370c9f7..7ba419394 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -201,7 +201,10 @@ class _Framer: if self.current_frame: f = self.current_frame if f.tell() >= self._FRAME_SIZE_TARGET or force: - with f.getbuffer() as data: + # XXX RUSTPYTHON TODO: memoryview + BytesIO.getbuffer() + # with f.getbuffer() as data: + data = f.getvalue() + if True: n = len(data) write = self.file_write write(FRAME) diff --git a/compiler/src/compile.rs b/compiler/src/compile.rs index 26eca75a4..a3b758443 100644 --- a/compiler/src/compile.rs +++ b/compiler/src/compile.rs @@ -479,7 +479,9 @@ impl Compiler { self.compile_statements(body)?; - for end_label in end_labels { + // sort of "stack up" the layers of with blocks: + // with a, b: body -> start_with(a) start_with(b) body() end_with(b) end_with(a) + for end_label in end_labels.into_iter().rev() { self.emit(Instruction::PopBlock); self.emit(Instruction::EnterFinally); self.set_label(end_label); diff --git a/parser/src/fstring.rs b/parser/src/fstring.rs index 4540c005d..7af0cb404 100644 --- a/parser/src/fstring.rs +++ b/parser/src/fstring.rs @@ -81,8 +81,7 @@ impl<'a> FStringParser<'a> { // match a python 3.8 self documenting expression // format '{' PYTHON_EXPRESSION '=' FORMAT_SPECIFIER? '}' - '=' if self.chars.peek() != Some(&'=') => { - // check for delims empty? + '=' if self.chars.peek() != Some(&'=') && delims.is_empty() => { pred_expression_text = expression.to_string(); // safe expression before = to print it } diff --git a/src/main.rs b/src/main.rs index 55a7ef724..80639aae6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,6 +169,12 @@ fn parse_arguments<'a>(app: App<'a, '_>) -> ArgMatches<'a> { .short("X") .takes_value(true) .help("set implementation-specific option"), + ) + .arg( + Arg::with_name("warning-control") + .short("W") + .takes_value(true) + .help("warning control; arg is action:message:category:module:lineno"), ); #[cfg(feature = "flame-it")] let app = app diff --git a/vm/src/obj/objtype.rs b/vm/src/obj/objtype.rs index 39c752675..5bcabb47b 100644 --- a/vm/src/obj/objtype.rs +++ b/vm/src/obj/objtype.rs @@ -171,7 +171,10 @@ impl PyClassRef { ], ) } else { - Err(vm.new_attribute_error(format!("{} has no attribute '{}'", self, name))) + Err(vm.new_attribute_error(format!( + "type object '{}' has no attribute '{}'", + self, name + ))) } } diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 9363f5bae..7f4c53e9f 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -1324,6 +1324,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef { //StringIO: in-memory text let string_io = py_class!(ctx, "StringIO", text_io_base.clone(), { + "__module__" => ctx.new_str("_io"), (slot new) => string_io_new, "seek" => ctx.new_method(PyStringIORef::seek), "seekable" => ctx.new_method(PyStringIORef::seekable),