Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 607418 - sys-apps/portage: "DeprecationWarning: invalid escape sequence" warnings with Python 3.6
Summary: sys-apps/portage: "DeprecationWarning: invalid escape sequence" warnings with...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS, PATCH
Depends on:
Blocks: 611328
  Show dependency tree
 
Reported: 2017-01-27 18:55 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2017-05-20 18:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Use raw literals (portage-use_raw_literals.patch,12.10 KB, patch)
2017-01-31 07:47 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2017-01-27 18:55:52 UTC
Python 3.6 introduced "DeprecationWarning: invalid escape sequence" warnings.
The fix is to use raw literals (br"some bytes" or r"some string") or to escape '\'.

$ export PYTHONWARNINGS="d,i::ImportWarning"
$ python3.6 -c 'print("\d")'
<string>:1: DeprecationWarning: invalid escape sequence \d
\d
$ python3.6 -c 'print(b"\d")'
<string>:1: DeprecationWarning: invalid escape sequence \d
b'\\d'
$ python3.6 -c 'print(r"\d")'
\d
$ python3.6 -c 'print(br"\d")'
b'\\d'
$ python3.6 -c 'print("\\d")'
\d
$ python3.6 -c 'print(b"\\d")'
b'\\d'


In Portage:


$ python3.6 -c $'import sys\nfor x in sys.argv[1:]:\n with open(x, "rb") as f:\n  line = f.readline()\n  if line.startswith(b"#!") and b"python" in line:\n   f.seek(0, 0)\n   compile(f.read(), x, "exec")' $(find * -type f '!' -name '*.py')
bin/dispatch-conf:225: DeprecationWarning: invalid escape sequence \s
  for x in ['^[-+]\s*#', '^[-+]\s*$']:
bin/dispatch-conf:225: DeprecationWarning: invalid escape sequence \s
  for x in ['^[-+]\s*#', '^[-+]\s*$']:


$ python3.6 -m compileall *
...
Compiling 'bin/check-implicit-pointer-usage.py'...
bin/check-implicit-pointer-usage.py:22: DeprecationWarning: invalid escape sequence \d
  implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration "
bin/check-implicit-pointer-usage.py:25: DeprecationWarning: invalid escape sequence \d
  "([^:]*):(\d+): warning: "
bin/check-implicit-pointer-usage.py:30: DeprecationWarning: invalid escape sequence \d
  +  "|passing arg \d+ of `[^']*'"
bin/check-implicit-pointer-usage.py:31: DeprecationWarning: invalid escape sequence \d
  +  "|passing arg \d+ of pointer to function"
...
Compiling 'pym/_emerge/main.py'...
pym/_emerge/main.py:89: DeprecationWarning: invalid escape sequence \ 
  """
...
Compiling 'pym/portage/cvstree.py'...
pym/portage/cvstree.py:64: DeprecationWarning: invalid escape sequence \/
  rep = re.compile("^\/%s\/" % re.escape(filename))
pym/portage/cvstree.py:204: DeprecationWarning: invalid escape sequence \.
  ignore_list = re.compile("(^|/)(RCS(|LOG)|SCCS|CVS(|\.adm)|cvslog\..*|tags|TAGS|\.(make\.state|nse_depinfo)|.*~|(\.|)#.*|,.*|_$.*|.*\$|\.del-.*|.*\.(old|BAK|bak|orig|rej|a|olb|o|obj|so|exe|Z|elc|ln)|core)$")
...
Compiling 'pym/portage/glsa.py'...
pym/portage/glsa.py:213: DeprecationWarning: invalid escape sequence \s
  rValue = re.sub("[\s]{2,}", " ", rValue)
...
Compiling 'pym/portage/news.py'...
pym/portage/news.py:196: DeprecationWarning: invalid escape sequence \s
  _formatRE = re.compile("News-Item-Format:\s*([^\s]*)\s*$")
...
Compiling 'pym/portage/package/ebuild/fetch.py'...
pym/portage/package/ebuild/fetch.py:234: DeprecationWarning: invalid escape sequence \d
  _fetch_resume_size_re = re.compile('(^[\d]+)([KMGTPEZY]?$)')
...
Compiling 'pym/portage/tests/util/test_getconfig.py'...
pym/portage/tests/util/test_getconfig.py:61: DeprecationWarning: invalid escape sequence \E
  'LESS_TERMCAP_mb': "$\E[01;31m", # bug #410625
...
Compiling 'pym/portage/tests/util/test_varExpand.py'...
pym/portage/tests/util/test_varExpand.py:32: DeprecationWarning: invalid escape sequence \$
  """
...
Compiling 'pym/portage/util/__init__.py'...
pym/portage/util/__init__.py:712: DeprecationWarning: invalid escape sequence \:
  string.ascii_letters + "~!@#$%*_\:;?,./-+{}")
...
Compiling 'pym/portage/util/lafilefixer.py'...
pym/portage/util/lafilefixer.py:43: DeprecationWarning: invalid escape sequence \.
  pkgconfig_sub1 = re.compile(b"usr/lib[^/]*/pkgconfig/\.\./\.\.")
pym/portage/util/lafilefixer.py:44: DeprecationWarning: invalid escape sequence \.
  pkgconfig_sub2 = re.compile(b"(?P<usrlib>usr/lib[^/]*)/pkgconfig/\.\.")
pym/portage/util/lafilefixer.py:135: DeprecationWarning: invalid escape sequence \g
  ladir = pkgconfig_sub2.sub(b"\g<usrlib>", ladir)
...
Compiling 'pym/portage/xml/metadata.py'...
pym/portage/xml/metadata.py:136: DeprecationWarning: invalid escape sequence \s
  self.description = re.sub('\s+', ' ', _desc)
...
Compiling 'repoman/pym/repoman/modules/vcs/cvs/changes.py'...
repoman/pym/repoman/modules/vcs/cvs/changes.py:85: DeprecationWarning: invalid escape sequence \$
  headerstring = "'\$(Header|Id).*\$'"
Compiling 'repoman/pym/repoman/modules/vcs/cvs/status.py'...
repoman/pym/repoman/modules/vcs/cvs/status.py:67: DeprecationWarning: invalid escape sequence \?
  "egrep '^[^\?] .*' | "
...
Compiling 'repoman/pym/repoman/modules/vcs/svn/changes.py'...
repoman/pym/repoman/modules/vcs/svn/changes.py:113: DeprecationWarning: invalid escape sequence \$
  headerstring = "'\$(%s).*\$'" % "|".join(enabled_keywords)
...
Comment 1 Arfrever Frehtes Taifersar Arahesis 2017-01-31 07:47:57 UTC
Created attachment 461920 [details, diff]
Use raw literals
Comment 2 Zac Medico gentoo-dev 2017-01-31 18:13:10 UTC
Thanks, this is in the master branch:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=55ad426b76e66fbef88dca3274172f5a30903ae6
Comment 3 Zac Medico gentoo-dev 2017-05-20 18:14:57 UTC
Fixed in portage-2.3.5.