summaryrefslogtreecommitdiffstats
path: root/Modules/binascii.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/binascii.c')
-rw-r--r--Modules/binascii.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c
index fbd2320..1f9ff5a 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -335,13 +335,15 @@ binascii.b2a_uu
data: Py_buffer
/
+ *
+ backtick: bool(accept={int}) = False
Uuencode line of data.
[clinic start generated code]*/
static PyObject *
-binascii_b2a_uu_impl(PyObject *module, Py_buffer *data)
-/*[clinic end generated code: output=0070670e52e4aa6b input=00fdf458ce8b465b]*/
+binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick)
+/*[clinic end generated code: output=b1b99de62d9bbeb8 input=b26bc8d32b6ed2f6]*/
{
unsigned char *ascii_data;
const unsigned char *bin_data;
@@ -367,7 +369,10 @@ binascii_b2a_uu_impl(PyObject *module, Py_buffer *data)
return NULL;
/* Store the length */
- *ascii_data++ = ' ' + (bin_len & 077);
+ if (backtick && !bin_len)
+ *ascii_data++ = '`';
+ else
+ *ascii_data++ = ' ' + bin_len;
for( ; bin_len > 0 || leftbits != 0 ; bin_len--, bin_data++ ) {
/* Shift the data (or padding) into our buffer */
@@ -381,7 +386,10 @@ binascii_b2a_uu_impl(PyObject *module, Py_buffer *data)
while ( leftbits >= 6 ) {
this_ch = (leftchar >> (leftbits-6)) & 0x3f;
leftbits -= 6;
- *ascii_data++ = this_ch + ' ';
+ if (backtick && !this_ch)
+ *ascii_data++ = '`';
+ else
+ *ascii_data++ = this_ch + ' ';
}
}
*ascii_data++ = '\n'; /* Append a courtesy newline */