Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_contents_entry() and get_contents_dir() returning 'str' instead of 'bytes' #3737

Open
eugenhu opened this issue Jul 6, 2020 · 3 comments · May be fixed by #3738
Open

get_contents_entry() and get_contents_dir() returning 'str' instead of 'bytes' #3737

eugenhu opened this issue Jul 6, 2020 · 3 comments · May be fixed by #3738
Assignees

Comments

@eugenhu
Copy link

eugenhu commented Jul 6, 2020

I'm not sure if this is accidental but get_contents_entry() and get_contents_dir() are returning strs (line 209, 219):

def get_contents_entry(node):
"""Fetch the contents of the entry. Returns the exact binary
contents of the file."""
try:
node = node.disambiguate(must_exist=1)
except SCons.Errors.UserError:
# There was nothing on disk with which to disambiguate
# this entry. Leave it as an Entry, but return a null
# string so calls to get_contents() in emitters and the
# like (e.g. in qt.py) don't have to disambiguate by hand
# or catch the exception.
return ''
else:
return _get_contents_map[node._func_get_contents](node)
def get_contents_dir(node):
"""Return content signatures and names of all our children
separated by new-lines. Ensure that the nodes are sorted."""
contents = []
for n in sorted(node.children(), key=lambda t: t.name):
contents.append('%s %s\n' % (n.get_csig(), n.name))
return ''.join(contents)

I ran into this when trying to debug this SConstruct,

v = Value('x')
e = Entry('something')
v.add_dependency([e])

v.get_contents()

which was producing the output,

AttributeError: 'str' object has no attribute 'decode':
  File ".../SConstruct", line 5:
    v.get_contents()
  File ".../SCons/Node/Python.py", line 155:
    text_contents = self.get_text_contents()
  File ".../SCons/Node/Python.py", line 147:
    contents = contents + kid.get_contents().decode()

I think this is because Value.get_text_contents() is expecting kid.get_contents() to be of type bytes.

@bdbaddog
Copy link
Contributor

bdbaddog commented Jul 6, 2020

Did you see the note requesting you bring your issue to the Users mailing list or the scons-help channel on our discord server or the IRC channel before posting here?
Also you didn't post info about scons version, python version, OS which is requested.

@eugenhu
Copy link
Author

eugenhu commented Jul 6, 2020

Sorry I did read that, I didn't realise the procedure and bug report format was strict, I'm just getting used to submitting github issues for different projects so apologies about that. I'll visit the discord server now.

@mwichmann
Copy link
Collaborator

Note for linkage purposes that the topic of what a value node returns as a sig is also the topic of #2785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants