`[[False] * width] * self.border` creates *border* references to the
same inner list object. When border > 1 this means all top (or all
bottom) border rows in the returned matrix share a single backing list,
so mutating any one of them silently corrupts the rest.
Replace the list-multiplication with list comprehensions to give every
border row its own independent list.
Reproducer (raises AssertionError before this fix):
qr = QRCode(border=4)
qr.add_data("1")
m = qr.get_matrix()
assert m[0] is not m[1] # was the *same* list – False without fix
Adds a regression test that verifies row identity and all-False content
for each border row when border=4.
What
[[False] * width] * self.border creates border references to the same inner list object. When border > 1, all top border rows (and all bottom border rows) in the returned matrix share a single backing list, so mutating any one of them silently corrupts the rest.
Reproducer
Fix
Replace the list-multiplication with list comprehensions so that every border row has its own independent list:
Tests
Added test_get_matrix_border_rows_not_aliased which verifies that, with border=4, every pair of top/bottom border rows is a distinct object and all values are False.
All 33 tests pass.