[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-18 Thread Benjamin Peterson
Benjamin Peterson added the comment: Applied in r74929. Thanks! -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-18 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Jeff Bradberry wrote: > > Jeff Bradberry added the comment: > > Ok, fixed. I am kind of vague, though, on the usefulness of str.encode > and unicode.decode. codecs can work on any combination of types. Here's an example of a codec that accepts str and u

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-18 Thread Jeff Bradberry
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 __

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-17 Thread Benjamin Peterson
Benjamin Peterson added the comment: I still have a few things I would like changed: - Instead of listing which methods take keyword arguments at the top of the section, I would prefer that each used the "versionchanged: 2.7" directive and indicated the added ability to use keyword arguments. -

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Perfect. Thanks for checking. Benjamin, could you please check this in ? Thanks. -- assignee: -> benjamin.peterson ___ Python tracker ___

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-17 Thread Jeff Bradberry
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

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: The patch looks fine, the idea is good as well. I'm just a little worried about the performance impact this might have (not much though). Could you run a quick comparison of before applying the patch compared to after the patch is applied, using positional

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-16 Thread Jeff Bradberry
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

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-16 Thread Benjamin Peterson
Benjamin Peterson added the comment: They should also probably be added to unicode(), str(), unicode.decode, and unicode.encode then. (Also some tests, please!) -- nosy: +benjamin.peterson ___ Python tracker __

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-09-16 Thread Jeff Bradberry
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.pa

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-06-18 Thread Amaury Forgeot d'Arc
Changes by Amaury Forgeot d'Arc : -- keywords: +easy stage: -> needs patch ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue6300] encode and decode should accept 'errors' as a keyword argument

2009-06-17 Thread R. David Murray
New submission from R. David Murray : I repeatedly find myself typing things like "mybytestring.decode('ASCII', errors='replace')". This seems like the natural (I'm tempted to say Pythonic) thing to do, and is more readable (IMO) than "mybytestring.decode('ASCII', 'replace')". (replace what?).