diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e62076..8e13cab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Declare the extension free-threading compatible so that importing it on a free-threaded CPython no longer forces the GIL back on (#240) +### Removed + +- **Breaking**: `Creator.add_metadata` no longer auto-converts a `Date` metadata value passed as `datetime.date`/`datetime.datetime`; pass pre-formatted `str`/`bytes` instead (#188) + ## [3.13.1] - 2026-10-05 ### Changed diff --git a/libzim/libzim.pyx b/libzim/libzim.pyx index aa1fea9a..62b79d8b 100644 --- a/libzim/libzim.pyx +++ b/libzim/libzim.pyx @@ -33,7 +33,6 @@ __path__ = [] cimport zim -import datetime import enum import importlib import importlib.abc @@ -718,11 +717,9 @@ class Creator(_Creator): return super().config_compression(compression) def add_metadata( - self, name: str, content: Union[str, bytes, datetime.date, datetime.datetime], + self, name: str, content: Union[str, bytes], mimetype: str = "text/plain;charset=UTF-8" ): - if name == "Date" and isinstance(content, (datetime.date, datetime.datetime)): - content = content.strftime("%Y-%m-%d").encode("UTF-8") if isinstance(content, str): content = content.encode("UTF-8") super().add_metadata(name=name, content=content, mimetype=mimetype) diff --git a/pyproject.toml b/pyproject.toml index d02d0408..d631172f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" [project] name = "libzim" -version = "3.13.2-dev0" +version = "4.0.0-dev0" requires-python = ">=3.10,<3.15" description = "A python-facing API for creating and interacting with ZIM files" authors = [ diff --git a/tests/test_libzim_creator.py b/tests/test_libzim_creator.py index 75cf0aa8..344070d6 100644 --- a/tests/test_libzim_creator.py +++ b/tests/test_libzim_creator.py @@ -3,7 +3,6 @@ from __future__ import annotations import base64 -import datetime import itertools import os import pathlib @@ -417,13 +416,8 @@ def test_creator_metadata(fpath, lipsum_item): with Creator(fpath) as c: c.add_item(lipsum_item) for name, value in metadata.items(): - if name == "Date": - continue c.add_metadata(name, value) - mdate = datetime.date(*[int(x) for x in metadata.get("Date", "").split("-")]) - c.add_metadata("Date", mdate) - zim = Archive(fpath) for name, value in metadata.items(): assert zim.get_metadata(name).decode("UTF-8") == value