Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify timezone when doing conversion in seen module #2273

Closed
wants to merge 1 commit into from
Closed

Specify timezone when doing conversion in seen module #2273

wants to merge 1 commit into from

Conversation

timwoj
Copy link

@timwoj timwoj commented Apr 27, 2022

Description

I'm not sure why but the seen command started throwing this exception recently on my installation:

Traceback (most recent call last):
  File "/home/tim/sopel/lib/python3.10/site-packages/sopel/bot.py", line 674, in call_rule
    rule.execute(sopel, trigger)
  File "/home/tim/sopel/lib/python3.10/site-packages/sopel/plugins/rules.py", line 1079, in execute
    exit_code = self._handler(bot, trigger)
  File "/home/tim/sopel/lib/python3.10/site-packages/sopel/modules/seen.py", line 44, in seen
    delta = seconds_to_human((trigger.time - saw).total_seconds())
TypeError: can't subtract offset-naive and offset-aware datetimes

This PR fixes that by swapping from utcfromtimestamp to fromtimestamp and passing in the UTC timezone. The python docs actually recommend using fromtimestamp anyways if needing an offset-aware date time.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

I'm getting failures from make test but nothing within the code that I modified.

@dgw
Copy link
Member

dgw commented Apr 27, 2022

This is obsoleted by #2265, yes?

@Exirel
Copy link
Contributor

Exirel commented Apr 27, 2022

It is, yes.

@dgw
Copy link
Member

dgw commented Apr 27, 2022

@timwoj Thanks for the contribution, and for runtime-testing our unstable branch! Going to close this in favor of the previously approved patch, due to land Soon™ after I sort out this git.io thing GitHub sprung on us this week.

@dgw dgw closed this Apr 27, 2022
@dgw dgw added Duplicate Bugfix Generally, PRs that reference (and fix) one or more issue(s) Declined Requests that will not be implemented for technical or project direction reasons labels Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Generally, PRs that reference (and fix) one or more issue(s) Declined Requests that will not be implemented for technical or project direction reasons Duplicate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants