<br>
<div class="gmail_quote">
<div> </div>
<div>Hi,</div>
<div> </div>
<div>Thats the output i got in output <a href="http://window.it/" target="_blank">window.it</a> is not listing the statement which caused it. copy paste and try it on you setup. it behaves the same way.</div>
<div> </div>
<div>I know that error is in <a href="http://log.info/" target="_blank">log.info</a>() function call.but it is not caught by "except". which is not getting logged using log.exception </div>
<div> </div>
<div>Thanks</div>
<div>Siddhartha</div>
<div> </div>
<div> </div>
<div>---------- Forwarded message ----------<br>From: Steve Holden <<a href="mailto:steve@holdenweb.com" target="_blank">steve@holdenweb.com</a>><br>To: <br>Date: Tue, 26 Jan 2010 11:54:23 -0500<br>Subject: Re: TypeError not caught by except statement<br>
siddhartha veedaluru wrote:<br>> Hi,<br>><br>> except not able to caught the TypeError exception occured in the below<br>> code<br>><br>>        <a href="http://log.info/" target="_blank">log.info</a> <<a href="http://log.info%3e(%22refer%22,ret/" target="_blank">http://log.info>("refer",ret</a>) in the try block<br>
><br>> throws a TypeError which is not caught .</div>
<p>The traceback you provide does not show the line in question, so I am<br>confused as to why you would think it was causing the problem. The<br>purpose of the traceback is to show you where the exception occurred,<br>and I question whether that is happening here.</p>

<p>Anyway, I suspect your error might go away if you turned the first<br>argument of hte <a href="http://log.info/" target="_blank">log.info</a>() call into a format string such as</p>
<p> <a href="http://log.info/" target="_blank">log.info</a>("refer: %s", ret)</p>
<p>regards<br> Steve</p>
<p>> Also sometimes process is getting hanged.<br>><br>> ------------------------------------------------------------------------------------------------------------------------------------------------<br>> import logging<br>
> log = logging.getLogger()<br>> fileName = strftime("%d-%b-%Y-", gmtime()) + str(int(time.time())) + "-<br>> Log.log"<br>> log = logging.getLogger()<br>> log.setLevel(logging.NOTSET)<br>
> fh = logging.FileHandler(logFile)<br>> logFileLevel = logging.DEBUG<br>> fh.setLevel(logFileLevel)<br>> format_string = '%(process)d %(thread)d %(asctime)-15s %(levelname)-5s<br>> at %(filename)-15s in %(funcName)-10s at line %(lineno)-3d "%(message)<br>
> s"'<br>> fh.setFormatter(logging.Formatter(format_string))<br>> log.addHandler(fh)<br>><br>> try:<br>>    <a href="http://log.info/" target="_blank">log.info</a> <<a href="http://log.info%3e(%22start/" target="_blank">http://log.info>("start</a>")<br>
>    <a href="http://log.info/" target="_blank">log.info</a> <<a href="http://log.info%3e(%22refer%22,ret/" target="_blank">http://log.info>("refer",ret</a>)<br>>    <a href="http://log.info/" target="_blank">log.info</a> <<a href="http://log.info%3e(%22end/" target="_blank">http://log.info>("end</a>")<br>
> except TypeError:<br>>    log.exception("Exception raised")<br>><br>> ----------------------------------------------------------------------------------------------------------------------------------------------<br>
> OUTPUT message:<br>><br>> Traceback (most recent call last):<br>>  File "C:\Python26\lib\logging\__init__.py", line 768, in emit<br>>    msg = self.format(record)<br>>  File "C:\Python26\lib\logging\__init__.py", line 648, in format<br>
>    return fmt.format(record)<br>>  File "C:\Python26\lib\logging\__init__.py", line 436, in format<br>>    record.message = record.getMessage()<br>>  File "C:\Python26\lib\logging\__init__.py", line 306, in getMessage<br>
>    msg = msg % self.args<br>> TypeError: not all arguments converted during string formatting<br>></p>
<p><br><font color="#888888">--<br>Steve Holden           +1 571 484 6266   +1 800 494 3119<br>PyCon is coming! Atlanta, Feb 2010  <a href="http://us.pycon.org/" target="_blank">http://us.pycon.org/</a><br>Holden Web LLC                 <a href="http://www.holdenweb.com/" target="_blank">http://www.holdenweb.com/</a><br>
UPCOMING EVENTS:        <a href="http://holdenweb.eventbrite.com/" target="_blank">http://holdenweb.eventbrite.com/</a></font></p></div><br>