[Patches] [ python-Patches-661719 ] allow py_compile to re-raise exceptions

SourceForge.net noreply@sourceforge.net
Fri, 03 Jan 2003 12:43:13 -0800


Patches item #661719, was opened at 2003-01-03 17:59
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=661719&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gyro Funch (siva1311)
Assigned to: Nobody/Anonymous (nobody)
Summary: allow py_compile to re-raise exceptions

Initial Comment:
py_compile does not re-raise exceptions so that they
can be caught by the calling program. The following
example illustrates the problem:

-----begin bad_prog.py-----
print "hello
-----end   bad_prog.py-----


-----begin test_compile.py-----
from py_compile import compile

class CompileError(Exception): pass

fl = 'bad_prog.py'
try:
    compile(fl)
except Exception,msg:
    raise CompileError, '%s: %s' % (msg,fl)
-----end   test_compile.py-----

-----
[~]:python test_compile.py 
  File "bad_prog.py", line 1
    print "hello
               ^
SyntaxError: invalid token
-----
Note that CompileError is not raised.


The attached simple patch should take care of the
problem (and I hope not cause any bad side effects). 

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-01-03 21:43

Message:
Logged In: YES 
user_id=21627

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=661719&group_id=5470