Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]
### Fixed
* Layers cache was written with `\r\r\n` row endings on Windows, so the second diff of any
board failed with an `IndexError` in `load_cached_layers`

## [2.6.0] - 2026-06-01
### Added
* KiCad 10 variants support for PCB
Expand Down
9 changes: 7 additions & 2 deletions kicad-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,15 @@ def load_cached_layers(layers_file):
layer_names = {}
name_to_id = {}
logger.debug('Loading layers from cache '+layers_file)
with open(layers_file) as csvfile:
# newline='' as the csv docs require; also tolerates caches written by older versions,
# where the missing newline='' made every row end \r\r\n and yield a blank row here
with open(layers_file, newline='') as csvfile:
reader = csv.reader(csvfile)
header = next(reader)
logger.debug(header)
for r in reader:
if not r:
continue
ilnum = int(r[0])
lname = r[1]
lname_user = r[2]
Expand All @@ -721,7 +725,8 @@ def save_layers_to_cache(layers_file, all_layers, kiri_mode):
makedirs(dname, exist_ok=True)
if kiri_mode:
return
with open(layers_file, 'wt') as csvfile:
# Without newline='' the writer's \r\n becomes \r\r\n on Windows, which reads back broken
with open(layers_file, 'wt', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(('Layer ID', 'Layer name', 'User name'))
writer.writerows(all_layers)
Expand Down