micropython / micropython/micropython

bytearray slice assignment fails for derived types

Open
#1,710 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
C
Stars
22.1k
Forks
9k
Avg merge
6d 4h
Merged PRs (30d)
16

Description

The type check for slice assignment to bytearray derived types seems to be a bit too strict:

class MyBytearray(bytearray): pass

a = MyBytearray(4)
b = MyBytearray(4)
a[0:4] = b

results in this error:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
NotImplementedError: array/bytes required on right side

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided MyBytearray slice-assignment reproducer and trace the implementation that raises “array/bytes required on right side.” Done means assignment from a bytearray-derived type succeeds without NotImplementedError, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.