@@ -4670,15 +4670,12 @@ char utf7_category[128] = {
4670
4670
4671
4671
/* ENCODE_DIRECT: this character should be encoded as itself. The
4672
4672
* answer depends on whether we are encoding set O as itself, and also
4673
- * on whether we are encoding whitespace as itself. RFC2152 makes it
4673
+ * on whether we are encoding whitespace as itself. RFC 2152 makes it
4674
4674
* clear that the answers to these questions vary between
4675
4675
* applications, so this code needs to be flexible. */
4676
4676
4677
- #define ENCODE_DIRECT (c , directO , directWS ) \
4678
- ((c) < 128 && (c) > 0 && \
4679
- ((utf7_category[(c)] == 0) || \
4680
- (directWS && (utf7_category[(c)] == 2)) || \
4681
- (directO && (utf7_category[(c)] == 1))))
4677
+ #define ENCODE_DIRECT (c ) \
4678
+ ((c) < 128 && (c) > 0 && ((utf7_category[(c)] != 3)))
4682
4679
4683
4680
PyObject *
4684
4681
PyUnicode_DecodeUTF7 (const char * s ,
@@ -4895,8 +4892,6 @@ PyUnicode_DecodeUTF7Stateful(const char *s,
4895
4892
4896
4893
PyObject *
4897
4894
_PyUnicode_EncodeUTF7 (PyObject * str ,
4898
- int base64SetO ,
4899
- int base64WhiteSpace ,
4900
4895
const char * errors )
4901
4896
{
4902
4897
Py_ssize_t len = PyUnicode_GET_LENGTH (str );
@@ -4923,7 +4918,7 @@ _PyUnicode_EncodeUTF7(PyObject *str,
4923
4918
Py_UCS4 ch = PyUnicode_READ (kind , data , i );
4924
4919
4925
4920
if (inShift ) {
4926
- if (ENCODE_DIRECT (ch , ! base64SetO , ! base64WhiteSpace )) {
4921
+ if (ENCODE_DIRECT (ch )) {
4927
4922
/* shifting out */
4928
4923
if (base64bits ) { /* output remaining bits */
4929
4924
* out ++ = TO_BASE64 (base64buffer << (6 - base64bits ));
@@ -4947,7 +4942,7 @@ _PyUnicode_EncodeUTF7(PyObject *str,
4947
4942
* out ++ = '+' ;
4948
4943
* out ++ = '-' ;
4949
4944
}
4950
- else if (ENCODE_DIRECT (ch , ! base64SetO , ! base64WhiteSpace )) {
4945
+ else if (ENCODE_DIRECT (ch )) {
4951
4946
* out ++ = (char ) ch ;
4952
4947
}
4953
4948
else {
0 commit comments