Elasticsearch-py: DeprecationWarning over invalid escape sequences

Created on 20 Jan 2020  路  6Comments  路  Source: elastic/elasticsearch-py

elasticsearch-py version (elasticsearch.__versionstr__): master branch

Description of the problem including expected versus actual behavior:

DeprecationWarning over invalid escape sequences. Escaping them or using raw string literals is preferred.

Steps to reproduce:

find . -iname '*.py' | xargs -P 4 -I{} python3.8 -Wall -m py_compile {}

./elasticsearch-py/test_elasticsearch/test_connection.py:330: DeprecationWarning: invalid escape sequence \?
  "^GET http://localhost:9200/\?param=42 \[status:500 request:0.[0-9]{3}s\]",
./elasticsearch-py/test_elasticsearch/test_connection.py:356: DeprecationWarning: invalid escape sequence \[
  '#\[200\] \(0.[0-9]{3}s\)\n#\{\n#  "answer": "that\\\\u0027s it!"\n#\}',
./elasticsearch-py/test_elasticsearch/test_connection.py:365: DeprecationWarning: invalid escape sequence \?
  "GET http://localhost:9200/\?param=42 \[status:200 request:0.[0-9]{3}s\]",
enhancement

Most helpful comment

Don't think so, thank yall for this :)

All 6 comments

Hi @tirkarthi, thanks for raising this issue. In which version of Python will these be deprecated in?

@alexk307 Python 3.8 deprecated these escape sequences.

Thanks @sethmlarson, I wasn't sure if 3.8 deprecated or just produced a deprecation warning for a future release.

The deprecation warning was present in Python 3.7 itself. In Python 3.8 it was made SyntaxWarning but the change was obtrusive to lot of libraries that it was made deprecation warning for few more releases before being converted into syntax warning in future and later an error. Upstream issue has more points : https://bugs.python.org/issue32912

Is this issue still relevant? I ran find . -iname '*.py' | xargs -P 4 -I{} python3.8 -Wall -m py_compile {} with the latest master commit and I got errors only from libraries. There is no error from elasticsearch-py itself.

$ find . -iname '*.py' | xargs -P 4 -I{} python3.8 -Wall -m py_compile {}
./.tox/lint/lib/python3.6/site-packages/toml/decoder.py:47: DeprecationWarning: invalid escape sequence \.
  TIME_RE = re.compile("([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{3,6}))?")
./venv/lib/python3.6/site-packages/toml/decoder.py:47: DeprecationWarning: invalid escape sequence \.
  TIME_RE = re.compile("([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{3,6}))?")

Don't think so, thank yall for this :)

Was this page helpful?
0 / 5 - 0 ratings