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: bytearray.copy is undocumented
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: HallerPatrick, docs@python, josh.r, terry.reedy, wim.glenn
Priority: normal Keywords: patch

Created on 2021-01-17 18:41 by wim.glenn, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24308 closed terry.reedy, 2021-01-23 17:26
Messages (7)
msg385164 - (view) Author: wim glenn (wim.glenn) * Date: 2021-01-17 18:41
bytearray type has a copy method which seems to be undocumented

https://docs.python.org/3/library/stdtypes.html#bytes-and-bytearray-operations
msg385167 - (view) Author: Patrick Haller (HallerPatrick) Date: 2021-01-17 19:49
You will see this on every bytes and bytearray type as the behaviour described is the same for both.
msg385558 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-23 18:29
Patrick, I am not sure what you are saying.  All the methods listed is this section are for both, as with

bytes.count(sub[, start[, end]])
bytearray.count(sub[, start[, end]])¶

but only bytearray has .copy (since there is never a need to copy an immutable).  This appears to be only methods like this.  PR created.
msg385563 - (view) Author: Patrick Haller (HallerPatrick) Date: 2021-01-23 19:37
Terry, I am sorry. You are of course right. I was somehow looking at count not copy.
msg385568 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2021-01-24 02:21
Does this need specific documentation? bytearray itself is documented with:

> As bytearray objects are mutable, they support the mutable sequence operations in addition to the common bytes and bytearray operations described in Bytes and Bytearray Operations.

where "mutable" is a link to all the mutable sequence operations ( https://docs.python.org/3/library/stdtypes.html#typesseq-mutable ), including copy. Specifically documenting copy for bytearray is pointless; are we going to add specific documentation for append and remove and all the other mutable sequence operations as well?
msg385569 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-24 04:07
Josh, you are right.  I closed the PR.  Before closing, I will think about whether to propose a change to make this more prominent.

I notice the issubclass(array.array, collections.abc.MutableSequence ) is True even though some of the methods  (like clear, copy) are missing.
msg385599 - (view) Author: wim glenn (wim.glenn) * Date: 2021-01-25 03:30
Oh, I've missed that part. Although the note (5) seems to indicate that the copy method refers to sequence types which don't support slicing, it still seems adequately documented under the mutable sequence operations.

I'll close this.
History
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87114
2021-01-26 16:47:56terry.reedysetresolution: not a bug
2021-01-25 03:30:14wim.glennsetstatus: open -> closed

messages: + msg385599
stage: resolved
2021-01-24 04:07:36terry.reedysetmessages: + msg385569
2021-01-24 02:21:32josh.rsetnosy: + josh.r
messages: + msg385568
2021-01-23 19:37:43HallerPatricksetmessages: + msg385563
2021-01-23 18:29:41terry.reedysettype: enhancement -> behavior
versions: - Python 3.6, Python 3.7
messages: + msg385558
stage: patch review -> (no value)
2021-01-23 17:26:32terry.reedysetkeywords: + patch
nosy: + terry.reedy

pull_requests: + pull_request23129
stage: patch review
2021-01-17 19:49:53HallerPatricksetnosy: + HallerPatrick
messages: + msg385167
2021-01-17 18:41:52wim.glenncreate