maintainer-feedback requested: [Bug 300366] devel/py-jsonsir: Fix RegexEncoder on Python 3.7+ (re._pattern_type)

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 30 Oct 2026 22:28:04 UTC
Bugzilla Automation <bugzilla@FreeBSD.org> has asked freebsd-python (Nobody)
<python@FreeBSD.org> for maintainer-feedback:
Bug 300366: devel/py-jsonsir: Fix RegexEncoder on Python 3.7+
(re._pattern_type)
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300366



--- Description ---
jsonsir.contrib.regexencoder, the RegexEncoder of devel/py-jsonsir
0.0.2, can't be imported on any Python since 3.7, including 3.12 (and
3.13):

    $ python3.12 -c 'import jsonsir.contrib.regexencoder'
    AttributeError: module 're' has no attribute '_pattern_type'

jsonsir/contrib/regexencoder.py:12 uses re._pattern_type, which Python
3.7 removed; re.Pattern is the same type. The patch uses re.Pattern and
bumps PORTREVISION. The core serializer and the other contrib encoders
are not affected.

Misc changes:
- jsonsir.contrib.objectidencoder imports bson, which neither upstream
  nor the port declared; it now comes from the new MONGO option (pymongo,
  off by default)
- the patches in files/ get a header saying what each one does and its
  upstream status (Description, Issue ID, Changeset, TODO)

Impact: the only port that depends on it, devel/py-resource, imports
exactly this encoder in its Mongo serializer; py-resource is proposed
for deprecation in bug 300364 for other reasons.

Tested: poudriere bulk -C -t on 15.1-RELEASE amd64, both with Python
3.12 and with DEFAULT_VERSIONS+=python=3.13: builds, check-plist is
clean, and from a clean install jsonsir and jsonsir.contrib.regexencoder
import and a compiled pattern round-trips through serialize() and
deserialize() (unpatched: AttributeError re._pattern_type). The default
package is unchanged by the new option; with MONGO enabled, the package
depends on pymongo, and jsonsir.contrib.objectidencoder imports and
round-trips a bson ObjectId.

Upstream: 0.0.2 (2015-01-16) is the only release, and
github.com/RussellLuo/jsonsir has had no commits since that day, so the
port carries the fix as a local patch.