Skip to content

Variable 'reward' referenced before assignment #34

@smacrineanu

Description

@smacrineanu

Describe the bug
The get_reward() function from arweave_lib.py fails randomly because of poor variable usage.

My guess is that the following code fails when the status.code is different than 200.

if response.status_code == 200:
            reward = response.text

return reward

Here is the traceback:

File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 192, in sign
  data_to_sign = self.get_signature_data()
File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 204, in get_signature_data
  self.reward = self.get_reward(self.data_size, target_address=self.target if len(self.target) > 0 else None)
File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 178, in get_reward
  return reward
UnboundLocalError: local variable 'reward' referenced before assignment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions