[Bug 294823] databases/mongodb70: fails to build with Python 3.14

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 26 Apr 2026 21:33:45 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294823

            Bug ID: 294823
           Summary: databases/mongodb70: fails to build with Python 3.14
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ronald@FreeBSD.org
          Reporter: wcarson.bugzilla@disillusion.net
          Assignee: ronald@FreeBSD.org
             Flags: maintainer-feedback?(ronald@FreeBSD.org)

When building databases/mongodb70 with python3.14, you get the following error:


    Traceback (most recent call last):
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/python/mozbuild/mozbuild/frontend/sandbox.py",
line 209, in exec_function
        func(*args, **kwargs)
        ~~~~^^^^^^^^^^^^^^^^^
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/python/mozbuild/mozbuild/frontend/sandbox.py",
line 184, in execute
        exec(code, self)
        ~~~~^^^^^^^^^^^^
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/build/templates.mozbuild",
line 8, in <module>
        @template
         ^^^^^^^^
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/python/mozbuild/mozbuild/frontend/reader.py",
line 319, in function
        return func(self)(*args)
               ~~~~~~~~~~^^^^^^^
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/python/mozbuild/mozbuild/frontend/reader.py",
line 289, in _template_decorator
        self.templates[name] = TemplateFunction(func, self)
                               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/python/mozbuild/mozbuild/frontend/reader.py",
line 419, in __init__
        func_ast = self.RewriteName(sandbox, self._global_name).visit(func_ast)
      File "/usr/local/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "/usr/local/lib/python3.14/ast.py", line 561, in generic_visit
        value = self.visit(value)
      File "/usr/local/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "/usr/local/lib/python3.14/ast.py", line 561, in generic_visit
        value = self.visit(value)
      File "/usr/local/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "/usr/local/lib/python3.14/ast.py", line 570, in generic_visit
        new_node = self.visit(old_value)
      File "/usr/local/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "/usr/local/lib/python3.14/ast.py", line 570, in generic_visit
        new_node = self.visit(old_value)
      File "/usr/local/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File "/usr/local/lib/python3.14/ast.py", line 570, in generic_visit
        new_node = self.visit(old_value)
      File "/usr/local/lib/python3.14/ast.py", line 506, in visit
        return visitor(node)
      File
"/wrkdirs/usr/ports/databases/mongodb70/work-default/spidermonkey-5acd3be6c9563ad3e7ca6182285c69a38de47bab/python/mozbuild/mozbuild/frontend/reader.py",
line 473, in visit_Name
        slice=c(ast.Index(value=c(ast.Str(s=node.id)))),
                                  ^^^^^^^
    AttributeError: module 'ast' has no attribute 'Str'


I was able to resolve by manually applying this patch
https://github.com/mozilla-firefox/firefox/commit/d497aa4f770ca02f6083e93b94996a8fe32c2ff4.patch
The line numbers do not match, so I adjusted it:


    databases/mongodb70 # cat
files/d497aa4f770ca02f6083e93b94996a8fe32c2ff4.patch
    From d497aa4f770ca02f6083e93b94996a8fe32c2ff4 Mon Sep 17 00:00:00 2001
    From: Mike Hommey <mh+mozilla@glandium.org>
    Date: Tue, 19 Aug 2025 05:09:09 +0000
    Subject: [PATCH] Bug 1969769 - Change uses of ast.Str with ast.Constant.
     r=firefox-build-system-reviewers,ahochheiden

    ast.Str was deprecated in python 3.12 and removed in 3.14. It inherited
    from ast.Constant, `Str.s` was equivalent to `Constant.value`, so we can
    use the latter on both old and newer python versions.

    Differential Revision: https://phabricator.services.mozilla.com/D261512
    ---
     python/mozbuild/mozbuild/frontend/reader.py        | 14 +++++++-------
     .../mozbuild/mozbuild/vendor/rewrite_mozbuild.py   |  6 ++----
     2 files changed, 9 insertions(+), 11 deletions(-)

    diff --git a/python/mozbuild/mozbuild/frontend/reader.py
b/python/mozbuild/mozbuild/frontend/reader.py
    index 9f6292cb909de..89bf9995c1768 100644
    --- a/python/mozbuild/mozbuild/frontend/reader.py
    +++ b/python/mozbuild/mozbuild/frontend/reader.py
    @@ -470,7 +470,7 @@
                 return c(
                     ast.Subscript(
                         value=c(ast.Name(id=self._global_name,
ctx=ast.Load())),
    -                    slice=c(ast.Index(value=c(ast.Str(s=node.id)))),
    +                   
slice=c(ast.Index(value=c(ast.Constant(value=node.id)))),
                         ctx=node.ctx,
                     )
                 )
    @@ -1035,8 +1035,8 @@
                     else:
                         # Others
                         assert isinstance(target.slice, ast.Index)
    -                    assert isinstance(target.slice.value, ast.Str)
    -                    key = target.slice.value.s
    +                    assert isinstance(target.slice.value, ast.Constant)
    +                    key = target.slice.value.value

                 return name, key

    @@ -1044,11 +1044,11 @@
                 value = node.value
                 if isinstance(value, ast.List):
                     for v in value.elts:
    -                    assert isinstance(v, ast.Str)
    -                    yield v.s
    +                    assert isinstance(v, ast.Constant)
    +                    yield v.value
                 else:
    -                assert isinstance(value, ast.Str)
    -                yield value.s
    +                assert isinstance(value, ast.Constant)
    +                yield value.value

             assignments = []

    diff --git a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py
    index cfcc0f18b9a9a..de06b58819b6a 100644
    --- a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py       2026-04-26
13:55:23.117672000 -0500
    +++ a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py       2026-04-26
13:55:54.618049000 -0500
    @@ -327,15 +327,13 @@
         """
         if isinstance(node.value, ast.List) and "elts" in node.value._fields:
             for f in node.value.elts:
    -            if not isinstance(f, ast.Constant) and not isinstance(f,
ast.Str):
    +            if not isinstance(f, ast.Constant):
                     log(
                         "Found non-constant source file name in list: ",
                         ast_get_source_segment(code, f),
                     )
                     return []
    -        return [
    -            f.value if isinstance(f, ast.Constant) else f.s for f in
node.value.elts
    -        ]
    +        return [f.value for f in node.value.elts]
         elif isinstance(node.value, ast.ListComp):
             # SOURCES += [f for f in foo if blah]
             log("Could not find the files for " + ast_get_source_segment(code,
node.value))


And in order to get it to apply to the spidermonkey part, I had to add this to
post-extract:


    databases/mongodb70 # git diff .
    diff --git a/databases/mongodb70/Makefile b/databases/mongodb70/Makefile
    index 2de42850b18c..4faf2c7e782c 100644
    --- a/databases/mongodb70/Makefile
    +++ b/databases/mongodb70/Makefile
    @@ -151,6 +151,7 @@ MOZJS_ARCH= ${ARCH}
     post-extract:
     # Verify we downloaded the proper mozjs git tag.
            ${SH} -xc "test \"X`grep -E '^LIB_GIT_REVISION='
${MOZJS_WRKSRC}/get-sources.sh`\" = \"XLIB_GIT_REVISION=${MOZJS_TAG}\""
    +       ${PATCH} -d ${WRKDIR}/spidermonkey-${MOZJS_TAG} -p1 <
${PATCHDIR}/d497aa4f770ca02f6083e93b94996a8fe32c2ff4.patch

     post-patch:
     # fix build with python-3.11

-- 
You are receiving this mail because:
You are the assignee for the bug.