41
41
package com .oracle .graal .python .builtins .modules ;
42
42
43
43
import static com .oracle .graal .python .builtins .PythonBuiltinClassType .NotImplementedError ;
44
+ import static com .oracle .graal .python .builtins .PythonBuiltinClassType .RuntimeWarning ;
44
45
import static com .oracle .graal .python .builtins .modules .codecs .ErrorHandlers .appendXmlCharRefReplacement ;
45
46
import static com .oracle .graal .python .builtins .modules .codecs .ErrorHandlers .getXmlCharRefReplacementLength ;
46
47
import static com .oracle .graal .python .builtins .objects .bytes .BytesUtils .HEXDIGITS ;
50
51
import static com .oracle .graal .python .nodes .BuiltinNames .J_ENCODE ;
51
52
import static com .oracle .graal .python .nodes .BuiltinNames .J__CODECS ;
52
53
import static com .oracle .graal .python .nodes .BuiltinNames .T_ASCII ;
54
+ import static com .oracle .graal .python .nodes .BuiltinNames .T_CP437 ;
53
55
import static com .oracle .graal .python .nodes .BuiltinNames .T__CODECS_TRUFFLE ;
54
56
import static com .oracle .graal .python .nodes .ErrorMessages .ARG_MUST_BE_CALLABLE ;
55
57
import static com .oracle .graal .python .nodes .ErrorMessages .BYTESLIKE_OBJ_REQUIRED ;
105
107
import com .oracle .graal .python .builtins .modules .codecs .CodecsRegistry ;
106
108
import com .oracle .graal .python .builtins .modules .codecs .CodecsRegistry .PyCodecLookupErrorNode ;
107
109
import com .oracle .graal .python .builtins .modules .codecs .CodecsRegistry .PyCodecRegisterErrorNode ;
110
+ import com .oracle .graal .python .builtins .modules .WarningsModuleBuiltins .WarnNode ;
108
111
import com .oracle .graal .python .builtins .objects .PNone ;
109
112
import com .oracle .graal .python .builtins .objects .buffer .PythonBufferAccessLibrary ;
110
113
import com .oracle .graal .python .builtins .objects .buffer .PythonBufferAcquireLibrary ;
@@ -1532,10 +1535,12 @@ Object encode(Object obj, Object errors) {
1532
1535
@ Builtin (name = "mbcs_encode" , minNumOfPositionalArgs = 1 , parameterNames = {"obj" , "errors" })
1533
1536
@ GenerateNodeFactory
1534
1537
abstract static class MBCSEncodeNode extends PythonBinaryBuiltinNode {
1535
- @ SuppressWarnings ("unused" )
1536
1538
@ Specialization
1537
- Object encode (Object obj , Object errors ) {
1538
- throw raise (NotImplementedError , toTruffleStringUncached ("mbcs_encode" ));
1539
+ Object encode (VirtualFrame frame , Object obj , Object errors ,
1540
+ @ Cached CodecsEncodeNode encode ,
1541
+ @ Cached WarnNode warnNode ) {
1542
+ warnNode .execute (frame , null , RuntimeWarning , toTruffleStringUncached ("mbcs_encode assumes cp437" ), 1 );
1543
+ return encode .execute (frame , obj , T_CP437 , errors );
1539
1544
}
1540
1545
}
1541
1546
@@ -1544,8 +1549,11 @@ Object encode(Object obj, Object errors) {
1544
1549
abstract static class MBCSDecodeNode extends PythonTernaryBuiltinNode {
1545
1550
@ SuppressWarnings ("unused" )
1546
1551
@ Specialization
1547
- Object decode (Object obj , Object errors , Object ffinal ) {
1548
- throw raise (NotImplementedError , toTruffleStringUncached ("mbcs_decode" ));
1552
+ Object decode (VirtualFrame frame , Object obj , Object errors , Object ffinal ,
1553
+ @ Cached CodecsDecodeNode decode ,
1554
+ @ Cached WarnNode warnNode ) {
1555
+ warnNode .execute (frame , null , RuntimeWarning , toTruffleStringUncached ("mbcs_decode assumes cp437" ), 1 );
1556
+ return decode .execute (frame , obj , T_CP437 , errors , ffinal );
1549
1557
}
1550
1558
}
1551
1559
0 commit comments