Skip to content

Commit 1af6785

Browse files
author
semantic-release
committed
chore(release): 1.0.1
1 parent fb897e0 commit 1af6785

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
# CHANGELOG
22

33

4+
## v1.0.1 (2026-03-23)
5+
6+
### Bug Fixes
7+
8+
- **decoration**: Clear stale sq_item C slot after wrapping Tensor.__getitem__
9+
([`b2c6085`](https://github.com/johnmarktaylor91/torchlens/commit/b2c6085e31695b973b8d11c23c773af837a846cc))
10+
11+
When __getitem__ is replaced on a C extension type with a Python function, CPython sets the sq_item
12+
slot in tp_as_sequence. This makes PySequence_Check(tensor) return True (was False in clean
13+
PyTorch), causing torch.tensor([0-d_tensor, ...]) to iterate elements as sequences and call len()
14+
-- which raises TypeError for 0-d tensors. The slot is never cleared by restoring the original
15+
wrapper_descriptor or by delattr.
16+
17+
Fix: null sq_item via ctypes after every decoration/undecoration cycle (decorate_all_once,
18+
unwrap_torch, wrap_torch). Safe because tensor indexing uses mp_subscript (mapping protocol), not
19+
sq_item (sequence protocol). Verified via tp_name guard; fails silently on non-CPython.
20+
21+
Adds 9 regression tests covering all lifecycle paths.
22+
23+
### Chores
24+
25+
- Add secret detection pre-commit hooks
26+
([`0e2889a`](https://github.com/johnmarktaylor91/torchlens/commit/0e2889ae90f822840895d9331e912a570d2a9acf))
27+
28+
Add detect-private-key (pre-commit-hooks) and detect-secrets (Yelp) to catch leaked keys, tokens,
29+
and high-entropy strings before they hit the repo.
30+
31+
432
## v1.0.0 (2026-03-13)
533

634
### Bug Fixes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "torchlens"
7-
version = "1.0.0"
7+
version = "1.0.1"
88
description = "A package for extracting activations from PyTorch models"
99
readme = "README.md"
1010
license = "GPL-3.0-only"

torchlens/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
``wrap_torch()``. The ``wrapped()`` context manager handles the full lifecycle.
88
"""
99

10-
__version__ = "1.0.0"
10+
__version__ = "1.0.1"
1111

1212
# ---- Public API: user-facing entry points --------------------------------
1313

0 commit comments

Comments
 (0)