Commit bddf62c2 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Removed str conversion from SourceDescriptors in order to be more explicit.

parent fcccb15f
...@@ -114,7 +114,7 @@ class CCodeWriter: ...@@ -114,7 +114,7 @@ class CCodeWriter:
s = s.rstrip() + ' # <<<<<<<<<<<<<< ' + '\n' s = s.rstrip() + ' # <<<<<<<<<<<<<< ' + '\n'
context += " * " + s context += " * " + s
marker = '"%s":%d\n%s' % (str(source_desc).encode('ASCII', 'replace'), line, context) marker = '"%s":%d\n%s' % (source_desc.get_description().encode('ASCII', 'replace'), line, context)
if self.last_marker != marker: if self.last_marker != marker:
self.marker = marker self.marker = marker
......
...@@ -29,7 +29,7 @@ class CompileError(PyrexError): ...@@ -29,7 +29,7 @@ class CompileError(PyrexError):
self.position = position self.position = position
self.message = message self.message = message
if position: if position:
pos_str = "%s:%d:%d: " % position pos_str = "%s:%d:%d: " % (position[0].get_description(), position[1], position[2])
cont = context(position) cont = context(position)
else: else:
pos_str = "" pos_str = ""
......
...@@ -428,7 +428,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -428,7 +428,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("static char *%s[] = {" % Naming.filenames_cname) code.putln("static char *%s[] = {" % Naming.filenames_cname)
if code.filename_list: if code.filename_list:
for source_desc in code.filename_list: for source_desc in code.filename_list:
filename = os.path.basename(str(source_desc)) filename = os.path.basename(source_desc.get_filenametable_entry())
escaped_filename = filename.replace("\\", "\\\\").replace('"', r'\"') escaped_filename = filename.replace("\\", "\\\\").replace('"', r'\"')
code.putln('"%s",' % code.putln('"%s",' %
escaped_filename) escaped_filename)
......
...@@ -206,7 +206,8 @@ def initial_compile_time_env(): ...@@ -206,7 +206,8 @@ def initial_compile_time_env():
#------------------------------------------------------------------ #------------------------------------------------------------------
class SourceDescriptor: class SourceDescriptor:
pass def __str__(self):
assert False # To catch all places where a descriptor is used directly as a filename
class FileSourceDescriptor(SourceDescriptor): class FileSourceDescriptor(SourceDescriptor):
""" """
...@@ -230,7 +231,10 @@ class FileSourceDescriptor(SourceDescriptor): ...@@ -230,7 +231,10 @@ class FileSourceDescriptor(SourceDescriptor):
else: else:
return open(self.filename) return open(self.filename)
def __str__(self): def get_description(self):
return self.filename
def get_filenametable_entry(self):
return self.filename return self.filename
def __repr__(self): def __repr__(self):
...@@ -248,9 +252,12 @@ class StringSourceDescriptor(SourceDescriptor): ...@@ -248,9 +252,12 @@ class StringSourceDescriptor(SourceDescriptor):
def get_lines(self, decode=False): def get_lines(self, decode=False):
return self.codelines return self.codelines
def __str__(self): def get_description(self):
return self.name return self.name
def get_filenametable_entry(self):
return "stringsource"
def __repr__(self): def __repr__(self):
return "<StringSourceDescriptor:%s>" % self return "<StringSourceDescriptor:%s>" % self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment