Skip to content

Fix type error when concatenating None#38

Open
marcorosa wants to merge 1 commit intosherdencooper:masterfrom
marcorosa:master-original
Open

Fix type error when concatenating None#38
marcorosa wants to merge 1 commit intosherdencooper:masterfrom
marcorosa:master-original

Conversation

@marcorosa
Copy link
Copy Markdown

Sometimes the mutator returns a result =None. In such case, concatenating a result=None with the prompt string raises an exception (TypeError, see below)

Traceback (most recent call last):
...
  File "...", line 53, in run
    mutated_results = self.mutate_policy.mutate_single(seed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/gptfuzzer/fuzzer/mutator.py", line 216, in mutate_single
    results = [result + prompt_node.prompt for result in results]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/gptfuzzer/fuzzer/mutator.py", line 216, in <listcomp>
    results = [result + prompt_node.prompt for result in results]
               ~~~~~~~^~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

This PR fixes the TypeError concatenating the prompt string with either result value (if not None) or an empty string (if result is =None)

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.

1 participant