Bugs item #1085283, was opened at 2004-12-14 18:11 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1085283&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None >Status: Closed >Resolution: Fixed Priority: 2 Private: No Submitted By: DSM (dsm001) Assigned to: Nobody/Anonymous (nobody) Summary: binascii.b2a_qp oddities Initial Comment: [Python 2.5a0 (#9, Dec 8 2004, 12:37:01); the behaviours go way back.] binascii.b2a_qp has several quirks discovered when reimplementing. (1) It lets low bytes pass through unescaped -- e.g. binascii.b2a_qp('\x08') == '\x08' -- unless quotetabs is True. This looks to be an error in program logic at lines ~1165 and ~1234, unless this is intended (although quopri's internal version quotes them). This doesn't seem RFC 1521 compatible on my reading of section 5 (admittedly I only read it for the first time last week. :-) (2) It determines whether to enforce \n or \r\n by scanning the string for the first occurrence [which should be mentioned in the docs]. binascii.c does this by calling strchr, which stops at the first \x00. This means that: >>> s0 = "The quick " + chr(0) + "brown fox.\r\n" >>> s1 = "The quick " + chr(1) + "brown fox.\r\n" >>> binascii.b2a_qp(s0) 'The quick \x00brown fox.\n' >>> binascii.b2a_qp(s1) 'The quick \x01brown fox.\r\n' and related strangenesses. (3) The code escapes the period "." if and only if it's the second character in a line. I'm not sure why; the only mention I can find in 1521 is in appendix B of escaping a period ALONE on a line in some situations, which binascii.b2a_qp doesn't do in any event. This behaviour may be prescribed by some other spec but is strange enough to be mentioned in the docs if it's intentional. A new strictly RFC1521-compliant qp encoding would be a good thing if backwards compatibility prevents changing some of these. ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2007-03-13 22:51 Message: Logged In: YES user_id=849994 Originator: NO Fixed (1) and (3) in rev. 54367. I think (2) is not important enough to do anything about it. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1085283&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com