8000 Update __future__ from CPython 3.12.2 · RustPython/RustPython@153ec28 · GitHub
[go: up one dir, main page]

Skip to content

Commit 153ec28

Browse files
CPython Developersyouknowone
CPython Developers
authored andcommitted
Update __future__ from CPython 3.12.2
1 parent 9f65a30 commit 153ec28

17 files changed

+49
-24
lines changed

Lib/__future__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
to use the feature in question, but may continue to use such imports.
3434
3535
MandatoryRelease may also be None, meaning that a planned feature got
36-
dropped.
36+
dropped or that the release version is undetermined.
3737
3838
Instances of class _Feature have two corresponding methods,
3939
.getOptionalRelease() and .getMandatoryRelease().
@@ -96,7 +96,7 @@ def getMandatoryRelease(self):
9696
"""Return release in which this feature will become mandatory.
9797
9898
This is a 5-tuple, of the same form as sys.version_info, or, if
99-
the feature was dropped, is None.
99+
the feature was dropped, or the release date is undetermined, is None.
100100
"""
101101
return self.mandatory
102102

@@ -143,5 +143,5 @@ def __repr__(self):
143143
CO_FUTURE_GENERATOR_STOP)
144144

145145
annotations = _Feature((3, 7, 0, "beta", 1),
146-
(3, 11, 0, "alpha", 0),
146+
None,
147147
CO_FUTURE_ANNOTATIONS)

Lib/test/test_future_stmt/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
from test import support
3+
4+
5+
def load_tests(*args):
6+
return support.load_package_tests(os.path.dirname(__file__), *args)
File renamed without changes.
File renamed without changes.

Lib/test/test_future.py renamed to Lib/test/test_future_stmt/test_future.py

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import __future__
44
import ast
55
import unittest
6-
from test import support
76
from test.support import import_helper
7+
from test.support.script_helper import spawn_python, kill_python
88
from textwrap import dedent
99
import os
1010
import re
@@ -25,73 +25,87 @@ def check_syntax_error(self, err, basename, lineno, offset=1):
2525
self.assertEqual(err.offset, offset)
2626

2727
def test_future1(self):
28-
with import_helper.CleanImport('future_test1'):
29-
from test import future_test1
28+
with import_helper.CleanImport('test.test_future_stmt.future_test1'):
29+
from test.test_future_stmt import future_test1
3030
self.assertEqual(future_test1.result, 6)
3131

3232
def test_future2(self):
33-
with import_helper.CleanImport('future_test2'):
34-
from test import future_test2
33+
with import_helper.CleanImport('test.test_future_stmt.future_test2'):
34+
from test.test_future_stmt import future_test2
3535
self.assertEqual(future_test2.result, 6)
3636

37-
def test_future3(self):
38-
with import_helper.CleanImport('test_future3'):
39-
from test import test_future3
37+
def test_future_single_import(self):
38+
with import_helper.CleanImport(
39+
'test.test_future_stmt.test_future_single_import',
40+
):
41+
from test.test_future_stmt import test_future_single_import
42+
43+
def test_future_multiple_imports(self):
44+
with import_helper.CleanImport(
45+
'test.test_future_stmt.test_future_multiple_imports',
46+
):
47+
from test.test_future_stmt import test_future_multiple_imports
48+
49+
def test_future_multiple_features(self):
50+
with import_helper.CleanImport(
51+
"test.test_future_stmt.test_future_multiple_features",
52+
):
53+
from test.test_future_stmt import test_future_multiple_features
4054

4155
# TODO: RUSTPYTHON
4256
@unittest.expectedFailure
4357
def test_badfuture3(self):
4458
with self.assertRaises(SyntaxError) as cm:
45-
from test import badsyntax_future3
59+
from test.test_future_stmt import badsyntax_future3
4660
self.check_syntax_error(cm.exception, "badsyntax_future3", 3)
4761

4862
# TODO: RUSTPYTHON
4963
@unittest.expectedFailure
5064
def test_badfuture4(self):
5165
with self.assertRaises(SyntaxError) as cm:
52-
from test import badsyntax_future4
66+
from test.test_future_stmt import badsyntax_future4
5367
self.check_syntax_error(cm.exception, "badsyntax_future4", 3)
5468

5569
# TODO: RUSTPYTHON
5670
@unittest.expectedFailure
5771
def test_badfuture5(self):
5872
with self.assertRaises(SyntaxError) as cm:
59-
from test import badsyntax_future5
73+
from test.test_future_stmt import badsyntax_future5
6074
self.check_syntax_error(cm.exception, "badsyntax_future5", 4)
6175

6276
# TODO: RUSTPYTHON
6377
@unittest.expectedFailure
6478
def test_badfuture6(self):
6579
with self.assertRaises(SyntaxError) as cm:
66-
from test import badsyntax_future6
80+
from test.test_future_stmt import badsyntax_future6
6781
self.check_syntax_error(cm.exception, "badsyntax_future6", 3)
6882

6983
# TODO: RUSTPYTHON
7084
@unittest.expectedFailure
7185
def test_badfuture7(self):
7286
with self.assertRaises(SyntaxError) as cm:
73-
from test import badsyntax_future7
74-
self.check_syntax_error(cm.exception, "badsyntax_future7", 3, 53)
87+
from test.test_future_stmt import badsyntax_future7
88+
self.check_syntax_error(cm.exception, "badsyntax_future7", 3, 54)
7589

7690
# TODO: RUSTPYTHON
7791
@unittest.expectedFailure
7892
def test_badfuture8(self):
7993
with self.assertRaises(SyntaxError) as cm:
80-
from test import badsyntax_future8
94+
from test.test_future_stmt import badsyntax_future8
8195
self.check_syntax_error(cm.exception, "badsyntax_future8", 3)
8296

8397
# TODO: RUSTPYTHON
8498
@unittest.expectedFailure
8599
def test_badfuture9(self):
86100
with self.assertRaises(SyntaxError) as cm:
87-
from test import badsyntax_future9
101+
from test.test_future_stmt import badsyntax_future9
88102
self.check_syntax_error(cm.exception, "badsyntax_future9", 3)
89103

90104
# TODO: RUSTPYTHON
91105
@unittest.expectedFailure
92106
def test_badfuture10(self):
93107
with self.assertRaises(SyntaxError) as cm:
94-
from test import badsyntax_future10
108+
from test.test_future_stmt import badsyntax_future10
95109
self.check_syntax_error(cm.exception, "badsyntax_future10", 3)
96110

97111
def test_ensure_flags_dont_clash(self):
@@ -129,15 +143,20 @@ def test_parserhack(self):
129143
else:
130144
self.fail("syntax error didn't occur")
131145

132-
def test_multiple_features(self):
133-
with import_helper.CleanImport("test.test_future5"):
134-
from test import test_future5
135-
136146
def test_unicode_literals_exec(self):
137147
scope = {}
138148
exec("from __future__ import unicode_literals; x = ''", {}, scope)
139149
self.assertIsInstance(scope["x"], str)
140150

151+
# TODO: RUSTPYTHON
152+
@unittest.expectedFailure
153+
def test_syntactical_future_repl(self):
154+
p = spawn_python('-i')
155+
p.stdin.write(b"from __future__ import barry_as_FLUFL\n")
156+
p.stdin.write(b"2 <> 3\n")
157+
out = kill_python(p)
158+
self.assertNotIn(b'SyntaxError: invalid syntax', out)
159+
141160
class AnnotationsFutureTestCase(unittest.TestCase):
142161
template = dedent(
143162
"""

0 commit comments

Comments
 (0)
0