This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: Deprecate the 'U' open mode
Type: behavior Stage: resolved
Components: Documentation, IO, Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Arfrever, asvetlov, chris.jerdonek, docs@python, georg.brandl, martin.panter, nadeem.vawda, pitrou, python-dev, r.david.murray, rhettinger, serhiy.storchaka, stutzbach, vajrasky, Василий.Макаров
Priority: normal Keywords: patch

Created on 2012-06-27 10:29 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
deprecate-U-mode.patch serhiy.storchaka, 2013-08-22 07:27 review
deprecate-U-mode_2.patch serhiy.storchaka, 2013-11-19 21:58 review
deprecate-U-mode_3.patch serhiy.storchaka, 2013-11-23 19:47 review
Messages (22)
msg164142 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-27 10:29
Since Python 2.3 many open functions supports "Universal line mode" (PEP 278). Since 3.0 (and 2.6) PEP 3116 suggests better alternative -- io.TextWrapper.

Now support for the 'U' mode in the different open functions is heterogeneous. Some functions simply ignore the 'U' mode (but accept it), others perceive it as a synonym for text-mode, others just pass it on lower lever, other attempt to implement it, but the implementation is obtained imperfect and contradictory (as in ZipExtFile). The documentation for built-in open does not advise the use of the 'U' mode. The 'U' mode support cumbersome. I propose to deprecate the 'U' mode. If someone wanted to work with the universal line support, he'll surely need to work with encodings too, and io.TextWrapper provides is better choise.

The deprecation plan for the 'U' mode of open functions might be as follow:

3.3.  Deprecating the 'U' mode in docs for all opens (building open, io.open, codecs.open, gzip.open, ZipFile.open, etc). Add suggestion about io.TextWrapper.
3.4.  Raise a warning on use of the 'U' mode.
3.5.  Raise an exception on use of the 'U' mode.
3.6 (or 4.0?).  Remove the 'U' mode processing code.

As the first stage involves only the changes to the documentation, I hope deprecation can starts in 3.3.
msg164144 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-27 10:50
Related issues: #2091, #5148, #6759, #12900.
msg164145 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-27 10:53
Starting to deprecate "U" in the 3.3 docs sounds reasonable to me.
msg164153 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-06-27 13:31
Unless there are places where it is actually broken, I don't think there is a good reason to have step 3.5, though.  Just add the deprecation warning and remove it in 4.0.
msg164232 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-28 09:30
> Unless there are places where it is actually broken, I don't think there is a good reason to have step 3.5, though.  Just add the deprecation warning and remove it in 4.0.

Well. In any case, the 'U' mode in most cases has no effect, and the
code, where it has an effect (in zipfile), is very rarely used (and it
is actually complicated and broken).

Here are the patches for the first (documentation) and the second stage
(warnings).
msg164296 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-06-28 21:28
+1 for the general idea of deprecating and eventually removing the "U"
modes.

But I agree with David, that it doesn't make sense to have separate steps
for 3.5 and 3.6/4.0. If you make the code raise an exception when "U" is
used, how is that different from what will happen when you remove the
code for processing it? Surely we want it to eventually be treated just
like any other invalid mode string?
msg168247 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2012-08-15 00:41
The only people affected by deprecating "U" are the people who are currently using it for some reason -- presumably they are expecting that it does something useful for their code.

Ideally, this proposed deprecation should be mentioned on python-dev so that those folks will have an opportunity to respond.
msg171546 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-09-28 21:59
> Ideally, this proposed deprecation should be mentioned on python-dev so that those folks will have an opportunity to respond.

http://comments.gmane.org/gmane.comp.python.devel/134996
msg171547 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-09-28 22:02
Chris, you did a great job on improving the documentation (including about universal newlines). Can you help with this issue?

For the first stage should be clearly shown that "U" mode is not only should not be used in new code, but must be removed from the old code.

Stage 1 patch updated to resolve conflicts with Chris changes.
msg171549 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-09-28 23:28
Thanks, Serhiy. :)  Sure, I should be able to help with the documentation portion of this issue if the community is in agreement.  Would the deprecation need to be moved up to 3.4 though now?
msg179190 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-06 15:48
> Would the deprecation need to be moved up to 3.4 though now?

Yes, I think so.
msg195865 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-08-22 07:27
Here is an updated patch. I think we can combine 1 and 2 stages (change the documentation and add warnings).
msg195875 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-08-22 09:50
http://bugs.python.org/review/15204/diff/9032/Tools/iobench/iobench.py

Line 10 in New:
import io

But io module is never used.
msg203421 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-19 20:38
Could anyone please review the patch?
msg203432 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-19 21:58
Updated patch addresses Victor's comments.
msg204081 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-23 19:47
Updated patch addresses Ezio's comments.
msg204092 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-23 20:13
New changeset 70bd6f7e013b by Serhiy Storchaka in branch 'default':
Issue #15204: Deprecated the 'U' mode in file-like objects.
http://hg.python.org/cpython/rev/70bd6f7e013b
msg204094 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-23 20:14
Thanks Victor and Ezio for the reviews.
msg204269 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-24 21:13
New changeset 694e2708b4a8 by Serhiy Storchaka in branch 'default':
Issue #15204: Silence and check the 'U' mode deprecation warnings in tests.
http://hg.python.org/cpython/rev/694e2708b4a8
msg213002 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-10 01:35
New changeset 2d5544afb510 by R David Murray in branch 'default':
whatsnew: 'U' mode deprecation (#15204).
http://hg.python.org/cpython/rev/2d5544afb510
msg229527 - (view) Author: Василий Макаров (Василий.Макаров) Date: 2014-10-16 12:53
open() documentation is probably broken a little now. Here is what one can see at the end of open() description:
"...
Deprecated since version 3.4, will be removed in version 4.0.

The 'U' mode."

Reader may assume open() function is what will be removed. Which is frightening :)
msg229693 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-10-19 20:20
Please open new issue for this.
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59409
2014-10-19 20:20:15serhiy.storchakasetmessages: + msg229693
2014-10-16 12:53:09Василий.Макаровsetnosy: + Василий.Макаров
messages: + msg229527
2014-03-10 01:35:01python-devsetmessages: + msg213002
2013-11-24 21:15:30serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-11-24 21:13:49python-devsetmessages: + msg204269
2013-11-23 20:14:27serhiy.storchakasetmessages: + msg204094
2013-11-23 20:13:13python-devsetnosy: + python-dev
messages: + msg204092
2013-11-23 19:47:20serhiy.storchakasetfiles: + deprecate-U-mode_3.patch

messages: + msg204081
2013-11-20 22:39:38martin.pantersetnosy: + martin.panter
2013-11-20 07:50:58serhiy.storchakasetfiles: - deprecate-U-mode-stage1_2.patch
2013-11-20 07:49:59serhiy.storchakasetfiles: - deprecate-U-mode-stage2.patch
2013-11-19 21:58:11serhiy.storchakasetfiles: + deprecate-U-mode_2.patch

messages: + msg203432
2013-11-19 21:22:45gvanrossumsetnosy: - gvanrossum, jackjansen
2013-11-19 20:38:36serhiy.storchakasetmessages: + msg203421
2013-08-22 09:50:50vajraskysetnosy: + vajrasky
messages: + msg195875
2013-08-22 07:27:08serhiy.storchakasetfiles: + deprecate-U-mode.patch

messages: + msg195865
2013-01-06 15:48:26pitrousetmessages: + msg179190
versions: - Python 3.3
2013-01-06 05:27:15ezio.melottisetstage: patch review
versions: + Python 3.4
2012-09-28 23:28:52chris.jerdoneksetmessages: + msg171549
2012-09-28 22:03:00serhiy.storchakasetfiles: - deprecate-U-mode-stage1.patch
2012-09-28 22:02:50serhiy.storchakasetfiles: + deprecate-U-mode-stage1_2.patch

messages: + msg171547
2012-09-28 21:59:28serhiy.storchakasetmessages: + msg171546
2012-08-15 00:41:15rhettingersetnosy: + rhettinger
messages: + msg168247
2012-08-14 16:01:23asvetlovsetnosy: + asvetlov
2012-08-03 08:24:06chris.jerdoneksetnosy: + chris.jerdonek
2012-06-28 21:28:35nadeem.vawdasetmessages: + msg164296
2012-06-28 09:32:47serhiy.storchakasetfiles: + deprecate-U-mode-stage2.patch
2012-06-28 09:32:08serhiy.storchakasetfiles: + deprecate-U-mode-stage1.patch
keywords: + patch
2012-06-28 09:30:28serhiy.storchakasetmessages: + msg164232
2012-06-27 15:52:50Arfreversetnosy: + Arfrever
2012-06-27 13:31:01r.david.murraysetnosy: + r.david.murray
messages: + msg164153
2012-06-27 10:53:21pitrousetnosy: + georg.brandl, nadeem.vawda
messages: + msg164145
2012-06-27 10:50:57serhiy.storchakasetmessages: + msg164144
2012-06-27 10:32:30serhiy.storchakasetnosy: + gvanrossum, jackjansen, pitrou, stutzbach
2012-06-27 10:29:50serhiy.storchakacreate