See attached patch regarding our development script cat.py. It fixes a Python 3 deprecation warning. However, I believe it changes behavior with Python 2. The script has a "python3" shebang line (see 3f03f0a447e), however that does not mean that it is not currently compatible with Python 2. Should I add a version check? i.e., use mode "rU" if Python 2, and mode "r" if Python 3?
Scott
From 3e81b02a659d8bc64823e9b4a292e88bb230aec0 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <[email protected]> Date: Thu, 19 Mar 2020 18:22:16 -0400 Subject: [PATCH] cat.py: fix Python deprecation warning This commit fixes the following warning: DeprecationWarning: 'U' mode is deprecated Removing 'U' has no effect with Python 3 [1]: There is an additional mode character permitted, 'U', which no longer has any effect, and is considered deprecated. It previously enabled universal newlines in text mode, which became the default behaviour in Python 3.0. [1] https://docs.python.org/3/library/functions.html?highlight=open#open --- development/cmake/po/cat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/development/cmake/po/cat.py b/development/cmake/po/cat.py index 0462b29c2f..ac1aad4de6 100644 --- a/development/cmake/po/cat.py +++ b/development/cmake/po/cat.py @@ -29,9 +29,10 @@ if outfile: out = open(outfile, "wb") for f in args: - # accept both windows and unix line endings, since it can happen that we - # are on unix, but the file has been written on windows or vice versa. - fil = open(f, "rU") + # Python 3 by default accepts both windows and unix line endings, since + # it can happen that we are on unix, but the file has been written on + # windows or vice versa. + fil = open(f, "r") for l in fil: # this does always write unix line endings since the file has # been opened in binary mode. This is needed since both gettext -- 2.20.1
signature.asc
Description: PGP signature
-- lyx-devel mailing list [email protected] http://lists.lyx.org/mailman/listinfo/lyx-devel
