Re: git: 0b3ec4bd7b7a - main - Mk/bsd.gecko.mk: release python limitation

From: Dmitry Marakasov <amdmi3_at_amdmi3.ru>
Date: Sun, 04 Dec 2022 22:22:47 UTC
* Christoph Moench-Tegeder (cmt@FreeBSD.org) wrote:
> The branch main has been updated by cmt:
> 
> URL: https://cgit.FreeBSD.org/ports/commit/?id=0b3ec4bd7b7a21467fb1f0d2ee6e9699947b811d
> 
> commit 0b3ec4bd7b7a21467fb1f0d2ee6e9699947b811d
> Author:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
> AuthorDate: 2022-11-16 22:21:55 +0000
> Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
> CommitDate: 2022-11-16 22:21:55 +0000
> 
>     Mk/bsd.gecko.mk: release python limitation
>     
>     upstream patch should allow building with newer pythons, while the
>     old python still works

This looks incomplete - thunderbird still does not build with python 3.11:

...
Creating config.status
Traceback (most recent call last):
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/configure.py", line 349, in <module>
    sys.exit(main(sys.argv))
             ^^^^^^^^^^^^^^
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/configure.py", line 157, in main
    config_status(js_config, execute=False)
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/configure.py", line 281, in config_status
    partial_config.write_vars(sanitized_config)
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/python/mozbuild/mozbuild/backend/configenvironment.py", line 355, in write_vars
    self.substs._fill_group(substs)
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/python/mozbuild/mozbuild/backend/configenvironment.py", line 250, in _fill_group
    new_files.add(Path(self._write_file(k, v)))
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/python/mozbuild/mozbuild/backend/configenvironment.py", line 232, in _write_file
    with FileAvoidWrite(filename) as fh:
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/python/mozbuild/mozbuild/util.py", line 353, in __exit__
    self.close()
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/python/mozbuild/mozbuild/util.py", line 277, in close
    existing = _open(self.name, self.mode)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/work/usr/ports/mail/thunderbird/work/thunderbird-102.5.1/python/mozbuild/mozbuild/util.py", line 63, in _open
    return io.open(path, mode, encoding="utf-8", newline="\n")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU'

>  Mk/bsd.gecko.mk                         |  2 +-
>  mail/thunderbird/files/patch-bug1799982 | 60 +++++++++++++++++++++++++++++++++
>  www/firefox-esr/files/patch-bug1799982  | 60 +++++++++++++++++++++++++++++++++
>  www/firefox/files/patch-bug1799982      | 60 +++++++++++++++++++++++++++++++++
>  4 files changed, 181 insertions(+), 1 deletion(-)
> 
> diff --git a/Mk/bsd.gecko.mk b/Mk/bsd.gecko.mk
> index c0e9e999b3b5..4e2a77c5107c 100644
> --- a/Mk/bsd.gecko.mk
> +++ b/Mk/bsd.gecko.mk
> @@ -61,7 +61,7 @@ MOZILLA_VER?=	${PORTVERSION}
>  MOZILLA_BIN?=	${PORTNAME}-bin
>  MOZILLA_EXEC_NAME?=${MOZILLA}
>  USES+=		compiler:c++17-lang cpe gl gmake gnome iconv localbase perl5 pkgconfig \
> -			python:3.6-3.10,build desktop-file-utils
> +			python:3.6+,build desktop-file-utils
>  CPE_VENDOR?=mozilla
>  USE_GL=		gl
>  USE_GNOME=	cairo gdkpixbuf2 gtk30
> diff --git a/mail/thunderbird/files/patch-bug1799982 b/mail/thunderbird/files/patch-bug1799982
> new file mode 100644
> index 000000000000..dac77d73390b
> --- /dev/null
> +++ b/mail/thunderbird/files/patch-bug1799982
> @@ -0,0 +1,60 @@
> +Bug 1799982 - Remove uses of inline flags from XPIDL regexps. r=xpcom-reviewers,kmag
> +
> +Apparently the use of these is being turned into an error in Python 3.11.
> +Fortunately, our uses appears to be rather trivial.
> +
> +For t_multilinecomment and t_LCDATA, I dropped the (?s) flag and just
> +replaced the one use of . with (\n|.). (?s) means DOTALL, which means
> +that dot includes any character, including a newline. Otherwise it means
> +dot includes any character except a newline.
> +
> +I took the new t_singlelinecomment from IPDL's parser.py, so I assume
> +it is reasonable enough. t_multilinecomment is also now the same as
> +in IPDL.
> +
> +Differential Revision: https://phabricator.services.mozilla.com/D161738
> +
> +diff --git xpcom/idl-parser/xpidl/xpidl.py xpcom/idl-parser/xpidl/xpidl.py
> +--- xpcom/idl-parser/xpidl/xpidl.py
> ++++ xpcom/idl-parser/xpidl/xpidl.py
> +@@ -1634,36 +1634,36 @@ class IDLParser(object):
> +     t_LSHIFT = r"<<"
> +     t_RSHIFT = r">>"
> + 
> +     literals = '"(){}[]<>,;:=|+-*'
> + 
> +     t_ignore = " \t"
> + 
> +     def t_multilinecomment(self, t):
> +-        r"/\*(?s).*?\*/"
> ++        r"/\*(\n|.)*?\*/"
> +         t.lexer.lineno += t.value.count("\n")
> +         if t.value.startswith("/**"):
> +             self._doccomments.append(t.value)
> + 
> +     def t_singlelinecomment(self, t):
> +-        r"(?m)//.*?$"
> ++        r"//[^\n]*"
> + 
> +     def t_IID(self, t):
> +         return t
> + 
> +     t_IID.__doc__ = r"%(c)s{8}-%(c)s{4}-%(c)s{4}-%(c)s{4}-%(c)s{12}" % {"c": hexchar}
> + 
> +     def t_IDENTIFIER(self, t):
> +         r"(unsigned\ long\ long|unsigned\ short|unsigned\ long|long\ long)(?!_?[A-Za-z][A-Za-z_0-9])|_?[A-Za-z][A-Za-z_0-9]*"  # NOQA: E501
> +         t.type = self.keywords.get(t.value, "IDENTIFIER")
> +         return t
> + 
> +     def t_LCDATA(self, t):
> +-        r"(?s)%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?"
> ++        r"%\{[ ]*C\+\+[ ]*\n(?P<cdata>(\n|.)*?\n?)%\}[ ]*(C\+\+)?"
> +         t.type = "CDATA"
> +         t.value = t.lexer.lexmatch.group("cdata")
> +         t.lexer.lineno += t.value.count("\n")
> +         return t
> + 
> +     def t_INCLUDE(self, t):
> +         r'\#include[ \t]+"[^"\n]+"'
> +         inc, value, end = t.value.split('"')
> +
> diff --git a/www/firefox-esr/files/patch-bug1799982 b/www/firefox-esr/files/patch-bug1799982
> new file mode 100644
> index 000000000000..dac77d73390b
> --- /dev/null
> +++ b/www/firefox-esr/files/patch-bug1799982
> @@ -0,0 +1,60 @@
> +Bug 1799982 - Remove uses of inline flags from XPIDL regexps. r=xpcom-reviewers,kmag
> +
> +Apparently the use of these is being turned into an error in Python 3.11.
> +Fortunately, our uses appears to be rather trivial.
> +
> +For t_multilinecomment and t_LCDATA, I dropped the (?s) flag and just
> +replaced the one use of . with (\n|.). (?s) means DOTALL, which means
> +that dot includes any character, including a newline. Otherwise it means
> +dot includes any character except a newline.
> +
> +I took the new t_singlelinecomment from IPDL's parser.py, so I assume
> +it is reasonable enough. t_multilinecomment is also now the same as
> +in IPDL.
> +
> +Differential Revision: https://phabricator.services.mozilla.com/D161738
> +
> +diff --git xpcom/idl-parser/xpidl/xpidl.py xpcom/idl-parser/xpidl/xpidl.py
> +--- xpcom/idl-parser/xpidl/xpidl.py
> ++++ xpcom/idl-parser/xpidl/xpidl.py
> +@@ -1634,36 +1634,36 @@ class IDLParser(object):
> +     t_LSHIFT = r"<<"
> +     t_RSHIFT = r">>"
> + 
> +     literals = '"(){}[]<>,;:=|+-*'
> + 
> +     t_ignore = " \t"
> + 
> +     def t_multilinecomment(self, t):
> +-        r"/\*(?s).*?\*/"
> ++        r"/\*(\n|.)*?\*/"
> +         t.lexer.lineno += t.value.count("\n")
> +         if t.value.startswith("/**"):
> +             self._doccomments.append(t.value)
> + 
> +     def t_singlelinecomment(self, t):
> +-        r"(?m)//.*?$"
> ++        r"//[^\n]*"
> + 
> +     def t_IID(self, t):
> +         return t
> + 
> +     t_IID.__doc__ = r"%(c)s{8}-%(c)s{4}-%(c)s{4}-%(c)s{4}-%(c)s{12}" % {"c": hexchar}
> + 
> +     def t_IDENTIFIER(self, t):
> +         r"(unsigned\ long\ long|unsigned\ short|unsigned\ long|long\ long)(?!_?[A-Za-z][A-Za-z_0-9])|_?[A-Za-z][A-Za-z_0-9]*"  # NOQA: E501
> +         t.type = self.keywords.get(t.value, "IDENTIFIER")
> +         return t
> + 
> +     def t_LCDATA(self, t):
> +-        r"(?s)%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?"
> ++        r"%\{[ ]*C\+\+[ ]*\n(?P<cdata>(\n|.)*?\n?)%\}[ ]*(C\+\+)?"
> +         t.type = "CDATA"
> +         t.value = t.lexer.lexmatch.group("cdata")
> +         t.lexer.lineno += t.value.count("\n")
> +         return t
> + 
> +     def t_INCLUDE(self, t):
> +         r'\#include[ \t]+"[^"\n]+"'
> +         inc, value, end = t.value.split('"')
> +
> diff --git a/www/firefox/files/patch-bug1799982 b/www/firefox/files/patch-bug1799982
> new file mode 100644
> index 000000000000..dac77d73390b
> --- /dev/null
> +++ b/www/firefox/files/patch-bug1799982
> @@ -0,0 +1,60 @@
> +Bug 1799982 - Remove uses of inline flags from XPIDL regexps. r=xpcom-reviewers,kmag
> +
> +Apparently the use of these is being turned into an error in Python 3.11.
> +Fortunately, our uses appears to be rather trivial.
> +
> +For t_multilinecomment and t_LCDATA, I dropped the (?s) flag and just
> +replaced the one use of . with (\n|.). (?s) means DOTALL, which means
> +that dot includes any character, including a newline. Otherwise it means
> +dot includes any character except a newline.
> +
> +I took the new t_singlelinecomment from IPDL's parser.py, so I assume
> +it is reasonable enough. t_multilinecomment is also now the same as
> +in IPDL.
> +
> +Differential Revision: https://phabricator.services.mozilla.com/D161738
> +
> +diff --git xpcom/idl-parser/xpidl/xpidl.py xpcom/idl-parser/xpidl/xpidl.py
> +--- xpcom/idl-parser/xpidl/xpidl.py
> ++++ xpcom/idl-parser/xpidl/xpidl.py
> +@@ -1634,36 +1634,36 @@ class IDLParser(object):
> +     t_LSHIFT = r"<<"
> +     t_RSHIFT = r">>"
> + 
> +     literals = '"(){}[]<>,;:=|+-*'
> + 
> +     t_ignore = " \t"
> + 
> +     def t_multilinecomment(self, t):
> +-        r"/\*(?s).*?\*/"
> ++        r"/\*(\n|.)*?\*/"
> +         t.lexer.lineno += t.value.count("\n")
> +         if t.value.startswith("/**"):
> +             self._doccomments.append(t.value)
> + 
> +     def t_singlelinecomment(self, t):
> +-        r"(?m)//.*?$"
> ++        r"//[^\n]*"
> + 
> +     def t_IID(self, t):
> +         return t
> + 
> +     t_IID.__doc__ = r"%(c)s{8}-%(c)s{4}-%(c)s{4}-%(c)s{4}-%(c)s{12}" % {"c": hexchar}
> + 
> +     def t_IDENTIFIER(self, t):
> +         r"(unsigned\ long\ long|unsigned\ short|unsigned\ long|long\ long)(?!_?[A-Za-z][A-Za-z_0-9])|_?[A-Za-z][A-Za-z_0-9]*"  # NOQA: E501
> +         t.type = self.keywords.get(t.value, "IDENTIFIER")
> +         return t
> + 
> +     def t_LCDATA(self, t):
> +-        r"(?s)%\{[ ]*C\+\+[ ]*\n(?P<cdata>.*?\n?)%\}[ ]*(C\+\+)?"
> ++        r"%\{[ ]*C\+\+[ ]*\n(?P<cdata>(\n|.)*?\n?)%\}[ ]*(C\+\+)?"
> +         t.type = "CDATA"
> +         t.value = t.lexer.lexmatch.group("cdata")
> +         t.lexer.lineno += t.value.count("\n")
> +         return t
> + 
> +     def t_INCLUDE(self, t):
> +         r'\#include[ \t]+"[^"\n]+"'
> +         inc, value, end = t.value.split('"')
> +
> 

-- 
Dmitry Marakasov   .
amdmi3@amdmi3.ru  ..:  https://github.com/AMDmi3  https://amdmi3.ru/