I'm not using docutils directly, but it's used by a dependency. There will be an easier way to reproduce it, this is how I'm getting it with Python 3.7:
git clone https://github.com/python-pillow/Pillow && cd Pillow
pip install -e .
pip install pyroma
python Tests/test_pyroma.py
Results in:
<snip other warnings>
/usr/local/lib/python3.7/site-packages/docutils/io.py:245: DeprecationWarning: 'U' mode is deprecated
self.source = open(source_path, mode, **kwargs)
.
----------------------------------------------------------------------
Ran 1 test in 0.520s
OK
It is caused by the U in the mode here:
class FileInput(Input):
"""
Input for single, simple file-like objects.
"""
def __init__(self, source=None, source_path=None,
encoding=None, error_handler='strict',
autoclose=True, mode='rU', **kwargs):
Since Python 3.4, the 'U' universal newlines mode has been deprecated.
https://docs.python.org/3.4/library/functions.html#open
From Python 3.0-3.3, it has been labelled "for backwards compatibility; unneeded for new code".
https://docs.python.org/3.0/library/functions.html#open
Python 3.7.0
docutils 0.14
Smaller test case:
And run with deprecation warnings enabled:
It's probably a problem to remove it because docutils still supports python2.
Shouldn't it then be handled by 2to3 ?
"Stéphane Blondon" stephaneb@users.sourceforge.net schrieb am Sa., 11.
Aug. 2018, 14:50:
Related
Bugs:
#3482to3 does not have a fixer for this issue, as it was written to fix issues when migrating from py2.x to 3.0 and using the "U" mode started throwing DeprecatedWarning only in 3.4.
It's possible to write a custom fixer, or course.
Maybe something along the lines of this?
mode = 'r' if sys.version_info >= (3, 4) else 'rU'I've created a patch with this suggestion:
https://sourceforge.net/p/docutils/patches/144/
thanks and all the best