fix: guard self.unit against None in Job.__repr__#653
Open
Jo2234 wants to merge 1 commit intodbader:masterfrom
Open
fix: guard self.unit against None in Job.__repr__#653Jo2234 wants to merge 1 commit intodbader:masterfrom
Jo2234 wants to merge 1 commit intodbader:masterfrom
Conversation
When self.unit is None (before a time unit property like .seconds
is accessed), calling repr() or str() on the Job crashes with:
TypeError: 'NoneType' object is not subscriptable
This happens because self.unit[:-1] is called unconditionally when
self.interval == 1. The fix adds a truthiness check for self.unit
before attempting the slice operation.
Fixes dbader#646
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Guard
self.unitagainstNoneinJob.__repr__()to prevent aTypeErrorcrash.Problem
When
self.unitisNone(its initial value at line 233) andself.interval == 1, callingrepr()orstr()on the Job crashes:This happens because
self.unit[:-1]is called at lines 305 and 320 without first checking ifself.unitisNone.Fix
Applied to both occurrences (lines 305 and 320).
Fixes #646