56
56
import static com .oracle .graal .python .nodes .ErrorMessages .IO_STREAM_INVALID_POS ;
57
57
import static com .oracle .graal .python .nodes .ErrorMessages .REENTRANT_CALL_INSIDE_P ;
58
58
import static com .oracle .graal .python .nodes .ErrorMessages .SHUTDOWN_POSSIBLY_DUE_TO_DAEMON_THREADS ;
59
+ import static com .oracle .graal .python .nodes .ErrorMessages .S_OF_CLOSED_FILE ;
59
60
import static com .oracle .graal .python .nodes .ErrorMessages .S_TO_CLOSED_FILE ;
60
61
import static com .oracle .graal .python .runtime .exception .PythonErrorType .IOUnsupportedOperation ;
61
62
import static com .oracle .graal .python .runtime .exception .PythonErrorType .OSError ;
@@ -94,9 +95,11 @@ public class BufferedIONodes {
94
95
abstract static class CheckIsClosedNode extends PNodeWithContext {
95
96
96
97
private final String method ;
98
+ private final String messageFmt ;
97
99
98
100
public CheckIsClosedNode (String method ) {
99
101
this .method = method ;
102
+ this .messageFmt = IONodes .WRITE .equals (method ) ? S_TO_CLOSED_FILE : S_OF_CLOSED_FILE ;
100
103
}
101
104
102
105
public abstract boolean execute (VirtualFrame frame , PBuffered self );
@@ -107,7 +110,7 @@ boolean isClosedBuffered(VirtualFrame frame, PBuffered self,
107
110
@ Cached IsClosedNode isClosedNode ,
108
111
@ Cached ConditionProfile isError ) {
109
112
if (isError .profile (isClosedNode .execute (frame , self ))) {
110
- throw raiseNode .raise (PythonBuiltinClassType .ValueError , S_TO_CLOSED_FILE , method );
113
+ throw raiseNode .raise (PythonBuiltinClassType .ValueError , messageFmt , method );
111
114
}
112
115
return false ;
113
116
}
0 commit comments