This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: methods for bytes
Type: Stage:
Components: Interpreter Core Versions: Python 3.0
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: georg.brandl, nnorwitz, shredwheat
Priority: normal Keywords: patch

Created on 2007-02-27 03:04 by shredwheat, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bytesmethods.diff shredwheat, 2007-02-27 03:04 patch methods for bytes
bytesspace.diff shredwheat, 2007-02-27 07:28
bytesmethods2.diff shredwheat, 2007-02-27 16:41 updated version of patch. replaces all previous.
bytestests.diff shredwheat, 2007-02-27 22:23
Messages (8)
msg51985 - (view) 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.
msg51986 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) 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.

msg51987 - (view) 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
msg51988 - (view) 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
msg51989 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-02-27 19:02
Thanks Pete!

Committed revision 54000.
msg51990 - (view) 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.
msg51991 - (view) Author: Pete Shinners (shredwheat) Date: 2007-02-27 22:23
File Added: bytestests.diff
msg51992 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-06 19:16
Committed the new tests as rev. 54179
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44628
2008-01-06 22:29:46adminsetkeywords: - py3k
versions: + Python 3.0
2007-02-27 03:04:19shredwheatcreate