Skip to content

Commit 1385c06

Browse files
committed
Fix some minor things required for unittest
1 parent f12a78b commit 1385c06

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

Lib/_codecs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,29 +1610,29 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors):
16101610
while (pos < len(s)):
16111611
ch = s[pos]
16121612
#/* Non-escape characters are interpreted as Unicode ordinals */
1613-
if (ch != '\\'):
1614-
p += chr(ord(ch))
1613+
if (ch != ord('\\')):
1614+
p.append(chr(ch))
16151615
pos += 1
16161616
continue
16171617
startinpos = pos
16181618
## /* \u-escapes are only interpreted iff the number of leading
16191619
## backslashes is odd */
16201620
bs = pos
16211621
while pos < size:
1622-
if (s[pos] != '\\'):
1622+
if (s[pos] != ord('\\')):
16231623
break
1624-
p += chr(ord(s[pos]))
1624+
p.append(chr(s[pos]))
16251625
pos += 1
16261626

16271627
if (((pos - bs) & 1) == 0 or
16281628
pos >= size or
1629-
(s[pos] != 'u' and s[pos] != 'U')) :
1630-
p += chr(ord(s[pos]))
1629+
(s[pos] != ord('u') and s[pos] != ord('U'))) :
1630+
p.append(chr(s[pos]))
16311631
pos += 1
16321632
continue
16331633

16341634
p.pop(-1)
1635-
if s[pos] == 'u':
1635+
if s[pos] == ord('u'):
16361636
count = 4
16371637
else:
16381638
count = 8
@@ -1646,7 +1646,7 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors):
16461646
res = unicode_call_errorhandler(
16471647
errors, "rawunicodeescape", "truncated \\uXXXX",
16481648
s, size, pos, pos+count)
1649-
p += res[0]
1649+
p.append(res[0])
16501650
pos = res[1]
16511651
else:
16521652
#ifndef Py_UNICODE_WIDE
@@ -1656,21 +1656,21 @@ def PyUnicode_DecodeRawUnicodeEscape(s, size, errors):
16561656
errors, "rawunicodeescape", "\\Uxxxxxxxx out of range",
16571657
s, size, pos, pos+1)
16581658
pos = res[1]
1659-
p += res[0]
1659+
p.append(res[0])
16601660
else:
1661-
p += chr(x)
1661+
p.append(chr(x))
16621662
pos += count
16631663
else:
16641664
if (x > 0x10000):
16651665
res = unicode_call_errorhandler(
16661666
errors, "rawunicodeescape", "\\Uxxxxxxxx out of range",
16671667
s, size, pos, pos+1)
16681668
pos = res[1]
1669-
p += res[0]
1669+
p.append(res[0])
16701670

16711671
#endif
16721672
else:
1673-
p += chr(x)
1673+
p.append(chr(x))
16741674
pos += count
16751675

16761676
return p

Lib/pickle.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ def commit_frame(self, force=False):
201201
if self.current_frame:
202202
f = self.current_frame
203203
if f.tell() >= self._FRAME_SIZE_TARGET or force:
204-
with f.getbuffer() as data:
204+
# XXX RUSTPYTHON TODO: memoryview + BytesIO.getbuffer()
205+
# with f.getbuffer() as data:
206+
data = f.getvalue()
207+
if True:
205208
n = len(data)
206209
write = self.file_write
207210
write(FRAME)

compiler/src/compile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ impl<O: OutputStream> Compiler<O> {
479479

480480
self.compile_statements(body)?;
481481

482-
for end_label in end_labels {
482+
// sort of "stack up" the layers of with blocks:
483+
// with a, b: body -> start_with(a) start_with(b) body() end_with(b) end_with(a)
484+
for end_label in end_labels.into_iter().rev() {
483485
self.emit(Instruction::PopBlock);
484486
self.emit(Instruction::EnterFinally);
485487
self.set_label(end_label);

parser/src/fstring.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ impl<'a> FStringParser<'a> {
8181

8282
// match a python 3.8 self documenting expression
8383
// format '{' PYTHON_EXPRESSION '=' FORMAT_SPECIFIER? '}'
84-
'=' if self.chars.peek() != Some(&'=') => {
85-
// check for delims empty?
84+
'=' if self.chars.peek() != Some(&'=') && delims.is_empty() => {
8685
pred_expression_text = expression.to_string(); // safe expression before = to print it
8786
}
8887

src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ fn parse_arguments<'a>(app: App<'a, '_>) -> ArgMatches<'a> {
169169
.short("X")
170170
.takes_value(true)
171171
.help("set implementation-specific option"),
172+
)
173+
.arg(
174+
Arg::with_name("warning-control")
175+
.short("W")
176+
.takes_value(true)
177+
.help("warning control; arg is action:message:category:module:lineno"),
172178
);
173179
#[cfg(feature = "flame-it")]
174180
let app = app

vm/src/obj/objtype.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ impl PyClassRef {
171171
],
172172
)
173173
} else {
174-
Err(vm.new_attribute_error(format!("{} has no attribute '{}'", self, name)))
174+
Err(vm.new_attribute_error(format!(
175+
"type object '{}' has no attribute '{}'",
176+
self, name
177+
)))
175178
}
176179
}
177180

vm/src/stdlib/io.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
13241324

13251325
//StringIO: in-memory text
13261326
let string_io = py_class!(ctx, "StringIO", text_io_base.clone(), {
1327+
"__module__" => ctx.new_str("_io"),
13271328
(slot new) => string_io_new,
13281329
"seek" => ctx.new_method(PyStringIORef::seek),
13291330
"seekable" => ctx.new_method(PyStringIORef::seekable),

0 commit comments

Comments
 (0)