@@ -862,15 +862,15 @@ binascii.a2b_ascii85
862862 adobe: bool = False
863863 Expect data to be wrapped in '<~' and '~>' as in Adobe Ascii85.
864864 ignorechars: Py_buffer(c_default="NULL", py_default="b''") = None
865- An optional bytes-like object with input characters to be ignored .
865+ A byte string containing characters to ignore from the input .
866866
867867Decode Ascii85 data.
868868[clinic start generated code]*/
869869
870870static PyObject *
871871binascii_a2b_ascii85_impl (PyObject * module , Py_buffer * data , int foldspaces ,
872872 int adobe , Py_buffer * ignorechars )
873- /*[clinic end generated code: output=599aa3e41095a651 input=a72510e79c6d2df0 ]*/
873+ /*[clinic end generated code: output=599aa3e41095a651 input=20796c9b23cec213 ]*/
874874{
875875 const unsigned char * ascii_data = data -> buf ;
876876 Py_ssize_t ascii_len = data -> len ;
@@ -901,6 +901,11 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer *data, int foldspaces,
901901 }
902902 }
903903
904+ ignorecache_t ignorecache ;
905+ if (ignorechars != NULL ) {
906+ memset (ignorecache , 0 , sizeof (ignorecache ));
907+ }
908+
904909 /* Allocate output buffer. */
905910 size_t bin_len = ascii_len ;
906911 unsigned char this_ch = 0 ;
@@ -931,17 +936,6 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer *data, int foldspaces,
931936 return NULL ;
932937 }
933938
934- /* Build ignore map. */
935- unsigned char ignore_map [256 ] = {0 };
936- if (ignorechars -> obj != NULL ) {
937- const unsigned char * ignore_data = ignorechars -> buf ;
938- Py_ssize_t ignore_len = ignorechars -> len ;
939- for (Py_ssize_t i = 0 ; i < ignore_len ; i ++ ) {
940- this_ch = ignore_data [i ];
941- ignore_map [this_ch ] = -1 ;
942- }
943- }
944-
945939 uint32_t leftchar = 0 ;
946940 int group_pos = 0 ;
947941 for (; ascii_len > 0 || group_pos != 0 ; ascii_len -- , ascii_data ++ ) {
@@ -981,7 +975,7 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer *data, int foldspaces,
981975 leftchar = this_ch == 'y' ? BASE85_A85_Y : BASE85_A85_Z ;
982976 group_pos = 5 ;
983977 }
984- else if (!ignore_map [ this_ch ] ) {
978+ else if (!ignorechar ( this_ch , ignorechars , ignorecache ) ) {
985979 state = get_binascii_state (module );
986980 if (state != NULL ) {
987981 PyErr_Format (state -> Error ,
0 commit comments