Re: [gentoo-portage-dev] [PATCH 1/3] Add cached portage.getpid() function

2020-08-07 Thread Michał Górny
On Fri, 2020-08-07 at 21:08 -0700, Zac Medico wrote:
> Since getpid is a syscall, cache results, and update them
> via an after fork hook.
> 
> Signed-off-by: Zac Medico 
> ---
>  lib/portage/__init__.py   | 14 +++
>  .../tests/process/test_AsyncFunction.py   | 24 +++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py
> index 916c93510..52902ba7d 100644
> --- a/lib/portage/__init__.py
> +++ b/lib/portage/__init__.py
> @@ -14,6 +14,7 @@ try:
>   if not hasattr(errno, 'ESTALE'):
>   # ESTALE may not be defined on some systems, such as interix.
>   errno.ESTALE = -1
> + import multiprocessing.util
>   import re
>   import types
>   import platform
> @@ -368,6 +369,19 @@ _internal_caller = False
>  
>  _sync_mode = False
>  
> +def _fork_watcher(_fork_watcher):
> + _fork_watcher.current_pid = _os.getpid()

I don't really like the idea of putting variables on functions.  Would
there be any problem with using a proper class here?

> +
> +_fork_watcher(_fork_watcher)
> +
> +multiprocessing.util.register_after_fork(_fork_watcher, _fork_watcher)
> +
> +def getpid():
> + """
> + Cached version of os.getpid(). ForkProcess updates the cache.
> + """
> + return _fork_watcher.current_pid
> +
>  def _get_stdin():
>   """
>   Buggy code in python's multiprocessing/process.py closes sys.stdin
> diff --git a/lib/portage/tests/process/test_AsyncFunction.py 
> b/lib/portage/tests/process/test_AsyncFunction.py
> index 55857026d..3b360e02f 100644
> --- a/lib/portage/tests/process/test_AsyncFunction.py
> +++ b/lib/portage/tests/process/test_AsyncFunction.py
> @@ -3,6 +3,7 @@
>  
>  import sys
>  
> +import portage
>  from portage import os
>  from portage.tests import TestCase
>  from portage.util._async.AsyncFunction import AsyncFunction
> @@ -36,3 +37,26 @@ class AsyncFunctionTestCase(TestCase):
>   def testAsyncFunctionStdin(self):
>   loop = asyncio._wrap_loop()
>   loop.run_until_complete(self._testAsyncFunctionStdin(loop))
> +
> + def _test_getpid_fork(self):
> + """
> + Verify that portage.getpid() cache is updated in a forked child 
> process.
> + """
> + loop = asyncio._wrap_loop()
> + proc = AsyncFunction(scheduler=loop, target=portage.getpid)
> + proc.start()
> + proc.wait()
> + self.assertEqual(proc.pid, proc.result)
> +
> + def test_getpid_fork(self):
> + self._test_getpid_fork()
> +
> + def test_getpid_double_fork(self):
> + """
> + Verify that portage.getpid() cache is updated correctly after
> + two forks.
> + """
> + loop = asyncio._wrap_loop()
> + proc = AsyncFunction(scheduler=loop, 
> target=self._test_getpid_fork)
> + proc.start()
> + self.assertEqual(proc.wait(), 0)

-- 
Best regards,
Michał Górny



signature.asc
Description: This is a digitally signed message part


[gentoo-portage-dev] [PATCH 0/3] sqlite: fork safety (bug 736334)

2020-08-07 Thread Zac Medico
Use a separate connection instance for each pid, since
it is not safe to use a connection created in a parent
process.

See: https://www.sqlite.org/howtocorrupt.html
Bug: https://bugs.gentoo.org/736334

Zac Medico (3):
  Add cached portage.getpid() function
  sqlite: add lazy connection init
  sqlite: fork safety (bug 736334)

 lib/portage/__init__.py   | 14 +
 lib/portage/cache/sqlite.py   | 30 +++
 lib/portage/tests/dbapi/test_auxdb.py | 13 ++--
 .../tests/process/test_AsyncFunction.py   | 24 +++
 4 files changed, 74 insertions(+), 7 deletions(-)

-- 
2.25.3




[gentoo-portage-dev] [PATCH 3/3] sqlite: fork safety (bug 736334)

2020-08-07 Thread Zac Medico
Use a separate connection instance for each pid, since
it is not safe to use a connection created in a parent
process.

See: https://www.sqlite.org/howtocorrupt.html
Bug: https://bugs.gentoo.org/736334
Signed-off-by: Zac Medico 
---
 lib/portage/cache/sqlite.py   |  9 +
 lib/portage/tests/dbapi/test_auxdb.py | 13 +++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/lib/portage/cache/sqlite.py b/lib/portage/cache/sqlite.py
index 0395dd516..36a4f049e 100644
--- a/lib/portage/cache/sqlite.py
+++ b/lib/portage/cache/sqlite.py
@@ -4,6 +4,7 @@
 import collections
 import re
 
+import portage
 from portage.cache import fs_template
 from portage.cache import cache_errors
 from portage import os
@@ -25,7 +26,7 @@ class database(fs_template.FsBased):
cache_bytes = 1024 * 1024 * 10
 
_connection_info_entry = 
collections.namedtuple('_connection_info_entry',
-   ('connection', 'cursor'))
+   ('connection', 'cursor', 'pid'))
 
def __init__(self, *args, **config):
super(database, self).__init__(*args, **config)
@@ -71,13 +72,13 @@ class database(fs_template.FsBased):
 
@property
def _db_cursor(self):
-   if self._db_connection_info is None:
+   if self._db_connection_info is None or 
self._db_connection_info.pid != portage.getpid():
self._db_init_connection()
return self._db_connection_info.cursor
 
@property
def _db_connection(self):
-   if self._db_connection_info is None:
+   if self._db_connection_info is None or 
self._db_connection_info.pid != portage.getpid():
self._db_init_connection()
return self._db_connection_info.connection
 
@@ -94,7 +95,7 @@ class database(fs_template.FsBased):
connection = self._db_module.connect(
database=_unicode_decode(self._dbpath), 
**connection_kwargs)
cursor = connection.cursor()
-   self._db_connection_info = 
self._connection_info_entry(connection, cursor)
+   self._db_connection_info = 
self._connection_info_entry(connection, cursor, portage.getpid())
self._db_cursor.execute("PRAGMA encoding = %s" % 
self._db_escape_string("UTF-8"))
if not self.readonly and not 
self._ensure_access(self._dbpath):
raise 
cache_errors.InitializationError(self.__class__, "can't ensure perms on %s" % 
self._dbpath)
diff --git a/lib/portage/tests/dbapi/test_auxdb.py 
b/lib/portage/tests/dbapi/test_auxdb.py
index 5c79357d7..7865c3564 100644
--- a/lib/portage/tests/dbapi/test_auxdb.py
+++ b/lib/portage/tests/dbapi/test_auxdb.py
@@ -4,7 +4,8 @@
 from portage.tests import TestCase
 from portage.tests.resolver.ResolverPlayground import ResolverPlayground
 from portage.util.futures import asyncio
-from portage.util.futures.compat_coroutine import coroutine
+from portage.util.futures.compat_coroutine import coroutine, coroutine_return
+from portage.util.futures.executor.fork import ForkExecutor
 
 
 class AuxdbTestCase(TestCase):
@@ -61,8 +62,14 @@ class AuxdbTestCase(TestCase):
 
portdb = playground.trees[playground.eroot]["porttree"].dbapi
 
+   def test_func():
+   return 
asyncio._wrap_loop().run_until_complete(self._test_mod_async(
+   ebuilds, ebuild_inherited, 
eclass_defined_phases, eclass_depend, portdb))
+
+   self.assertTrue(test_func())
+
loop = asyncio._wrap_loop()
-   loop.run_until_complete(self._test_mod_async(ebuilds, 
ebuild_inherited, eclass_defined_phases, eclass_depend, portdb))
+   
self.assertTrue(loop.run_until_complete(loop.run_in_executor(ForkExecutor(), 
test_func)))
 
@coroutine
def _test_mod_async(self, ebuilds, ebuild_inherited, 
eclass_defined_phases, eclass_depend, portdb):
@@ -73,3 +80,5 @@ class AuxdbTestCase(TestCase):
self.assertEqual(depend, eclass_depend)
self.assertEqual(eapi, metadata['EAPI'])
self.assertEqual(frozenset(inherited.split()), 
ebuild_inherited)
+
+   coroutine_return(True)
-- 
2.25.3




[gentoo-portage-dev] [PATCH 1/3] Add cached portage.getpid() function

2020-08-07 Thread Zac Medico
Since getpid is a syscall, cache results, and update them
via an after fork hook.

Signed-off-by: Zac Medico 
---
 lib/portage/__init__.py   | 14 +++
 .../tests/process/test_AsyncFunction.py   | 24 +++
 2 files changed, 38 insertions(+)

diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py
index 916c93510..52902ba7d 100644
--- a/lib/portage/__init__.py
+++ b/lib/portage/__init__.py
@@ -14,6 +14,7 @@ try:
if not hasattr(errno, 'ESTALE'):
# ESTALE may not be defined on some systems, such as interix.
errno.ESTALE = -1
+   import multiprocessing.util
import re
import types
import platform
@@ -368,6 +369,19 @@ _internal_caller = False
 
 _sync_mode = False
 
+def _fork_watcher(_fork_watcher):
+   _fork_watcher.current_pid = _os.getpid()
+
+_fork_watcher(_fork_watcher)
+
+multiprocessing.util.register_after_fork(_fork_watcher, _fork_watcher)
+
+def getpid():
+   """
+   Cached version of os.getpid(). ForkProcess updates the cache.
+   """
+   return _fork_watcher.current_pid
+
 def _get_stdin():
"""
Buggy code in python's multiprocessing/process.py closes sys.stdin
diff --git a/lib/portage/tests/process/test_AsyncFunction.py 
b/lib/portage/tests/process/test_AsyncFunction.py
index 55857026d..3b360e02f 100644
--- a/lib/portage/tests/process/test_AsyncFunction.py
+++ b/lib/portage/tests/process/test_AsyncFunction.py
@@ -3,6 +3,7 @@
 
 import sys
 
+import portage
 from portage import os
 from portage.tests import TestCase
 from portage.util._async.AsyncFunction import AsyncFunction
@@ -36,3 +37,26 @@ class AsyncFunctionTestCase(TestCase):
def testAsyncFunctionStdin(self):
loop = asyncio._wrap_loop()
loop.run_until_complete(self._testAsyncFunctionStdin(loop))
+
+   def _test_getpid_fork(self):
+   """
+   Verify that portage.getpid() cache is updated in a forked child 
process.
+   """
+   loop = asyncio._wrap_loop()
+   proc = AsyncFunction(scheduler=loop, target=portage.getpid)
+   proc.start()
+   proc.wait()
+   self.assertEqual(proc.pid, proc.result)
+
+   def test_getpid_fork(self):
+   self._test_getpid_fork()
+
+   def test_getpid_double_fork(self):
+   """
+   Verify that portage.getpid() cache is updated correctly after
+   two forks.
+   """
+   loop = asyncio._wrap_loop()
+   proc = AsyncFunction(scheduler=loop, 
target=self._test_getpid_fork)
+   proc.start()
+   self.assertEqual(proc.wait(), 0)
-- 
2.25.3




[gentoo-portage-dev] [PATCH 2/3] sqlite: add lazy connection init

2020-08-07 Thread Zac Medico
Signed-off-by: Zac Medico 
---
 lib/portage/cache/sqlite.py | 29 -
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/lib/portage/cache/sqlite.py b/lib/portage/cache/sqlite.py
index 55ae8f0e5..0395dd516 100644
--- a/lib/portage/cache/sqlite.py
+++ b/lib/portage/cache/sqlite.py
@@ -1,6 +1,7 @@
 # Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
+import collections
 import re
 
 from portage.cache import fs_template
@@ -23,6 +24,9 @@ class database(fs_template.FsBased):
# equation: cache_bytes = page_bytes * page_count
cache_bytes = 1024 * 1024 * 10
 
+   _connection_info_entry = 
collections.namedtuple('_connection_info_entry',
+   ('connection', 'cursor'))
+
def __init__(self, *args, **config):
super(database, self).__init__(*args, **config)
self._import_sqlite()
@@ -44,8 +48,8 @@ class database(fs_template.FsBased):
# Set longer timeout for throwing a "database is locked" 
exception.
# Default timeout in sqlite3 module is 5.0 seconds.
config.setdefault("timeout", 15)
-   self._db_init_connection(config)
-   self._db_init_structures()
+   self._config = config
+   self._db_connection_info = None
 
def _import_sqlite(self):
# sqlite3 is optional with >=python-2.5
@@ -65,7 +69,20 @@ class database(fs_template.FsBased):
s = str(s)
return "'%s'" % s.replace("'", "''")
 
-   def _db_init_connection(self, config):
+   @property
+   def _db_cursor(self):
+   if self._db_connection_info is None:
+   self._db_init_connection()
+   return self._db_connection_info.cursor
+
+   @property
+   def _db_connection(self):
+   if self._db_connection_info is None:
+   self._db_init_connection()
+   return self._db_connection_info.connection
+
+   def _db_init_connection(self):
+   config = self._config
self._dbpath = self.location + ".sqlite"
#if os.path.exists(self._dbpath):
#   os.unlink(self._dbpath)
@@ -74,14 +91,16 @@ class database(fs_template.FsBased):
try:
if not self.readonly:
self._ensure_dirs()
-   self._db_connection = self._db_module.connect(
+   connection = self._db_module.connect(
database=_unicode_decode(self._dbpath), 
**connection_kwargs)
-   self._db_cursor = self._db_connection.cursor()
+   cursor = connection.cursor()
+   self._db_connection_info = 
self._connection_info_entry(connection, cursor)
self._db_cursor.execute("PRAGMA encoding = %s" % 
self._db_escape_string("UTF-8"))
if not self.readonly and not 
self._ensure_access(self._dbpath):
raise 
cache_errors.InitializationError(self.__class__, "can't ensure perms on %s" % 
self._dbpath)
self._db_init_cache_size(config["cache_bytes"])
self._db_init_synchronous(config["synchronous"])
+   self._db_init_structures()
except self._db_error as e:
raise cache_errors.InitializationError(self.__class__, 
e)
 
-- 
2.25.3




Re: [gentoo-portage-dev] [PATCH] lib/*: Fix useless-return

2020-08-07 Thread Zac Medico
On 8/7/20 12:06 PM, Aaron Bauman wrote:
> * Python implies such things. Let's drop 'em and be consistent.
> 
> Signed-off-by: Aaron Bauman 
> ---
>  lib/_emerge/EbuildPhase.py | 6 +++---
>  lib/_emerge/resolver/output.py | 5 +
>  lib/portage/elog/mod_custom.py | 1 +
>  lib/portage/elog/mod_echo.py   | 4 ++--
>  lib/portage/elog/mod_mail.py   | 2 ++
>  lib/portage/glsa.py| 3 +++
>  lib/portage/mail.py| 1 +
>  lib/portage/sync/controller.py | 3 ++-
>  lib/portage/util/whirlpool.py  | 2 ++
>  pylintrc   | 1 -
>  10 files changed, 21 insertions(+), 7 deletions(-)

Thanks, merged:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=28ed2fe2ba42c7e58cb79e7ce991025e6a96
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


[gentoo-portage-dev] [PATCH] lib/*: Fix useless-return

2020-08-07 Thread Aaron Bauman
* Python implies such things. Let's drop 'em and be consistent.

Signed-off-by: Aaron Bauman 
---
 lib/_emerge/EbuildPhase.py | 6 +++---
 lib/_emerge/resolver/output.py | 5 +
 lib/portage/elog/mod_custom.py | 1 +
 lib/portage/elog/mod_echo.py   | 4 ++--
 lib/portage/elog/mod_mail.py   | 2 ++
 lib/portage/glsa.py| 3 +++
 lib/portage/mail.py| 1 +
 lib/portage/sync/controller.py | 3 ++-
 lib/portage/util/whirlpool.py  | 2 ++
 pylintrc   | 1 -
 10 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index ceffeccee..e6256d0aa 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -9,12 +9,11 @@ import tempfile
 
 from _emerge.AsynchronousLock import AsynchronousLock
 from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
-from _emerge.CompositeTask import CompositeTask
-from _emerge.EbuildProcess import EbuildProcess
 from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
+from _emerge.EbuildProcess import EbuildProcess
+from _emerge.CompositeTask import CompositeTask
 from _emerge.PackagePhase import PackagePhase
 from _emerge.TaskSequence import TaskSequence
-
 from portage.package.ebuild._ipc.QueryCommand import QueryCommand
 from portage.util._dyn_libs.soname_deps_qa import (
_get_all_provides,
@@ -397,6 +396,7 @@ class EbuildPhase(CompositeTask):
fd_pipes=self.fd_pipes, phase=phase, 
scheduler=self.scheduler,
settings=self.settings)
self._start_task(clean_phase, self._fail_clean_exit)
+   return
 
def _fail_clean_exit(self, clean_phase):
self._final_exit(clean_phase)
diff --git a/lib/_emerge/resolver/output.py b/lib/_emerge/resolver/output.py
index b6c77ecad..1dcb47020 100644
--- a/lib/_emerge/resolver/output.py
+++ b/lib/_emerge/resolver/output.py
@@ -243,6 +243,7 @@ class Display:
cur_use_map[key], old_iuse_map[key],
old_use_map[key], is_new, feature_flags,
reinst_flags_map.get(key))
+   return
 
 
@staticmethod
@@ -538,6 +539,7 @@ class Display:
if show_repos and repoadd:
myprint += " " + teal("[%s]" % repoadd)
writemsg_stdout("%s\n" % (myprint,), noiselevel=-1)
+   return
 
 
def print_blockers(self):
@@ -546,6 +548,7 @@ class Display:
"""
for pkg in self.blockers:
writemsg_stdout("%s\n" % (pkg,), noiselevel=-1)
+   return
 
 
def print_verbose(self, show_repos):
@@ -559,6 +562,7 @@ class Display:
# that RepoDisplay.__unicode__() is called in python2.
writemsg_stdout("%s" % (self.conf.repo_display,),
noiselevel=-1)
+   return
 
 
def print_changelog(self):
@@ -683,6 +687,7 @@ class Display:
if ebuild_path_cl is not None:
self.changelogs.extend(_calc_changelog(
ebuild_path_cl, pkg_info.previous_pkg, 
pkg.cpv))
+   return
 
 
def check_system_world(self, pkg):
diff --git a/lib/portage/elog/mod_custom.py b/lib/portage/elog/mod_custom.py
index aaf1d3b1b..7cfafeccc 100644
--- a/lib/portage/elog/mod_custom.py
+++ b/lib/portage/elog/mod_custom.py
@@ -18,3 +18,4 @@ def process(mysettings, key, logentries, fulltext):
retval = portage.process.spawn_bash(mylogcmd)
if retval != 0:
raise portage.exception.PortageException("!!! 
PORTAGE_ELOG_COMMAND failed with exitcode %d" % retval)
+   return
diff --git a/lib/portage/elog/mod_echo.py b/lib/portage/elog/mod_echo.py
index a026847b7..80f2b11ac 100644
--- a/lib/portage/elog/mod_echo.py
+++ b/lib/portage/elog/mod_echo.py
@@ -3,10 +3,9 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
-
+from portage.output import EOutput, colorize
 from portage.const import EBUILD_PHASES
 from portage.localization import _
-from portage.output import EOutput, colorize
 
 
 _items = []
@@ -62,3 +61,4 @@ def _finalize():
for line in msgcontent:
fmap[msgtype](line.strip("\n"))
_items = []
+   return
diff --git a/lib/portage/elog/mod_mail.py b/lib/portage/elog/mod_mail.py
index f737a80ce..38eaa277f 100644
--- a/lib/portage/elog/mod_mail.py
+++ b/lib/portage/elog/mod_mail.py
@@ -41,3 +41,5 @@ def process(mysettings, key, logentries, fulltext):
portage.mail.send_mail(mysettings, mymessage)
except PortageException as e:
writemsg("%s\n" % str(e), noiselevel=-1)
+
+   return
diff --git a/lib/portage/glsa.py 

Re: [gentoo-portage-dev] [PATCH] lib/*: Fix useless-return

2020-08-07 Thread Aaron Bauman
On Fri, Aug 07, 2020 at 12:28:04PM -0400, Aaron Bauman wrote:
> * Python implies such things. Let's drop 'em and be consistent.
> 
> Signed-off-by: Aaron Bauman 
> ---
>  "\\"   | 20 
>  lib/_emerge/EbuildPhase.py |  6 +++---
>  lib/_emerge/resolver/output.py |  5 -
>  lib/portage/elog/mod_custom.py |  1 -
>  lib/portage/elog/mod_echo.py   |  4 ++--
>  lib/portage/elog/mod_mail.py   |  2 --
>  lib/portage/glsa.py|  3 ---
>  lib/portage/mail.py|  1 -
>  lib/portage/sync/controller.py |  3 +--
>  lib/portage/util/whirlpool.py  |  2 --
>  pylintrc   |  1 +
>  11 files changed, 27 insertions(+), 21 deletions(-)
>  create mode 100644 "\\"
> 
> diff --git "a/\\" "b/\\"
> new file mode 100644
> index 0..aaf1d3b1b
> --- /dev/null
> +++ "b/\\"
> @@ -0,0 +1,20 @@
> +# elog/mod_custom.py - elog dispatch module
> +# Copyright 2006-2020 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +import portage.elog.mod_save
> +import portage.exception
> +import portage.process
> +
> +def process(mysettings, key, logentries, fulltext):
> + elogfilename = portage.elog.mod_save.process(mysettings, key, 
> logentries, fulltext)
> +
>  if not isinstance(source, bytes):
> @@ -777,7 +776,6 @@ def processBuffer(ctx):

[snip]

Please disregard. Sending new patch.

-- 
Cheers,
Aaron


signature.asc
Description: PGP signature


Re: [gentoo-portage-dev] [PATCH] lib/*: Fix useless-return

2020-08-07 Thread Michał Górny
On Fri, 2020-08-07 at 12:28 -0400, Aaron Bauman wrote:
> * Python implies such things. Let's drop 'em and be consistent.
> 
> Signed-off-by: Aaron Bauman 
> ---
>  "\\"   | 20 
>  lib/_emerge/EbuildPhase.py |  6 +++---
>  lib/_emerge/resolver/output.py |  5 -
>  lib/portage/elog/mod_custom.py |  1 -
>  lib/portage/elog/mod_echo.py   |  4 ++--
>  lib/portage/elog/mod_mail.py   |  2 --
>  lib/portage/glsa.py|  3 ---
>  lib/portage/mail.py|  1 -
>  lib/portage/sync/controller.py |  3 +--
>  lib/portage/util/whirlpool.py  |  2 --
>  pylintrc   |  1 +
>  11 files changed, 27 insertions(+), 21 deletions(-)
>  create mode 100644 "\\"
> 
> diff --git "a/\\" "b/\\"
> new file mode 100644
> index 0..aaf1d3b1b
> --- /dev/null
> +++ "b/\\"

That's an interesting file to add.

> @@ -0,0 +1,20 @@
> +# elog/mod_custom.py - elog dispatch module
> +# Copyright 2006-2020 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +import portage.elog.mod_save
> +import portage.exception
> +import portage.process
> +
> +def process(mysettings, key, logentries, fulltext):
> + elogfilename = portage.elog.mod_save.process(mysettings, key, 
> logentries, fulltext)
> +
> + if not mysettings.get("PORTAGE_ELOG_COMMAND"):
> + raise portage.exception.MissingParameter("!!! Custom logging 
> requested but PORTAGE_ELOG_COMMAND is not defined")
> + else:
> + mylogcmd = mysettings["PORTAGE_ELOG_COMMAND"]
> + mylogcmd = mylogcmd.replace("${LOGFILE}", elogfilename)
> + mylogcmd = mylogcmd.replace("${PACKAGE}", key)
> + retval = portage.process.spawn_bash(mylogcmd)
> + if retval != 0:
> + raise portage.exception.PortageException("!!! 
> PORTAGE_ELOG_COMMAND failed with exitcode %d" % retval)
> diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
> index e6256d0aa..ceffeccee 100644
> --- a/lib/_emerge/EbuildPhase.py
> +++ b/lib/_emerge/EbuildPhase.py
> @@ -9,11 +9,12 @@ import tempfile
>  
>  from _emerge.AsynchronousLock import AsynchronousLock
>  from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
> -from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
> -from _emerge.EbuildProcess import EbuildProcess
>  from _emerge.CompositeTask import CompositeTask
> +from _emerge.EbuildProcess import EbuildProcess
> +from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
>  from _emerge.PackagePhase import PackagePhase
>  from _emerge.TaskSequence import TaskSequence
> +
>  from portage.package.ebuild._ipc.QueryCommand import QueryCommand
>  from portage.util._dyn_libs.soname_deps_qa import (
>   _get_all_provides,
> @@ -396,7 +397,6 @@ class EbuildPhase(CompositeTask):
>   fd_pipes=self.fd_pipes, phase=phase, 
> scheduler=self.scheduler,
>   settings=self.settings)
>   self._start_task(clean_phase, self._fail_clean_exit)
> - return
>  
>   def _fail_clean_exit(self, clean_phase):
>   self._final_exit(clean_phase)
> diff --git a/lib/_emerge/resolver/output.py b/lib/_emerge/resolver/output.py
> index 1dcb47020..b6c77ecad 100644
> --- a/lib/_emerge/resolver/output.py
> +++ b/lib/_emerge/resolver/output.py
> @@ -243,7 +243,6 @@ class Display:
>   cur_use_map[key], old_iuse_map[key],
>   old_use_map[key], is_new, feature_flags,
>   reinst_flags_map.get(key))
> - return
>  
>  
>   @staticmethod
> @@ -539,7 +538,6 @@ class Display:
>   if show_repos and repoadd:
>   myprint += " " + teal("[%s]" % repoadd)
>   writemsg_stdout("%s\n" % (myprint,), noiselevel=-1)
> - return
>  
>  
>   def print_blockers(self):
> @@ -548,7 +546,6 @@ class Display:
>   """
>   for pkg in self.blockers:
>   writemsg_stdout("%s\n" % (pkg,), noiselevel=-1)
> - return
>  
>  
>   def print_verbose(self, show_repos):
> @@ -562,7 +559,6 @@ class Display:
>   # that RepoDisplay.__unicode__() is called in python2.
>   writemsg_stdout("%s" % (self.conf.repo_display,),
>   noiselevel=-1)
> - return
>  
>  
>   def print_changelog(self):
> @@ -687,7 +683,6 @@ class Display:
>   if ebuild_path_cl is not None:
>   self.changelogs.extend(_calc_changelog(
>   ebuild_path_cl, pkg_info.previous_pkg, 
> pkg.cpv))
> - return
>  
>  
>   def check_system_world(self, pkg):
> diff --git a/lib/portage/elog/mod_custom.py b/lib/portage/elog/mod_custom.py
> index 7cfafeccc..aaf1d3b1b 100644
> --- a/lib/portage/elog/mod_custom.py

[gentoo-portage-dev] [PATCH] lib/*: Fix useless-return

2020-08-07 Thread Aaron Bauman
* Python implies such things. Let's drop 'em and be consistent.

Signed-off-by: Aaron Bauman 
---
 "\\"   | 20 
 lib/_emerge/EbuildPhase.py |  6 +++---
 lib/_emerge/resolver/output.py |  5 -
 lib/portage/elog/mod_custom.py |  1 -
 lib/portage/elog/mod_echo.py   |  4 ++--
 lib/portage/elog/mod_mail.py   |  2 --
 lib/portage/glsa.py|  3 ---
 lib/portage/mail.py|  1 -
 lib/portage/sync/controller.py |  3 +--
 lib/portage/util/whirlpool.py  |  2 --
 pylintrc   |  1 +
 11 files changed, 27 insertions(+), 21 deletions(-)
 create mode 100644 "\\"

diff --git "a/\\" "b/\\"
new file mode 100644
index 0..aaf1d3b1b
--- /dev/null
+++ "b/\\"
@@ -0,0 +1,20 @@
+# elog/mod_custom.py - elog dispatch module
+# Copyright 2006-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+import portage.elog.mod_save
+import portage.exception
+import portage.process
+
+def process(mysettings, key, logentries, fulltext):
+   elogfilename = portage.elog.mod_save.process(mysettings, key, 
logentries, fulltext)
+
+   if not mysettings.get("PORTAGE_ELOG_COMMAND"):
+   raise portage.exception.MissingParameter("!!! Custom logging 
requested but PORTAGE_ELOG_COMMAND is not defined")
+   else:
+   mylogcmd = mysettings["PORTAGE_ELOG_COMMAND"]
+   mylogcmd = mylogcmd.replace("${LOGFILE}", elogfilename)
+   mylogcmd = mylogcmd.replace("${PACKAGE}", key)
+   retval = portage.process.spawn_bash(mylogcmd)
+   if retval != 0:
+   raise portage.exception.PortageException("!!! 
PORTAGE_ELOG_COMMAND failed with exitcode %d" % retval)
diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index e6256d0aa..ceffeccee 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -9,11 +9,12 @@ import tempfile
 
 from _emerge.AsynchronousLock import AsynchronousLock
 from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
-from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
-from _emerge.EbuildProcess import EbuildProcess
 from _emerge.CompositeTask import CompositeTask
+from _emerge.EbuildProcess import EbuildProcess
+from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
 from _emerge.PackagePhase import PackagePhase
 from _emerge.TaskSequence import TaskSequence
+
 from portage.package.ebuild._ipc.QueryCommand import QueryCommand
 from portage.util._dyn_libs.soname_deps_qa import (
_get_all_provides,
@@ -396,7 +397,6 @@ class EbuildPhase(CompositeTask):
fd_pipes=self.fd_pipes, phase=phase, 
scheduler=self.scheduler,
settings=self.settings)
self._start_task(clean_phase, self._fail_clean_exit)
-   return
 
def _fail_clean_exit(self, clean_phase):
self._final_exit(clean_phase)
diff --git a/lib/_emerge/resolver/output.py b/lib/_emerge/resolver/output.py
index 1dcb47020..b6c77ecad 100644
--- a/lib/_emerge/resolver/output.py
+++ b/lib/_emerge/resolver/output.py
@@ -243,7 +243,6 @@ class Display:
cur_use_map[key], old_iuse_map[key],
old_use_map[key], is_new, feature_flags,
reinst_flags_map.get(key))
-   return
 
 
@staticmethod
@@ -539,7 +538,6 @@ class Display:
if show_repos and repoadd:
myprint += " " + teal("[%s]" % repoadd)
writemsg_stdout("%s\n" % (myprint,), noiselevel=-1)
-   return
 
 
def print_blockers(self):
@@ -548,7 +546,6 @@ class Display:
"""
for pkg in self.blockers:
writemsg_stdout("%s\n" % (pkg,), noiselevel=-1)
-   return
 
 
def print_verbose(self, show_repos):
@@ -562,7 +559,6 @@ class Display:
# that RepoDisplay.__unicode__() is called in python2.
writemsg_stdout("%s" % (self.conf.repo_display,),
noiselevel=-1)
-   return
 
 
def print_changelog(self):
@@ -687,7 +683,6 @@ class Display:
if ebuild_path_cl is not None:
self.changelogs.extend(_calc_changelog(
ebuild_path_cl, pkg_info.previous_pkg, 
pkg.cpv))
-   return
 
 
def check_system_world(self, pkg):
diff --git a/lib/portage/elog/mod_custom.py b/lib/portage/elog/mod_custom.py
index 7cfafeccc..aaf1d3b1b 100644
--- a/lib/portage/elog/mod_custom.py
+++ b/lib/portage/elog/mod_custom.py
@@ -18,4 +18,3 @@ def process(mysettings, key, logentries, fulltext):
retval = portage.process.spawn_bash(mylogcmd)
if retval != 0:
raise