MCPcopy Index your code
hub / github.com/python/cpython / PyCompileError

Class PyCompileError

Lib/py_compile.py:18–63  ·  view source on GitHub ↗

Exception raised when an error occurs while attempting to compile the file. To raise this exception, use raise PyCompileError(exc_type,exc_value,file[,msg]) where exc_type: exception type to be used in error message type name can be accesses as c

Source from the content-addressed store, hash-verified

16
17
18class PyCompileError(Exception):
19 """Exception raised when an error occurs while attempting to
20 compile the file.
21
22 To raise this exception, use
23
24 raise PyCompileError(exc_type,exc_value,file[,msg])
25
26 where
27
28 exc_type: exception type to be used in error message
29 type name can be accesses as class variable
30 'exc_type_name'
31
32 exc_value: exception value to be used in error message
33 can be accesses as class variable 'exc_value'
34
35 file: name of file being compiled to be used in error message
36 can be accesses as class variable 'file'
37
38 msg: string message to be written as error message
39 If no value is given, a default exception message will be
40 given, consistent with 'standard' py_compile output.
41 message (or default) can be accesses as class variable
42 'msg'
43
44 """
45
46 def __init__(self, exc_type, exc_value, file, msg=''):
47 exc_type_name = exc_type.__name__
48 if exc_type is SyntaxError:
49 tbtext = ''.join(traceback.format_exception_only(
50 exc_type, exc_value))
51 errmsg = tbtext.replace('File "<string>"', 'File "%s"' % file)
52 else:
53 errmsg = "Sorry: %s: %s" % (exc_type_name,exc_value)
54
55 Exception.__init__(self,msg or errmsg,exc_type_name,exc_value,file)
56
57 self.exc_type_name = exc_type_name
58 self.exc_value = exc_value
59 self.file = file
60 self.msg = msg or errmsg
61
62 def __str__(self):
63 return self.msg
64
65
66class PycInvalidationMode(enum.Enum):

Callers 2

_get_codeMethod · 0.90
compileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…