40
40
*/
41
41
package com .oracle .graal .python .builtins .modules .io ;
42
42
43
+ import static com .oracle .graal .python .builtins .PythonBuiltinClassType .AttributeError ;
43
44
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .IOUnsupportedOperation ;
44
45
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .PTextIOWrapper ;
45
46
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .RuntimeError ;
94
95
import static com .oracle .graal .python .builtins .modules .io .TextIOWrapperNodes .setNewline ;
95
96
import static com .oracle .graal .python .builtins .modules .io .TextIOWrapperNodes .validateNewline ;
96
97
import static com .oracle .graal .python .nodes .ErrorMessages .A_STRICTLY_POSITIVE_INTEGER_IS_REQUIRED ;
98
+ import static com .oracle .graal .python .nodes .ErrorMessages .CANNOT_DELETE ;
97
99
import static com .oracle .graal .python .nodes .ErrorMessages .CAN_T_DO_NONZERO_CUR_RELATIVE_SEEKS ;
98
100
import static com .oracle .graal .python .nodes .ErrorMessages .CAN_T_DO_NONZERO_END_RELATIVE_SEEKS ;
99
101
import static com .oracle .graal .python .nodes .ErrorMessages .CAN_T_RECONSTRUCT_LOGICAL_FILE_POSITION ;
136
138
import com .oracle .graal .python .builtins .objects .buffer .PythonBufferAccessLibrary ;
137
139
import com .oracle .graal .python .builtins .objects .bytes .PBytes ;
138
140
import com .oracle .graal .python .builtins .objects .common .SequenceNodes ;
141
+ import com .oracle .graal .python .builtins .objects .getsetdescriptor .DescriptorDeleteMarker ;
139
142
import com .oracle .graal .python .builtins .objects .ints .PInt ;
140
143
import com .oracle .graal .python .builtins .objects .str .StringNodes .StringReplaceNode ;
141
144
import com .oracle .graal .python .builtins .objects .str .StringUtils .SimpleTruffleStringFormatNode ;
@@ -1157,7 +1160,7 @@ static TruffleString doit(PTextIO self) {
1157
1160
}
1158
1161
}
1159
1162
1160
- @ Builtin (name = J__CHUNK_SIZE , minNumOfPositionalArgs = 1 , maxNumOfPositionalArgs = 2 , isGetter = true , isSetter = true )
1163
+ @ Builtin (name = J__CHUNK_SIZE , minNumOfPositionalArgs = 1 , maxNumOfPositionalArgs = 2 , isGetter = true , isSetter = true , allowsDelete = true )
1161
1164
@ GenerateNodeFactory
1162
1165
abstract static class ChunkSizeNode extends PythonBuiltinNode {
1163
1166
@@ -1166,7 +1169,7 @@ static Object none(PTextIO self, @SuppressWarnings("unused") PNone none) {
1166
1169
return self .getChunkSize ();
1167
1170
}
1168
1171
1169
- @ Specialization (guards = {"self.isOK()" , "!self.isDetached()" , "!isNoValue(arg)" })
1172
+ @ Specialization (guards = {"self.isOK()" , "!self.isDetached()" , "!isNoValue(arg)" , "!isDeleteMarker(arg)" })
1170
1173
static Object chunkSize (VirtualFrame frame , PTextIO self , Object arg ,
1171
1174
@ Bind ("this" ) Node inliningTarget ,
1172
1175
@ Cached PyNumberAsSizeNode asSizeNode ,
@@ -1179,6 +1182,12 @@ static Object chunkSize(VirtualFrame frame, PTextIO self, Object arg,
1179
1182
return 0 ;
1180
1183
}
1181
1184
1185
+ @ Specialization (guards = {"self.isOK()" , "!self.isDetached()" })
1186
+ static Object noDelete (@ SuppressWarnings ("unused" ) PTextIO self , @ SuppressWarnings ("unused" ) DescriptorDeleteMarker marker ,
1187
+ @ Shared @ Cached PRaiseNode raiseNode ) {
1188
+ throw raiseNode .raise (AttributeError , CANNOT_DELETE );
1189
+ }
1190
+
1182
1191
@ Specialization (guards = "!self.isOK()" )
1183
1192
static Object initError (@ SuppressWarnings ("unused" ) PTextIO self , @ SuppressWarnings ("unused" ) Object arg ,
1184
1193
@ Shared @ Cached PRaiseNode raiseNode ) {
0 commit comments