From df96f36071d535e456b1c6b626a0d5f91f4e33c4 Mon Sep 17 00:00:00 2001 From: Aryan Arora Date: Mon, 19 Feb 2024 11:40:43 +0530 Subject: [PATCH 1/3] remove metadata conversion --- libzim/libzim.pyx | 5 +---- tests/test_libzim_creator.py | 6 ------ 2 files changed, 1 insertion(+), 10 deletions(-) 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/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 From 595eba992a65faf84bc65bf8b0165083e2c7b359 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Thu, 22 Oct 2026 11:27:05 +0000 Subject: [PATCH 2/3] Document breaking Date metadata change in CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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 From edc44408a007214774fcdeafe9fbe72be920a627 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Thu, 22 Oct 2026 11:27:16 +0000 Subject: [PATCH 3/3] Bump version to 4.0.0-dev0, next release will be a major version This breaking change to Creator.add_metadata means the next release will be 4.0.0 rather than a 3.x patch/minor. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = [