IBM / django-ibmi

Django adapter for IBM i
Apache License 2.0
3 stars 5 forks source link

Handle pytz properly #32

Closed kadler closed 3 years ago

kadler commented 3 years ago

In operations.py, there's code to handle timezones which Db2 doesn't natively support. This requires pytz and when it is not available it tries to raise an exception, but there's a couple problems:

  1. The NotSupportedException is not defined
  2. The exception object is not raised
  3. No code handles the exception

I think we should handle this properly. We could start by using an appropriate exception (maybe local to the module, since it's only used there) and handling it at the two call sites within the module and mapping it to the appropriate Django exception (or don't handle it and instead use the appropriate Django exception directy from _get_utcoffset).

Another, possibly better idea is to just require pytz in order to function so we don't have to handle the case where it is not available.

kadler commented 3 years ago

It looks like Django itself already requires pytz, so we can also require it, making the solution quite simple.