Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7eb46a

Browse files
authored
Merge pull requestRustPython#4384 from harupy/parse-formatted-value
Fix the location of `FormattedValue`
2 parents2c8af12 +d392694 commitb7eb46a

File tree

25 files changed

+2197
-381
lines changed

25 files changed

+2197
-381
lines changed

‎Lib/test/test_ast.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,16 +2031,12 @@ def test_suites(self):
20312031
self._check_content(s,try_stmt.body[0],'raise RuntimeError')
20322032
self._check_content(s,try_stmt.handlers[0].type,'TypeError')
20332033

2034-
# TODO: RUSTPYTHON
2035-
@unittest.expectedFailure
20362034
deftest_fstring(self):
20372035
s='x = f"abc {x + y} abc"'
20382036
fstr=self._parse_value(s)
20392037
binop=fstr.values[1].value
20402038
self._check_content(s,binop,'x + y')
20412039

2042-
# TODO: RUSTPYTHON
2043-
@unittest.expectedFailure
20442040
deftest_fstring_multi_line(self):
20452041
s=dedent('''
20462042
f"""Some multi-line text.

‎Lib/test/test_fstring.py‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ def __call__(self):
8383
# Make sure x was called.
8484
self.assertTrue(x.called)
8585

86-
# TODO: RUSTPYTHON - binop lineno
87-
@unittest.expectedFailure
8886
deftest_ast_line_numbers(self):
8987
expr="""
9088
a = 10
@@ -116,8 +114,6 @@ def test_ast_line_numbers(self):
116114
self.assertEqual(binop.left.col_offset,3)
117115
self.assertEqual(binop.right.col_offset,7)
118116

119-
# TODO: RUSTPYTHON binops lineno and col_offset
120-
@unittest.expectedFailure
121117
deftest_ast_line_numbers_multiple_formattedvalues(self):
122118
expr="""
123119
f'no formatted values'
@@ -170,8 +166,6 @@ def test_ast_line_numbers_multiple_formattedvalues(self):
170166
self.assertEqual(binop2.left.col_offset,23)
171167
self.assertEqual(binop2.right.col_offset,27)
172168

173-
# TODO: RUSTPYTHON binops lineno and col_offset
174-
@unittest.expectedFailure
175169
deftest_ast_line_numbers_nested(self):
176170
expr="""
177171
a = 10
@@ -217,8 +211,6 @@ def test_ast_line_numbers_nested(self):
217211
self.assertEqual(call.lineno,3)
218212
self.assertEqual(call.col_offset,11)
219213

220-
# TODO: RUSTPYTHON binops lineno and col_offset
221-
@unittest.expectedFailure
222214
deftest_ast_line_numbers_duplicate_expression(self):
223215
expr="""
224216
a = 10
@@ -285,8 +277,6 @@ def test_ast_line_numbers_duplicate_expression(self):
285277
self.assertEqual(binop.left.col_offset,23)
286278
self.assertEqual(binop.right.col_offset,27)
287279

288-
# TODO: RUSTPYTHON err col_offset and missing end_* attributes
289-
@unittest.expectedFailure
290280
deftest_ast_numbers_fstring_with_formatting(self):
291281

292282
t=ast.parse('f"Here is that pesky {xxx:.3f} again"')
@@ -310,8 +300,6 @@ def test_ast_numbers_fstring_with_formatting(self):
310300
self.assertEqual(name.col_offset,22)
311301
self.assertEqual(name.end_col_offset,25)
312302

313-
# TODO: RUSTPYTHON col_offset and binop lineno and col_offset
314-
@unittest.expectedFailure
315303
deftest_ast_line_numbers_multiline_fstring(self):
316304
# See bpo-30465 for details.
317305
expr="""
@@ -391,8 +379,6 @@ def test_ast_line_numbers_multiline_fstring(self):
391379
self.assertEqual(t.body[0].value.values[1].value.col_offset,11)
392380
self.assertEqual(t.body[0].value.values[1].value.end_col_offset,16)
393381

394-
# TODO: RUSTPYTHON lineno, col_offset, end*
395-
@unittest.expectedFailure
396382
deftest_ast_line_numbers_with_parentheses(self):
397383
expr="""
398384
x = (
@@ -470,8 +456,6 @@ def test_ast_compile_time_concat(self):
470456
exec(c)
471457
self.assertEqual(x[0],'foo3')
472458

473-
# TODO: RUSTPYTHON
474-
@unittest.expectedFailure
475459
deftest_compile_time_concat_errors(self):
476460
self.assertAllRaise(SyntaxError,
477461
'cannot mix bytes and nonbytes literals',
@@ -1083,8 +1067,6 @@ def test_del(self):
10831067
"del '' f''",
10841068
])
10851069

1086-
# TODO: RUSTPYTHON
1087-
@unittest.expectedFailure
10881070
deftest_mismatched_braces(self):
10891071
self.assertAllRaise(SyntaxError,"f-string: single '}' is not allowed",
10901072
["f'{{}'",

‎compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__nested_double_async_with.snap‎

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎compiler/parser/python.lalrpop‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,18 +1353,11 @@ OneOrMore<T>: Vec<T> = {
13531353
};
13541354

13551355
Constant: ast::Constant = {
1356-
<b:bytes+> => ast::Constant::Bytes(b.into_iter().flatten().collect()),
13571356
<value:int> => ast::Constant::Int(value),
13581357
<value:float> => ast::Constant::Float(value),
13591358
<s:complex> => ast::Constant::Complex { real: s.0, imag: s.1 },
13601359
};
13611360

1362-
Bytes: Vec<u8> = {
1363-
<s:bytes+> => {
1364-
s.into_iter().flatten().collect::<Vec<u8>>()
1365-
},
1366-
};
1367-
13681361
Identifier: String = <s:name> => s;
13691362

13701363
// Hook external lexer:
@@ -1462,8 +1455,11 @@ extern {
14621455
int => lexer::Tok::Int { value: <BigInt> },
14631456
float => lexer::Tok::Float { value: <f64> },
14641457
complex => lexer::Tok::Complex { real: <f64>, imag: <f64> },
1465-
string => lexer::Tok::String { value: <String>, kind: <StringKind> },
1466-
bytes => lexer::Tok::Bytes { value: <Vec<u8>> },
1458+
string => lexer::Tok::String {
1459+
value: <String>,
1460+
kind: <StringKind>,
1461+
triple_quoted: <bool>
1462+
},
14671463
name => lexer::Tok::Name { name: <String> },
14681464
"\n" => lexer::Tok::Newline,
14691465
";" => lexer::Tok::Semi,

‎compiler/parser/src/error.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ pub enum FStringErrorType {
101101
UnterminatedString,
102102
}
103103

104+
implFStringErrorType{
105+
pubfnto_lexical_error(self,location:Location) ->LexicalError{
106+
LexicalError{
107+
error:LexicalErrorType::FStringError(self),
108+
location,
109+
}
110+
}
111+
}
112+
104113
impl fmt::DisplayforFStringErrorType{
105114
fnfmt(&self,f:&mut fmt::Formatter) -> fmt::Result{
106115
matchself{

‎compiler/parser/src/fstring.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// We no longer need this file
12
useself::FStringErrorType::*;
23
usecrate::{
34
ast::{Constant,ConversionFlag,Expr,ExprKind,Location},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp