Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions libzim/libzim.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ __path__ = []

cimport zim

import datetime
import enum
import importlib
import importlib.abc
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 0 additions & 6 deletions tests/test_libzim_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import base64
import datetime
import itertools
import os
import pathlib
Expand Down Expand Up @@ -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
Expand Down
Loading