Skip to content
Snippets Groups Projects
Commit 4d4fca1b authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

AthenaCommon: remove printfunc alias

parent c39348e6
No related branches found
No related tags found
2 merge requests!710942024-05-02: merge of 24.0 into main,!71021AthenaCommon: remove printfunc alias
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# File: AthenaCommon/python/Include.py
# Author: Wim Lavrijsen (WLavrijsen@lbl.gov)
......@@ -7,10 +7,6 @@
JOBOPTSEARCHPATH envar and globally executed. If requested, files will be
traced. Note, however, that this option interferes with pdb and trace."""
# Don't want to use from __future__ import print_function here: that would
# then apply to everything that we read with include().
import builtins
printfunc = getattr(builtins,'print')
import os, sys, re, fnmatch
from AthenaCommon.Utils.unixtools import FindFile
......@@ -287,13 +283,13 @@ class Include( object ):
# formatted line printer
def _oneline( self, fid, lineno, detail, buf ):
printfunc (marker, fidMarker % fid, lineMarker % lineno, detail,)
print (marker, fidMarker % fid, lineMarker % lineno, detail,)
try:
# simple eol case
if not buf or not buf[ lineno ]:
printfunc()
print()
return
# in general, an interpreter "line" may be longer than a file line
......@@ -302,18 +298,18 @@ class Include( object ):
# this line appears to have a continuation ...
try:
# output traced line
printfunc (line)
print (line)
# output continued line
lineno += 1
printfunc (marker, fidMarker % fid, lineMarker % lineno, detail,)
print (marker, fidMarker % fid, lineMarker % lineno, detail,)
line = buf[ lineno ].rstrip()
except IndexError:
# shouldn't happen; but must mean that the diagnosis above is
# wrong and that there is no continuation, keep silent
break
printfunc (line)
print (line)
except IndexError:
log.warning( 'index (%d) out of range while scanning include file %d', lineno, fid )
......
import builtins
printfunc = getattr(builtins,'print')
### execution of user script and drop into batch or interactive mode ---------
for script in opts.scripts:
try:
......@@ -22,9 +19,9 @@ for script in opts.scripts:
if not 'AthenaCommon' in frame_info[0]:
short_tb.append( frame_info )
printfunc ('Shortened traceback (most recent user call last):')
printfunc (''.join( traceback.format_list( short_tb ) ),)
printfunc (''.join( traceback.format_exception_only( exc_info[0], exc_info[1] ) ),)
print ('Shortened traceback (most recent user call last):')
print (''.join( traceback.format_list( short_tb ) ),)
print (''.join( traceback.format_exception_only( exc_info[0], exc_info[1] ) ),)
else:
traceback.print_exc()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment