From f480c51c9d2d2335554dd6a031844b737e1199ab Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Thu, 9 Jan 2020 10:11:11 +0000 Subject: [PATCH] AthenaCommon: More python 3 fixes - Coerce iterator to list. - fileno Also need to make sure `file' is explicitly defined as a local if we're assigning it on any arm of a conditional; can't just rely on finding it as a builtin. --- Control/AthenaCommon/python/ChapPy.py | 5 +++-- Control/AthenaCommon/python/JobProperties.py | 2 +- Control/AthenaCommon/share/athena.py | 4 ++-- Control/AthenaCommon/share/athena3.py | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Control/AthenaCommon/python/ChapPy.py b/Control/AthenaCommon/python/ChapPy.py index f2671c84943..2bc329b2522 100755 --- a/Control/AthenaCommon/python/ChapPy.py +++ b/Control/AthenaCommon/python/ChapPy.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # @file : ChapPy.py # @author: Sebastien Binet <binet@cern.ch> @@ -32,9 +32,10 @@ def dump( buf, stdout = sys.stdout ): fname = None if isinstance(buf, str): fname = buf + from builtins import file if six.PY3: import io - file = io.IOBase + file = io.IOBase # noqa: F811 if isinstance(buf, file): fname = buf.name with open(fname, 'r') as fd: diff --git a/Control/AthenaCommon/python/JobProperties.py b/Control/AthenaCommon/python/JobProperties.py index 4a6805b9e97..fa0096d6f6b 100755 --- a/Control/AthenaCommon/python/JobProperties.py +++ b/Control/AthenaCommon/python/JobProperties.py @@ -733,7 +733,7 @@ class JobPropertyContainer (object): """ tp=type(data) if tp.__name__=='dict': - list_context=JobProperty._nInstancesContextDict.keys() + list_context=list(JobProperty._nInstancesContextDict.keys()) for i in data.keys(): for j in data[i].keys(): if list_context.count(i+'.'+j)==1: diff --git a/Control/AthenaCommon/share/athena.py b/Control/AthenaCommon/share/athena.py index e1d808e4885..1cc99b8102a 100755 --- a/Control/AthenaCommon/share/athena.py +++ b/Control/AthenaCommon/share/athena.py @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # # athena.py is born as shell script to preload some optional libraries # @@ -149,7 +149,7 @@ fhistory = os.path.expanduser( '~/.athena.history' ) ## interface setup as appropriate if opts.run_batch and not opts.dbg_stage: # in batch there is no need for stdin - if os.isatty( sys.stdin.fileno() ): + if sys.stdin and os.isatty( sys.stdin.fileno() ): os.close( sys.stdin.fileno() ) else: # Make sure ROOT gets initialized early, so that it shuts down last. diff --git a/Control/AthenaCommon/share/athena3.py b/Control/AthenaCommon/share/athena3.py index 4bffdc3e87d..c563db0e1ce 100755 --- a/Control/AthenaCommon/share/athena3.py +++ b/Control/AthenaCommon/share/athena3.py @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # # athena.py is born as shell script to preload some optional libraries # @@ -149,7 +149,7 @@ fhistory = os.path.expanduser( '~/.athena.history' ) ## interface setup as appropriate if opts.run_batch and not opts.dbg_stage: # in batch there is no need for stdin - if os.isatty( sys.stdin.fileno() ): + if sys.stdin and os.isatty( sys.stdin.fileno() ): os.close( sys.stdin.fileno() ) else: # Make sure ROOT gets initialized early, so that it shuts down last. -- GitLab