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.

Author vstinner
Recipients serhiy.storchaka, vstinner
Date 2019-06-18.15:48:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560872905.7.0.609892598407.issue37330@roundup.psfhosted.org>
In-reply-to
Content
The builtin open() function accepts 'U' in the file mode, but it emits a DeprecationWarning since Python 3.4, change made in bpo-15204:

commit 6787a3806ee6a85a6f21ede70c10e15a6df267c4
Author: Serhiy Storchaka <storchaka@gmail.com>
Date:   Sat Nov 23 22:12:06 2013 +0200

    Issue #15204: Deprecated the 'U' mode in file-like objects.

$ cat x.py 
f = open(__file__, 'U')
line = f.readline()
print(type(line))
f.close()

$ python3.7 x.py 
x.py:1: DeprecationWarning: 'U' mode is deprecated
  f = open(__file__, 'U')
<class 'str'>

The 'U' mode is documented as deprecated since Python 3.3

The flag is basically only there for backward compatibility with Python 2. Python 3.9.0 final release is currently scheduled at 2020-06-08: 6 months after Python 2 end-of-life (2020-01-01).

Currently, the 'U' mode is documented as it will be removed from Python 4.0. But I dislike having a bunch of backward incompatible changes in Python 4.0. I would prefer Python 4.0 to be simply the version after Python 3.X.

Deprecation warnings are now displayed in the __main__ module by default, thanks to the PEP 565 -- Show DeprecationWarning in __main__.
https://www.python.org/dev/peps/pep-0565/

More and more projects run their test suite using -Werror and so have to fix deprecation warnings.
History
Date User Action Args
2019-06-18 15:48:25vstinnersetrecipients: + vstinner, serhiy.storchaka
2019-06-18 15:48:25vstinnersetmessageid: <1560872905.7.0.609892598407.issue37330@roundup.psfhosted.org>
2019-06-18 15:48:25vstinnerlinkissue37330 messages
2019-06-18 15:48:25vstinnercreate