Issue 1669633: methods for bytes (original) (raw)
Created on 2007-02-27 03:04 by shredwheat, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (8)
Author: Pete Shinners (shredwheat)
Date: 2007-02-27 03:04
This adds the methods for bytes objects as listed in PEP 358. It includes tests for the newly added methods.
Author: Neal Norwitz (nnorwitz) *
Date: 2007-02-27 05:35
Thanks for the patch.
I'd like to try to focus on reviewing only new code. How much of this code was copied straight from string, how much was modified and how much was new?
There are a bunch of formatting changes. Could you revert those portions and add them to a separate patch (the file can be attached here if you want).
Since you are adding a Fini method, I wonder if you ought to add a corresponding Init method. This would init nullbytes and save a comparison on each instantiation of a bytes object.
_adjust_indices() looks generic, does this code exist elsewhere/can it be reused?
All the methods that take a single argument should use METH_O (e.g., bytes_extend).
Shouldn't value in bytes_remove(), bytes_insert(), and possibly elsewhere be limited to 0..255? If the value is > 255, it will traverse the entire bytes, then raise an exception rather than fail early.
Author: Pete Shinners (shredwheat)
Date: 2007-02-27 07:28
This is a split of the whitespacing. This matches the PEP7 style guide for 4-space indentation in C code.
File Added: bytesspace.diff
Author: Pete Shinners (shredwheat)
Date: 2007-02-27 16:41
Attached is the updated patch. This should apply clean after the "fromhex" patch that was recently applied. This ignores the previous whitespace cleanup patch.
Most of this code was copied from string. Minor modifications were made on these, but no real code changes. The following list of new methods are mostly modelled after list methods. extend, insert, append, reverse, pop, remove
This adds an Init method to match the Fini. Also added a comment stating partition is the only dependency of all this init. If partiion is removed from bytes, so should this global stuff.
_adjust_indices was copied directly from str. This is not used anywhere else in the codebase, so it should be unique again when str is removed. Added comment about this.
Switched new single argument methods to METH_O.
The 0-255 range is enforced on insert, append, and remove. Outside results in ValueError. File Added: bytesmethods2.diff
Author: Neal Norwitz (nnorwitz) *
Date: 2007-02-27 19:02
Thanks Pete!
Committed revision 54000.
Author: Pete Shinners (shredwheat)
Date: 2007-02-27 22:23
This patch adds many more tests for bytes. It breaks the common string_tests into a lower level base class that can support bytes and strings.
Author: Pete Shinners (shredwheat)
Date: 2007-02-27 22:23
File Added: bytestests.diff
Author: Georg Brandl (georg.brandl) *
Date: 2007-03-06 19:16
Committed the new tests as rev. 54179
History
Date
User
Action
Args
2022-04-11 14:56:22
admin
set
github: 44628
2008-01-06 22:29:46
admin
set
keywords: - py3k
versions: + Python 3.0
2007-02-27 03:04:19
shredwheat
create