py-solc-ast icon indicating copy to clipboard operation
py-solc-ast copied to clipboard

AttributeError: 'dict' object has no attribute 'exportedSymbols'

Open HasaTan opened this issue 2 years ago • 4 comments

Environment information

  • py-solc-ast Version: 1.2.9
  • solc Version: 0.5.4
  • Python Version: 3.9.7
  • OS: win

What was wrong?

Please include information like:

when i run the code : source = dict()

  source["sources"] = solcx.compile_files([filename], output_values=['ast'])
  
  file = filename + ".json"
  with open(file, 'w') as file_obj:
      json.dump(source, file_obj)
  
  contrasts_units = solcast.from_standard_output(source)

the log shows that:

Traceback (most recent call last): File "D:\Project\Python\cfg_builder\main.py", line 27, in contrasts_units = solcast.from_standard_output(source) File "D:\Project\Python\cfg_builder\venv\lib\site-packages\solcast\main.py", line 33, in from_standard_output source_nodes = set_dependencies(source_nodes) File "D:\Project\Python\cfg_builder\venv\lib\site-packages\solcast\dependencies.py", line 12, in set_dependencies symbol_map = get_symbol_map(source_nodes) File "D:\Project\Python\cfg_builder\venv\lib\site-packages\solcast\dependencies.py", line 98, in get_symbol_map for key, value in ((k, x) for k, v in node.exportedSymbols.items() for x in v): AttributeError: 'dict' object has no attribute 'exportedSymbols'

How can it be fixed?

Fill this in if you know how the bug could be fixed.

HasaTan avatar May 17 '23 12:05 HasaTan

I think if you use from_standard_output, you have to use the standard output approach for compiling, and not compile_files().

try:

from solcx.main import _compile_combined_json

output = _compile_combined_json(source_files=[filename], output_values=["ast"])

antazoey avatar May 22 '23 15:05 antazoey

also i think we are inheriting this package over here: https://github.com/ApeWorX/py-solc-ast

antazoey avatar May 22 '23 15:05 antazoey

另外,我认为我们在这里继承了这个包:https://github.com/ApeWorX/py-solc-ast

thks,i use the sol that sloditity version 0.5.4,then i change it to version ^0.8.0, then i success .

HasaTan avatar May 23 '23 08:05 HasaTan

i realized i imported the wrong method in my example, but the words are still right ,have to use standard input compile.

antazoey avatar May 23 '23 12:05 antazoey