python / cpython

The Python programming language
https://www.python.org
Other
63.19k stars 30.26k forks source link

New C module for quopri assist #35183

Closed 8e121080-cc2d-4f2f-9b30-7e4536124e42 closed 23 years ago

8e121080-cc2d-4f2f-9b30-7e4536124e42 commented 23 years ago
BPO 462190
Nosy @gvanrossum, @loewis
Files
  • quoted.patch: Patch against recent python 2.2 CVS
  • binascii.patch: Patch against recent python 2.2 CVS
  • binascii.patch2
  • binascii.patch4: Patch against recent python 2.2 CVS
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = 'https://github.com/loewis' closed_at = created_at = labels = ['extension-modules'] title = 'New C module for quopri assist' updated_at = user = 'https://bugs.python.org/blong42' ``` bugs.python.org fields: ```python activity = actor = 'loewis' assignee = 'loewis' closed = True closed_date = None closer = None components = ['Extension Modules'] creation = creator = 'blong42' dependencies = [] files = ['3614', '3615', '3616', '3617'] hgrepos = [] issue_num = 462190 keywords = ['patch'] message_count = 9.0 messages = ['37605', '37606', '37607', '37608', '37609', '37610', '37611', '37612', '37613'] nosy_count = 3.0 nosy_names = ['gvanrossum', 'loewis', 'blong42'] pr_nums = [] priority = 'normal' resolution = 'accepted' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue462190' versions = [] ```

    8e121080-cc2d-4f2f-9b30-7e4536124e42 commented 23 years ago

    This patch adds a new module, quoted, and code in quopri to use this module if it exists. This module implements quoted printable encoding and decoding based on strings in C. This was required by a recent project of mine because 1MB quoted printable mail attachments (sometimes chosen to send PDF and PS data) would take 40+ minutes to encode and decode using the standard quopri python module.

    gvanrossum commented 23 years ago

    Logged In: YES user_id=6380

    It would make more sense to add this as another pair of encodings to the binascii module, which provides similar support for binhex, base64, and uuencode.

    8e121080-cc2d-4f2f-9b30-7e4536124e42 commented 23 years ago

    Logged In: YES user_id=325633

    Ok, this new patch adds the code to binascii, b2a_qp and a2b_qp.

    61337411-43fc-4a9c-b8d5-4060aede66d0 commented 23 years ago

    Logged In: YES user_id=21627

    The patch looks good to me. A couple of comments that may be worth consideration:

    8e121080-cc2d-4f2f-9b30-7e4536124e42 commented 23 years ago

    Logged In: YES user_id=325633

    Ok, this version handles invalid escape sequences the same way, ie by leaving them as they were in the input stream.

    My original reason for writing this was performance, and the size of the input was already restricted to 1MB, hence the chosen in memory encode/decode. No one is likely to be using the current version for anything even approaching that size given the abysmal performance of the current version. Given that 2.2 adds the decodestring and encodestring versions, maybe we should have both, I'm not sure. The new mimelib module handles mail in memory, instead of using the file like operations of the rfc822 module. *shrug*

    Using PyString in that fashion I don't think will save anything... as the only external interfaces for that would do a copy on create with PyString_FromStringAndSize(), and then a realloc with the PyString_Resize() (though I could be missing something in there).

    61337411-43fc-4a9c-b8d5-4060aede66d0 commented 23 years ago

    Logged In: YES user_id=21627

    I get numerous failures when running test_quopri. Do you see the same problems? Can you correct them?

    61337411-43fc-4a9c-b8d5-4060aede66d0 commented 23 years ago

    Logged In: YES user_id=21627

    Please have a look at the patch in

    http://sourceforge.net/tracker/index.php?func=detail&aid=464070&group_id=5470&atid=305470

    and the bug 463966. Would you be interested in fixing those bugs as well, and integrating the fixes into your C code?

    8e121080-cc2d-4f2f-9b30-7e4536124e42 commented 23 years ago

    Logged In: YES user_id=325633

    Ok, this version (4) of the patch fixes the bugs introduced in version (2), and also incorporates the patch from 464070, which fixes bug 463966 in both C and the quopri code. This version also includes an optional argument that will cause header encoding in the encoding functions, as well as documentation of the new functions in the binascii module.

    61337411-43fc-4a9c-b8d5-4060aede66d0 commented 23 years ago

    Logged In: YES user_id=21627

    Thanks again for the patch. It was committed as libbinascii.tex 1.21, libquopri.tex 1.14, quopri.py 1.16, test_quopri.py 1.6, NEWS 1.261, binascii.c 2.30.