| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,12 @@ Library | |||
| 28 | 28 | - Issue #14127 and #10148: shutil.copystat now preserves exact mtime and atime | |
| 29 | 29 | on filesystems providing nanosecond resolution. | |
| 30 | 30 | ||
| 31 | + Tools/Demos | ||
| 32 | + ----------- | ||
| 33 | + | ||
| 34 | + - Issue #14965: Bring Tools/parser/unparse.py support up to date with | ||
| 35 | + the Python 3.3 Grammar. | ||
| 36 | + | ||
| 31 | 37 | ||
| 32 | 38 | What's New in Python 3.3.0 Alpha 3? | |
| 33 | 39 | =================================== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,6 +93,21 @@ class Foo: pass | |||
| 93 | 93 | suite5 | |
| 94 | 94 | """ | |
| 95 | 95 | ||
| 96 | + with_simple = """\ | ||
| 97 | + with f(): | ||
| 98 | + suite1 | ||
| 99 | + """ | ||
| 100 | + | ||
| 101 | + with_as = """\ | ||
| 102 | + with f() as x: | ||
| 103 | + suite1 | ||
| 104 | + """ | ||
| 105 | + | ||
| 106 | + with_two_items = """\ | ||
| 107 | + with f() as x, g() as y: | ||
| 108 | + suite1 | ||
| 109 | + """ | ||
| 110 | + | ||
| 96 | 111 | class ASTTestCase(unittest.TestCase): | |
| 97 | 112 | def assertASTEqual(self, ast1, ast2): | |
| 98 | 113 | self.assertEqual(ast.dump(ast1), ast.dump(ast2)) | |
@@ -209,6 +224,22 @@ def test_elifs(self): | |||
| 209 | 224 | def test_try_except_finally(self): | |
| 210 | 225 | self.check_roundtrip(try_except_finally) | |
| 211 | 226 | ||
| 227 | + def test_starred_assignment(self): | ||
| 228 | + self.check_roundtrip("a, *b, c = seq") | ||
| 229 | + self.check_roundtrip("a, (*b, c) = seq") | ||
| 230 | + self.check_roundtrip("a, *b[0], c = seq") | ||
| 231 | + self.check_roundtrip("a, *(b, c) = seq") | ||
| 232 | + | ||
| 233 | + def test_with_simple(self): | ||
| 234 | + self.check_roundtrip(with_simple) | ||
| 235 | + | ||
| 236 | + def test_with_as(self): | ||
| 237 | + self.check_roundtrip(with_as) | ||
| 238 | + | ||
| 239 | + def test_with_two_items(self): | ||
| 240 | + self.check_roundtrip(with_two_items) | ||
| 241 | + | ||
| 242 | + | ||
| 212 | 243 | class DirectoryTestCase(ASTTestCase): | |
| 213 | 244 | """Test roundtrip behaviour on all files in Lib and Lib/test.""" | |
| 214 | 245 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,6 +147,14 @@ def _Yield(self, t): | |||
| 147 | 147 | self.dispatch(t.value) | |
| 148 | 148 | self.write(")") | |
| 149 | 149 | ||
| 150 | + def _YieldFrom(self, t): | ||
| 151 | + self.write("(") | ||
| 152 | + self.write("yield from") | ||
| 153 | + if t.value: | ||
| 154 | + self.write(" ") | ||
| 155 | + self.dispatch(t.value) | ||
| 156 | + self.write(")") | ||
| 157 | + | ||
| 150 | 158 | def _Raise(self, t): | |
| 151 | 159 | self.fill("raise") | |
| 152 | 160 | if not t.exc: | |
@@ -158,35 +166,24 @@ def _Raise(self, t): | |||
| 158 | 166 | self.write(" from ") | |
| 159 | 167 | self.dispatch(t.cause) | |
| 160 | 168 | ||
| 161 | - def _TryExcept(self, t): | ||
| 169 | + def _Try(self, t): | ||
| 162 | 170 | self.fill("try") | |
| 163 | 171 | self.enter() | |
| 164 | 172 | self.dispatch(t.body) | |
| 165 | 173 | self.leave() | |
| 166 | - | ||
| 167 | 174 | for ex in t.handlers: | |
| 168 | 175 | self.dispatch(ex) | |
| 169 | 176 | if t.orelse: | |
| 170 | 177 | self.fill("else") | |
| 171 | 178 | self.enter() | |
| 172 | 179 | self.dispatch(t.orelse) | |
| 173 | 180 | self.leave() | |
| 174 | - | ||
| 175 | - def _TryFinally(self, t): | ||
| 176 | - if len(t.body) == 1 and isinstance(t.body[0], ast.TryExcept): | ||
| 177 | - # try-except-finally | ||
| 178 | - self.dispatch(t.body) | ||
| 179 | - else: | ||
| 180 | - self.fill("try") | ||
| 181 | + if t.finalbody: | ||
| 182 | + self.fill("finally") | ||
| 181 | 183 | self.enter() | |
| 182 | - self.dispatch(t.body) | ||
| 184 | + self.dispatch(t.finalbody) | ||
| 183 | 185 | self.leave() | |
| 184 | 186 | ||
| 185 | - self.fill("finally") | ||
| 186 | - self.enter() | ||
| 187 | - self.dispatch(t.finalbody) | ||
| 188 | - self.leave() | ||
| 189 | - | ||
| 190 | 187 | def _ExceptHandler(self, t): | |
| 191 | 188 | self.fill("except") | |
| 192 | 189 | if t.type: | |
@@ -296,10 +293,7 @@ def _While(self, t): | |||
| 296 | 293 | ||
| 297 | 294 | def _With(self, t): | |
| 298 | 295 | self.fill("with ") | |
| 299 | - self.dispatch(t.context_expr) | ||
| 300 | - if t.optional_vars: | ||
| 301 | - self.write(" as ") | ||
| 302 | - self.dispatch(t.optional_vars) | ||
| 296 | + interleave(lambda: self.write(", "), self.dispatch, t.items) | ||
| 303 | 297 | self.enter() | |
| 304 | 298 | self.dispatch(t.body) | |
| 305 | 299 | self.leave() | |
@@ -472,6 +466,10 @@ def _Subscript(self, t): | |||
| 472 | 466 | self.dispatch(t.slice) | |
| 473 | 467 | self.write("]") | |
| 474 | 468 | ||
| 469 | + def _Starred(self, t): | ||
| 470 | + self.write("*") | ||
| 471 | + self.dispatch(t.value) | ||
| 472 | + | ||
| 475 | 473 | # slice | |
| 476 | 474 | def _Ellipsis(self, t): | |
| 477 | 475 | self.write("...") | |
@@ -560,6 +558,12 @@ def _alias(self, t): | |||
| 560 | 558 | if t.asname: | |
| 561 | 559 | self.write(" as "+t.asname) | |
| 562 | 560 | ||
| 561 | + def _withitem(self, t): | ||
| 562 | + self.dispatch(t.context_expr) | ||
| 563 | + if t.optional_vars: | ||
| 564 | + self.write(" as ") | ||
| 565 | + self.dispatch(t.optional_vars) | ||
| 566 | + | ||
| 563 | 567 | def roundtrip(filename, output=sys.stdout): | |
| 564 | 568 | with open(filename, "rb") as pyfile: | |
| 565 | 569 | encoding = tokenize.detect_encoding(pyfile.readline)[0] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments