Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
export: Replace broken naive datetime warning with assertion.
Anders Kaseorg6e32684d09b9
diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex e1295a3c5fb..db32625a275 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -22,7 +22,6 @@ from django.conf import settingsfrom django.db.models import Exists, OuterRef, Qfrom django.forms.models import model_to_dictfrom django.utils.timezone import is_naive as timezone_is_naive-from django.utils.timezone import make_aware as timezone_make_awarefrom mypy_boto3_s3.service_resource import Objectimport zerver.lib.upload@@ -430,15 +429,11 @@ def make_raw(query: Any, exclude: Optional[List[Field]] = None) -> List[Record]:def floatify_datetime_fields(data: TableData, table: TableName) -> None:for item in data[table]:for field in DATE_FIELDS[table]:- orig_dt = item[field]- if orig_dt is None:+ dt = item[field]+ if dt is None:continue- assert isinstance(orig_dt, datetime.datetime)- if timezone_is_naive(orig_dt):- logging.warning("Naive datetime:", item)- dt = timezone_make_aware(orig_dt)- else:- dt = orig_dt+ assert isinstance(dt, datetime.datetime)+ assert not timezone_is_naive(dt)utc_naive = dt.replace(tzinfo=None) - assert_is_not_none(dt.utcoffset())item[field] = (utc_naive - datetime.datetime(1970, 1, 1)).total_seconds()