VirusTotal / yara-python

The Python interface for YARA
http://virustotal.github.io/yara/
Apache License 2.0
648 stars 179 forks source link

Deprecation warning due to invalid escape sequences in Python 3.7 #138

Closed tirkarthi closed 4 years ago

tirkarthi commented 4 years ago

Deprecation warning due to invalid escape sequences in Python 3.7. These can be resolved using raw strings or escaping the sequences again. Also helpful fpr automated fixes : https://github.com/asottile/pyupgrade/

The command uses Python 3.8 but the deprecation warnings are present in Python 3.7 also.

find . -iname '*py' | grep -Ev 'setup|rdf4' | xargs -P4 -I{} python3.8 -Wall -m py_compile {}
./tests.py:143: DeprecationWarning: invalid escape sequence \s
  ('a[\s\S]b', 'a b', SUCCEED, 'a b'),
./tests.py:144: DeprecationWarning: invalid escape sequence \d
  ('a[\d\D]b', 'a1b', SUCCEED, 'a1b'),
./tests.py:164: DeprecationWarning: invalid escape sequence \]
  ('a[\]]b', 'a]b', SUCCEED, 'a]b'),
./tests.py:195: DeprecationWarning: invalid escape sequence \w
  ('a\wc', 'abc', SUCCEED, 'abc'),
./tests.py:196: DeprecationWarning: invalid escape sequence \w
  ('a\wc', 'a_c', SUCCEED, 'a_c'),
./tests.py:197: DeprecationWarning: invalid escape sequence \w
  ('a\wc', 'a0c', SUCCEED, 'a0c'),
./tests.py:198: DeprecationWarning: invalid escape sequence \w
  ('a\wc', 'a*c', FAIL),
./tests.py:199: DeprecationWarning: invalid escape sequence \w
  ('\w+', '--ab_cd0123--', SUCCEED, 'ab_cd0123'),
./tests.py:200: DeprecationWarning: invalid escape sequence \w
  ('[\w]+', '--ab_cd0123--', SUCCEED, 'ab_cd0123'),
./tests.py:201: DeprecationWarning: invalid escape sequence \D
  ('\D+', '1234abc5678', SUCCEED, 'abc'),
./tests.py:202: DeprecationWarning: invalid escape sequence \d
  ('[\d]+', '0123456789', SUCCEED, '0123456789'),
./tests.py:203: DeprecationWarning: invalid escape sequence \D
  ('[\D]+', '1234abc5678', SUCCEED, 'abc'),
./tests.py:204: DeprecationWarning: invalid escape sequence \d
  ('[\da-fA-F]+', '123abc', SUCCEED, '123abc'),
./tests.py:363: DeprecationWarning: invalid escape sequence \ 
  'rule test { condition: (1 + 1) * 2 == (9 - 1) \ 2 }',
./tests.py:366: DeprecationWarning: invalid escape sequence \ 
  'rule test { condition: 3 \ 2 == 1}',
./tests.py:367: DeprecationWarning: invalid escape sequence \ 
  'rule test { condition: 3.0 \ 2 == 1.5}',
./tests.py:658: DeprecationWarning: invalid escape sequence \.
  'rule test { strings: $a = /ppi\.mi/ condition: $a }',
tirkarthi commented 4 years ago

I will add a PR for this.