##// END OF EJS Templates
util: use safehasattr or getattr instead of hasattr
Augie Fackler -
r14968:b7dbe957 default
parent child Browse files
Show More
@@ -358,8 +358,8 b' def mainfrozen():'
358 The code supports py2exe (most common, Windows only) and tools/freeze
358 The code supports py2exe (most common, Windows only) and tools/freeze
359 (portable, not much used).
359 (portable, not much used).
360 """
360 """
361 return (hasattr(sys, "frozen") or # new py2exe
361 return (safehasattr(sys, "frozen") or # new py2exe
362 hasattr(sys, "importers") or # old py2exe
362 safehasattr(sys, "importers") or # old py2exe
363 imp.is_frozen("__main__")) # tools/freeze
363 imp.is_frozen("__main__")) # tools/freeze
364
364
365 def hgexecutable():
365 def hgexecutable():
@@ -783,7 +783,7 b' class atomictempfile(object):'
783 self._fp.close()
783 self._fp.close()
784
784
785 def __del__(self):
785 def __del__(self):
786 if hasattr(self, '_fp'): # constructor actually did something
786 if safehasattr(self, '_fp'): # constructor actually did something
787 self.close()
787 self.close()
788
788
789 def makedirs(name, mode=None):
789 def makedirs(name, mode=None):
@@ -1254,8 +1254,9 b' def rundetached(args, condfn):'
1254 def handler(signum, frame):
1254 def handler(signum, frame):
1255 terminated.add(os.wait())
1255 terminated.add(os.wait())
1256 prevhandler = None
1256 prevhandler = None
1257 if hasattr(signal, 'SIGCHLD'):
1257 SIGCHLD = getattr(signal, 'SIGCHLD', None)
1258 prevhandler = signal.signal(signal.SIGCHLD, handler)
1258 if SIGCHLD is not None:
1259 prevhandler = signal.signal(SIGCHLD, handler)
1259 try:
1260 try:
1260 pid = spawndetached(args)
1261 pid = spawndetached(args)
1261 while not condfn():
1262 while not condfn():
General Comments 0
You need to be logged in to leave comments. Login now