[issue15204] Deprecate the 'U' open mode
New submission from Serhiy Storchaka <storchaka@gmail.com>: 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. ---------- assignee: docs@python components: Documentation, IO, Library (Lib) messages: 164142 nosy: docs@python, storchaka priority: normal severity: normal status: open title: Deprecate the 'U' open mode type: behavior versions: Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- nosy: +gvanrossum, jackjansen, pitrou, stutzbach _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka <storchaka@gmail.com> added the comment: Related issues: #2091, #5148, #6759, #12900. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: Starting to deprecate "U" in the 3.3 docs sounds reasonable to me. ---------- nosy: +georg.brandl, nadeem.vawda _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
R. David Murray <rdmurray@bitdance.com> added the comment: 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. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka <storchaka@gmail.com> added the comment:
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). ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@GMail.Com>: ---------- nosy: +Arfrever _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- keywords: +patch Added file: http://bugs.python.org/file26197/deprecate-U-mode-stage1.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: Added file: http://bugs.python.org/file26198/deprecate-U-mode-stage2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Nadeem Vawda <nadeem.vawda@gmail.com> added the comment: +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? ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Chris Jerdonek <chris.jerdonek@gmail.com>: ---------- nosy: +cjerdonek _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Andrew Svetlov <andrew.svetlov@gmail.com>: ---------- nosy: +asvetlov _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Raymond Hettinger added the comment: 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. ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment:
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 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: 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. ---------- Added file: http://bugs.python.org/file27345/deprecate-U-mode-stage1_2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: Removed file: http://bugs.python.org/file26197/deprecate-U-mode-stage1.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Chris Jerdonek added the comment: 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? ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- stage: -> patch review versions: +Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Antoine Pitrou added the comment:
Would the deprecation need to be moved up to 3.4 though now?
Yes, I think so. ---------- versions: -Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: Here is an updated patch. I think we can combine 1 and 2 stages (change the documentation and add warnings). ---------- Added file: http://bugs.python.org/file31416/deprecate-U-mode.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Vajrasky Kok added the comment: http://bugs.python.org/review/15204/diff/9032/Tools/iobench/iobench.py Line 10 in New: import io But io module is never used. ---------- nosy: +vajrasky _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: Could anyone please review the patch? ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Guido van Rossum <guido@python.org>: ---------- nosy: -gvanrossum, jackjansen _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: Updated patch addresses Victor's comments. ---------- Added file: http://bugs.python.org/file32708/deprecate-U-mode_2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: Removed file: http://bugs.python.org/file26198/deprecate-U-mode-stage2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: Removed file: http://bugs.python.org/file27345/deprecate-U-mode-stage1_2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Martin Panter <vadmium+py@gmail.com>: ---------- nosy: +vadmium _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: Updated patch addresses Ezio's comments. ---------- Added file: http://bugs.python.org/file32809/deprecate-U-mode_3.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: Thanks Victor and Ezio for the reviews. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Roundup Robot added the comment: 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 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Roundup Robot added the comment: New changeset 2d5544afb510 by R David Murray in branch 'default': whatsnew: 'U' mode deprecation (#15204). http://hg.python.org/cpython/rev/2d5544afb510 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Василий Макаров added the comment: 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 :) ---------- nosy: +Василий.Макаров _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
Serhiy Storchaka added the comment: Please open new issue for this. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15204> _______________________________________
participants (14)
-
Andrew Svetlov
-
Antoine Pitrou
-
Arfrever Frehtes Taifersar Arahesis
-
Chris Jerdonek
-
Ezio Melotti
-
Guido van Rossum
-
Martin Panter
-
Nadeem Vawda
-
R. David Murray
-
Raymond Hettinger
-
Roundup Robot
-
Serhiy Storchaka
-
Vajrasky Kok
-
Василий Макаров