When we remove 'U' mode of open()?

'U' mode was removed once and resurrected. https://bugs.python.org/issue39674 As far as I can see, it is postponed to Python 3.10. Am I right? Can we remove 'U' mode in Python 3.10? Regards, -- Inada Naoki <songofacandy@gmail.com>

On 07. 04. 21 14:53, Inada Naoki wrote:
'U' mode was removed once and resurrected. https://bugs.python.org/issue39674
As far as I can see, it is postponed to Python 3.10. Am I right? Can we remove 'U' mode in Python 3.10?
What is the benefit of doing it? Is the current compatibility layer to do nothing when "U" is passed difficult to maintain? -- Miro Hrončok -- Phone: +420777974800 IRC: mhroncok

On Wed, Apr 7, 2021 at 11:29 PM Miro Hrončok <mhroncok@redhat.com> wrote:
On 07. 04. 21 14:53, Inada Naoki wrote:
'U' mode was removed once and resurrected. https://bugs.python.org/issue39674
As far as I can see, it is postponed to Python 3.10. Am I right? Can we remove 'U' mode in Python 3.10?
What is the benefit of doing it? Is the current compatibility layer to do nothing when "U" is passed difficult to maintain?
I am working on fileinput module: * https://bugs.python.org/issue43712 * https://bugs.python.org/issue5758 * https://bugs.python.org/issue36865 It supports deprecated 'U' mode for now, same to builtin open(). When I read and write code and tests, I need to pay attention about all allowed combination of mode string. It is not difficult to maintain, but it has significant support cost. If we don't remove it forever, accumulated cost would be very high than users think. It is technical debt. Regards, -- Inada Naoki <songofacandy@gmail.com>

On Wed, 7 Apr 2021 23:44:18 +0900 Inada Naoki <songofacandy@gmail.com> wrote:
On Wed, Apr 7, 2021 at 11:29 PM Miro Hrončok <mhroncok@redhat.com> wrote:
On 07. 04. 21 14:53, Inada Naoki wrote:
'U' mode was removed once and resurrected. https://bugs.python.org/issue39674
As far as I can see, it is postponed to Python 3.10. Am I right? Can we remove 'U' mode in Python 3.10?
What is the benefit of doing it? Is the current compatibility layer to do nothing when "U" is passed difficult to maintain?
I am working on fileinput module:
* https://bugs.python.org/issue43712 * https://bugs.python.org/issue5758 * https://bugs.python.org/issue36865
It supports deprecated 'U' mode for now, same to builtin open(). When I read and write code and tests, I need to pay attention about all allowed combination of mode string.
You can already remove 'U' from fileinput with necessarily removing it from open(). Regards Antoine.

Hi Inada-san, I'm +0 on removing again the flag, but I would prefer to not endorse the responsibility. I am already responsible for enough incompatible changes in Python 3.10 :-D Some context on this "U" open mode. The flag is accepted by many functions opening files. It is deprecated (emit DeprecationWarning) for 9 years (Python 3.3, 2012). The flag is currently ignored and is basically only kept for backward compatibility with Python 2, whereas Python 2.7 support ended in January 2020 (1 year ago). I removed the flag in Python 3.9: * https://bugs.python.org/issue37330 * https://github.com/python/cpython/commit/e471e72977c83664f13d041c78549140c86... The removal broke the Waf build system used by the Samba project. Waf code is copied into Samba source code (as Python copies autoconf/automake files). So even if Waf and then the Waf copy in Samba are updated to not pass the "U" flag, trying to build an old Samba version will fail if the flag is removed. Andrew Bartlett explained that it's a practical issue when bisecting a bug in Samba. It's annoying, but likely easy to workaround (fix the local waf copy temporarily). Moreover, the removal broke 11 packages in Fedora: * aubio * openvswitch * python-SALib * python-altgraph * python-apsw * python-magic-wormhole-mailbox-server * python-munch * python-parameterized * python-pylibmc * python-sphinx-testing * veusz Miro Hrončok and me proposed to revert the removal in Python 3.9: https://mail.python.org/archives/list/python-dev@python.org/thread/EYLXCGGJO... The removal was reverted (accept again the flag) in Python 3.9: * https://bugs.python.org/issue39674#msg363195 * https://github.com/python/cpython/commit/942f7a2dea2e95a0fa848329565c0d0288d... LWN article summarizing the issue: https://lwn.net/Articles/811369/ I added a section at the very beginning of What's New in Python 3.9 to request developers to check for DeprecationWarning in their project: https://docs.python.org/dev/whatsnew/3.9.html#you-should-check-for-deprecati... The idea was that Python 3.9 is the last version supporting the flag, developers are now warned, and so the flag should be removed from Python 3.10. That being said, I'm kind of cautious. Each time I introduce a minor incompatible change breaking a few projects (say 5 projects or less), many people get angry and complain without trying to understand the rationale. Moreover, they are silent when I say that there was a DeprecationWarning for 9 years. I didn't check if the 11 projects + waf + samba have been updated to no longer pass the deprecated "U" flag. Victor -- Night gathers, and now my watch begins. It shall not end until my death.

07.04.21 19:13, Victor Stinner пише:
Hi Inada-san,
I'm +0 on removing again the flag, but I would prefer to not endorse the responsibility. I am already responsible for enough incompatible changes in Python 3.10 :-D
Some context on this "U" open mode. The flag is accepted by many functions opening files. It is deprecated (emit DeprecationWarning) for 9 years (Python 3.3, 2012).
It was silently deprecated before 3.3 (perhaps it was no-op since 3.0). I added DeprecationWarning with intention to remove this option in all functions accepting it. The only non-trivial support of the "U" mode was left in ZipFile.open(), and it was broken since beginning.

On Wed, Apr 7, 2021 at 10:01 AM Serhiy Storchaka <storchaka@gmail.com> wrote:
07.04.21 19:13, Victor Stinner пише:
Hi Inada-san,
I'm +0 on removing again the flag, but I would prefer to not endorse the responsibility. I am already responsible for enough incompatible changes in Python 3.10 :-D
Some context on this "U" open mode. The flag is accepted by many functions opening files. It is deprecated (emit DeprecationWarning) for 9 years (Python 3.3, 2012).
It was silently deprecated before 3.3 (perhaps it was no-op since 3.0).
I added DeprecationWarning with intention to remove this option in all functions accepting it. The only non-trivial support of the "U" mode was left in ZipFile.open(), and it was broken since beginning.
I think at this point the DeprecationWarning has definitely been on long enough, there was an explicit warning about it in Python 3.9, and 3.10 will be nearly 2 years removed from 2.7 reaching EOL which is the only place where "U" may still be used. So I think it's fine to drop "U" in 3.10.

We are close to 3.10 beta and it is not ideal timing for removing. So my proposal is: * Remove 'U' in fileinput, because it makes my task little simpler. * Remove 'U' in other places in Python 3.11, after 3.10 branch is created (and master branch is renamed to main). On Thu, Apr 8, 2021 at 5:45 AM Brett Cannon <brett@python.org> wrote:
On Wed, Apr 7, 2021 at 10:01 AM Serhiy Storchaka <storchaka@gmail.com> wrote:
07.04.21 19:13, Victor Stinner пише:
Hi Inada-san,
I'm +0 on removing again the flag, but I would prefer to not endorse the responsibility. I am already responsible for enough incompatible changes in Python 3.10 :-D
Some context on this "U" open mode. The flag is accepted by many functions opening files. It is deprecated (emit DeprecationWarning) for 9 years (Python 3.3, 2012).
It was silently deprecated before 3.3 (perhaps it was no-op since 3.0).
I added DeprecationWarning with intention to remove this option in all functions accepting it. The only non-trivial support of the "U" mode was left in ZipFile.open(), and it was broken since beginning.
I think at this point the DeprecationWarning has definitely been on long enough, there was an explicit warning about it in Python 3.9, and 3.10 will be nearly 2 years removed from 2.7 reaching EOL which is the only place where "U" may still be used. So I think it's fine to drop "U" in 3.10. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/VTROKN5U... Code of Conduct: http://python.org/psf/codeofconduct/
-- Inada Naoki <songofacandy@gmail.com>

On Thu, Apr 8, 2021 at 9:54 AM Inada Naoki <songofacandy@gmail.com> wrote:
We are close to 3.10 beta and it is not ideal timing for removing. So my proposal is:
* Remove 'U' in fileinput, because it makes my task little simpler. * Remove 'U' in other places in Python 3.11, after 3.10 branch is created (and master branch is renamed to main).
I rejected bpo-36865, and created a pull request fixing bpo-5758 and bpo-43712 without touching the `mode`. There is no need to remove 'U' soon from fileinput too. We can remove them all in Python 3.11. https://bugs.python.org/issue36865 https://bugs.python.org/issue5758 https://bugs.python.org/issue43712 https://github.com/python/cpython/pull/25272 -- Inada Naoki <songofacandy@gmail.com>

That sounds reasonable ;-) Victor On Thu, Apr 8, 2021 at 3:02 AM Inada Naoki <songofacandy@gmail.com> wrote:
We are close to 3.10 beta and it is not ideal timing for removing. So my proposal is:
* Remove 'U' in fileinput, because it makes my task little simpler. * Remove 'U' in other places in Python 3.11, after 3.10 branch is created (and master branch is renamed to main).
On Thu, Apr 8, 2021 at 5:45 AM Brett Cannon <brett@python.org> wrote:
On Wed, Apr 7, 2021 at 10:01 AM Serhiy Storchaka <storchaka@gmail.com> wrote:
07.04.21 19:13, Victor Stinner пише:
Hi Inada-san,
I'm +0 on removing again the flag, but I would prefer to not endorse the responsibility. I am already responsible for enough incompatible changes in Python 3.10 :-D
Some context on this "U" open mode. The flag is accepted by many functions opening files. It is deprecated (emit DeprecationWarning) for 9 years (Python 3.3, 2012).
It was silently deprecated before 3.3 (perhaps it was no-op since 3.0).
I added DeprecationWarning with intention to remove this option in all functions accepting it. The only non-trivial support of the "U" mode was left in ZipFile.open(), and it was broken since beginning.
I think at this point the DeprecationWarning has definitely been on long enough, there was an explicit warning about it in Python 3.9, and 3.10 will be nearly 2 years removed from 2.7 reaching EOL which is the only place where "U" may still be used. So I think it's fine to drop "U" in 3.10. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/VTROKN5U... Code of Conduct: http://python.org/psf/codeofconduct/
-- Inada Naoki <songofacandy@gmail.com> _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/NYVORKRS... Code of Conduct: http://python.org/psf/codeofconduct/
-- Night gathers, and now my watch begins. It shall not end until my death.
participants (6)
-
Antoine Pitrou
-
Brett Cannon
-
Inada Naoki
-
Miro Hrončok
-
Serhiy Storchaka
-
Victor Stinner