Skip to content

DeprecationWarning: invalid escape sequence #8940

@ColCarroll

Description

@ColCarroll

Description

On python 3.6, there are DeprecationWarning: : invalid escape sequences thrown in many places. See https://bugs.python.org/issue27364 for details. The warning is silent by default and, according to GvR, "we indeed need to take "several" releases before we go there." It seems like it is usually triggered by LaTeX docstrings, and can be fixed by making those strings raw strings (r'raw strings'), or doubling backslashes.

Happy to help start fixing, if a fix is desired at this point!

Steps/Code to Reproduce

You can see the silenced warnings now with the flags -Wd. Note that nosetests also will display the warnings, as will a pip-installed sklearn.

Example:

$ python -Wd
Python 3.6.0 (default, Feb 27 2017, 17:29:08)
>>> import sklearn

Expected Results

Running nosetests or the above should not print any DeprecationErrors

Actual Results

I've removed a few unrelated errors:

/scikit-learn/sklearn/__init__.py:22: DeprecationWarning: invalid escape sequence \.
  module='^{0}\.'.format(re.escape(__name__)))
/scikit-learn/sklearn/externals/joblib/func_inspect.py:53: DeprecationWarning: invalid escape sequence \<
  '\<doctest (.*\.rst)\[(.*)\]\>', source_file).groups()
/scikit-learn/sklearn/externals/joblib/_memory_helpers.py:10: DeprecationWarning: invalid escape sequence \s
  cookie_re = re.compile("coding[:=]\s*([-\w.]+)")

Versions

Darwin-16.6.0-x86_64-i386-64bit
Python 3.6.0 (default, Feb 27 2017, 17:29:08)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
NumPy 1.12.1
SciPy 0.19.0
Scikit-Learn 0.19.dev0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions