Content-Length: 297122 | pFad | http://github.com/adafruit/circuitpython/commit/361dbc02066f8d2b83c3a7f1f4993a9a590d1239

0B Merge pull request #10380 from bablokb/fix_deque · adafruit/circuitpython@361dbc0 · GitHub
Skip to content

Commit 361dbc0

Browse files
authored
Merge pull request #10380 from bablokb/fix_deque
fix deque implementation from upstream
2 parents 4061983 + cb1fcf3 commit 361dbc0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

py/objdeque.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static mp_obj_t deque_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
208208

209209
size_t offset = mp_get_index(self->base.type, deque_len(self), index, false);
210210
size_t index_val = self->i_get + offset;
211-
if (index_val > self->alloc) {
211+
if (index_val >= self->alloc) {
212212
index_val -= self->alloc;
213213
}
214214

tests/basics/deque2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
d[3] = 5
3232
print(d[3])
3333

34+
# Access the last element via index, when the last element is at various locations
35+
d = deque((), 2)
36+
for i in range(4):
37+
d.append(i)
38+
print(i, d[-1])
39+
40+
# Write the last element then access all elements from the end
41+
d[-1] = 4
42+
print(d[-2], d[-1])
43+
3444
# Accessing indices out of bounds raises IndexError
3545
try:
3646
d[4]

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/commit/361dbc02066f8d2b83c3a7f1f4993a9a590d1239

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy