[issue6300] encode and decode should accept 'errors' as a keyword argument
Jeff Bradberry added the comment: This patch adds the requested behavior to the current 2.7 svn trunk. Both 'encoding' and 'errors' may be used as keyword arguments for encode() and decode(). -- keywords: +patch nosy: +jbradberry Added file: http://bugs.python.org/file14905/python27.patch ___ Python tracker <http://bugs.python.org/issue6300> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6300] encode and decode should accept 'errors' as a keyword argument
Jeff Bradberry added the comment: As it turns out, someone had previously made this adjustment to str() and unicode(). My updated patch adds this behavior to unicode.decode and unicode.encode, adds a couple of tests to test_unicode.py, and updates the documentation to show that these functions (and str.format, which had failed to be noted as taking them) now take keyword arguments. -- Added file: http://bugs.python.org/file14906/python27.patch ___ Python tracker <http://bugs.python.org/issue6300> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6300] encode and decode should accept 'errors' as a keyword argument
Jeff Bradberry added the comment: Before: ~/python2.7$ ./python -mtimeit "u'Andr\202 x'.encode('ascii', 'replace')" 100 loops, best of 3: 1.8 usec per loop After: ~/python2.7-patched$ ./python -mtimeit "u'Andr\202 x'.encode('ascii', 'replace')" 100 loops, best of 3: 1.73 usec per loop The difference in performance seems to be trivial, perhaps favoring the patched version slightly. -- ___ Python tracker <http://bugs.python.org/issue6300> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6300] encode and decode should accept 'errors' as a keyword argument
Jeff Bradberry added the comment: Ok, fixed. I am kind of vague, though, on the usefulness of str.encode and unicode.decode. -- Added file: http://bugs.python.org/file14925/python27.patch ___ Python tracker <http://bugs.python.org/issue6300> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com