Skip to content

reject a day-of-week literal mixed with nth/L for the same weekday - #307

Open
Raghuvardhan-Reddy78 wants to merge 1 commit into
pallets-eco:mainfrom
Raghuvardhan-Reddy78:dow-literal-nth-same-day
Open

Raghuvardhan-Reddy78 wants to merge 1 commit into
pallets-eco:mainfrom
Raghuvardhan-Reddy78:dow-literal-nth-same-day

Conversation

@Raghuvardhan-Reddy78

Copy link
Copy Markdown
Contributor

_expand rejects a day-of-week field that mixes a literal weekday with an nth or last entry for another weekday, so 5,6#3 raises CroniterUnsupportedSyntaxError. The check builds its set of literals by subtracting the nth keys from the expanded field, which also removes a literal for the same weekday, so 0 0 * * 5,5#3 and 0 0 * * 5,L5 pass is_valid. At run time proc_day_of_week_nth only fires the nth entry and the literal is gone: from 2021-03-01, 5,5#3 yields Mar 19, Apr 16, May 21 instead of every Friday, and croniter.match returns False for Friday 2021-03-05. I found it while reading the nth handling next to test_hash_mixup_all_fri_3rd_sat and confirmed it with a short script. _expand now records the literal weekdays it parses and treats one that collides with an nth key as the same unsupported mix. A literal list covering the whole week is still accepted, so the pinned 0-6,sat#3 and *,sat#3 cases are unchanged, and the new test fails without the fix.

The check that rejects mixing a literal weekday with an nth or last
entry ("5,6#3") subtracted the nth keys from the literals, so a literal
for the same weekday ("5,5#3", "5,L5") slipped through. The nth entry
then replaced the literal and the schedule fired on the 3rd (or last)
Friday only instead of every Friday. Reject it like "5,6#3".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant