Skip to content

fix: guard self.unit against None in __repr__#652

Open
thakoreh wants to merge 1 commit intodbader:masterfrom
thakoreh:fix-unit-none-guard
Open

fix: guard self.unit against None in __repr__#652
thakoreh wants to merge 1 commit intodbader:masterfrom
thakoreh:fix-unit-none-guard

Conversation

@thakoreh
Copy link

@thakoreh thakoreh commented Mar 1, 2026

Summary

Fixes #646

Problem

When self.interval == 1 and self.unit is None, the code attempts to slice self.unit[:-1], which causes a crash.

TypeError: 'NoneType' object is not subscriptable

Solution

Added a guard to check that self.unit is not None before attempting to slice it:

# Before
self.unit[:-1] if self.interval == 1 else self.unit

# After
self.unit[:-1] if self.interval == 1 and self.unit else self.unit

This change is applied to both occurrences in the __repr__ method (lines 305 and 320).

Added None check before slicing self.unit to prevent crash when
self.unit is None and self.interval == 1.

Fixes dbader#646
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CRASH CONDITION] - Guard self.unit against None

1 participant