Fix some minor things required for unittest

This commit is contained in:
Noah committed 2020-08-12 16:03:20 -05:00
1 parent f12a78ba23
commit 1385c06e25
7 files changed
+31 -17

No files matched your search

+12 -12
View File
@@ -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
+4 -1
View File
@@ -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)
+3 -1
View File
@@ -479,7 +479,9 @@ impl<O: OutputStream> Compiler<O> {
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);
+1 -2
View File
@@ -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
}
+6
View File
@@ -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
+4 -1
View File
@@ -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
)))
}
}
+1
View File
@@ -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),