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

decomp: split_node: Fix deepcopy import. #25

Merged
merged 1 commit into from
Jan 22, 2018

Conversation

maximumspatium
Copy link
Contributor

I encountered an input that triggers the following import failure in decomp:split_node():

Error while processing file: sub_204bdc.lst
Traceback (most recent call last):
  File "apply_xform.py", line 229, in <module>
    changed = one_iter(input, output, iter_no)
  File "apply_xform.py", line 191, in one_iter
    handle_file(args)
  File "apply_xform.py", line 68, in handle_file
    raise e
  File "apply_xform.py", line 65, in handle_file
    handle_file_unprotected(args)
  File "apply_xform.py", line 93, in handle_file_unprotected
    mod.apply(cfg)
  File "/Users/maxim/Documents/Development/ScratchABlock_maxim/script_decompile.py", line 97, in apply
    if match_abnormal_sel(cfg):
  File "/Users/maxim/Documents/Development/ScratchABlock_maxim/decomp.py", line 458, in match_abnormal_sel
    split_node(cfg, v)
  File "/Users/maxim/Documents/Development/ScratchABlock_maxim/decomp.py", line 35, in split_node
    node2_props = copy.deepcopy(node_props)
AttributeError: 'function' object has no attribute 'deepcopy'

It looks like something "shadows" python's copy. Hence this simple fix.

@pfalcon
Copy link
Owner

pfalcon commented Jan 22, 2018

I believe I hit that once also, and did something to work around that too. So how about we trying to fix it better this time? The issues seems to be exactly that "from copy import copy" is used somewhere, creating ambiguity between a module and a function name. And the right way to solve it would be use namespace reference (e.g. copy.copy()) everywhere. Let me know if you agree and I can fix it.

@maximumspatium
Copy link
Contributor Author

Let me know if you agree and I can fix it.

Sure, +1 for a better fix (if you'll be able to spot the issue).
Putting copy.copy(node_props) right before deepcopy invocation results in the same error. On the other hand, copy(node_props) works...

@maximumspatium
Copy link
Contributor Author

"from copy import copy" is used somewhere

Yep, that's core.py...

@maximumspatium
Copy link
Contributor Author

Another attempt to do the things right...

@pfalcon pfalcon merged commit c7969f0 into pfalcon:master Jan 22, 2018
@pfalcon
Copy link
Owner

pfalcon commented Jan 22, 2018

Merged, thanks!

@pfalcon
Copy link
Owner

pfalcon commented Jan 22, 2018

Note that this is a part of bigger issue: #17 , for which I appreciate feedback.

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

Successfully merging this pull request may close these issues.

2 participants