-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy path3.6-notes.txt
144 lines (129 loc) · 5.37 KB
/
3.6-notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Here's the diff that's needed to go from the 3.7 version to 3.6, and
from using Python's "-m test" to using "PYTHONPATH=. python3.6 test/test_dataclasses.py".
diff -u ../python/cpython/Lib/dataclasses.py .
--- ../python/cpython/Lib/dataclasses.py 2018-05-16 14:11:43.000000000 -0400
+++ ./dataclasses.py 2018-05-16 16:24:10.000000000 -0400
@@ -547,9 +547,7 @@
def _is_classvar(a_type, typing):
# This test uses a typing internal class, but it's the best way to
# test if this is a ClassVar.
- return (a_type is typing.ClassVar
- or (type(a_type) is typing._GenericAlias
- and a_type.__origin__ is typing.ClassVar))
+ return type(a_type) is typing._ClassVar
def _is_initvar(a_type, dataclasses):
diff -u ../python/cpython/Lib/test/test_dataclasses.py test
--- ../python/cpython/Lib/test/test_dataclasses.py 2018-05-16 11:32:13.000000000 -0400
+++ test/test_dataclasses.py 2018-05-16 16:14:43.000000000 -0400
@@ -666,7 +666,7 @@
self.assertNotEqual(Point3D(1, 2, 3), (1, 2, 3))
# Make sure we can't unpack.
- with self.assertRaisesRegex(TypeError, 'unpack'):
+ with self.assertRaisesRegex(TypeError, 'is not iterable'):
x, y, z = Point3D(4, 5, 6)
# Make sure another class with the same field names isn't
@@ -2051,7 +2051,7 @@
@dataclass(repr=False)
class C:
x: int
- self.assertIn('test_dataclasses.TestRepr.test_no_repr.<locals>.C object at',
+ self.assertIn('.TestRepr.test_no_repr.<locals>.C object at',
repr(C(3)))
# Test a class with a __repr__ and repr=False.
@@ -2798,10 +2798,10 @@
self.assertEqual(C(10).x, 10)
def test_classvar_module_level_import(self):
- from . import dataclass_module_1
- from . import dataclass_module_1_str
- from . import dataclass_module_2
- from . import dataclass_module_2_str
+ import dataclass_module_1
+ import dataclass_module_1_str
+ import dataclass_module_2
+ import dataclass_module_2_str
for m in (dataclass_module_1, dataclass_module_1_str,
dataclass_module_2, dataclass_module_2_str,
@@ -2971,7 +2971,7 @@
make_dataclass('C', [field, 'a', field])
def test_keyword_field_names(self):
- for field in ['for', 'async', 'await', 'as']:
+ for field in ['for', 'as', 'import']:
with self.subTest(field=field):
with self.assertRaisesRegex(TypeError, 'must not be keywords'):
make_dataclass('C', ['a', field])
diff -u ../python/cpython/Lib/test/dataclass_module_1.py test
diff -u ../python/cpython/Lib/test/dataclass_module_1_str.py test
--- ../python/cpython/Lib/test/dataclass_module_1_str.py 2018-05-16 06:50:50.000000000 -0400
+++ test/dataclass_module_1_str.py 2018-05-16 16:23:19.000000000 -0400
@@ -1,4 +1,4 @@
-from __future__ import annotations
+#from __future__ import annotations
USING_STRINGS = True
# dataclass_module_1.py and dataclass_module_1_str.py are identical
@@ -15,18 +15,18 @@
@dataclasses.dataclass
class CV:
- T_CV4 = typing.ClassVar
- cv0: typing.ClassVar[int] = 20
- cv1: typing.ClassVar = 30
- cv2: T_CV2
- cv3: T_CV3
- not_cv4: T_CV4 # When using string annotations, this field is not recognized as a ClassVar.
+ T_CV4 = "typing.ClassVar"
+ cv0: "typing.ClassVar[int]" = 20
+ cv1: "typing.ClassVar" = 30
+ cv2: "T_CV2"
+ cv3: "T_CV3"
+ not_cv4: "T_CV4" # When using string annotations, this field is not recognized as a ClassVar.
@dataclasses.dataclass
class IV:
- T_IV4 = dataclasses.InitVar
- iv0: dataclasses.InitVar[int]
- iv1: dataclasses.InitVar
- iv2: T_IV2
- iv3: T_IV3
- not_iv4: T_IV4 # When using string annotations, this field is not recognized as an InitVar.
+ T_IV4 = "dataclasses.InitVar"
+ iv0: "dataclasses.InitVar[int]"
+ iv1: "dataclasses.InitVar"
+ iv2: "T_IV2"
+ iv3: "T_IV3"
+ not_iv4: "T_IV4" # When using string annotations, this field is not recognized as an InitVar.
diff -u ../python/cpython/Lib/test/dataclass_module_2.py test
diff -u ../python/cpython/Lib/test/dataclass_module_2_str.py test
--- ../python/cpython/Lib/test/dataclass_module_2_str.py 2018-05-16 06:50:50.000000000 -0400
+++ test/dataclass_module_2_str.py 2018-05-16 16:23:58.000000000 -0400
@@ -1,4 +1,4 @@
-from __future__ import annotations
+#from __future__ import annotations
USING_STRINGS = True
# dataclass_module_2.py and dataclass_module_2_str.py are identical
@@ -15,18 +15,18 @@
@dataclass
class CV:
- T_CV4 = ClassVar
- cv0: ClassVar[int] = 20
- cv1: ClassVar = 30
- cv2: T_CV2
- cv3: T_CV3
- not_cv4: T_CV4 # When using string annotations, this field is not recognized as a ClassVar.
+ T_CV4 = "ClassVar"
+ cv0: "ClassVar[int]" = 20
+ cv1: "ClassVar" = 30
+ cv2: "T_CV2"
+ cv3: "T_CV3"
+ not_cv4: "T_CV4" # When using string annotations, this field is not recognized as a ClassVar.
@dataclass
class IV:
- T_IV4 = InitVar
- iv0: InitVar[int]
- iv1: InitVar
- iv2: T_IV2
- iv3: T_IV3
- not_iv4: T_IV4 # When using string annotations, this field is not recognized as an InitVar.
+ T_IV4 = "InitVar"
+ iv0: "InitVar[int]"
+ iv1: "InitVar"
+ iv2: "T_IV2"
+ iv3: "T_IV3"
+ not_iv4: "T_IV4" # When using string annotations, this field is not recognized as an InitVar.