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

Unexpected behavior in content.delete #383

Closed
rafaelbco opened this issue Aug 17, 2017 · 1 comment
Closed

Unexpected behavior in content.delete #383

rafaelbco opened this issue Aug 17, 2017 · 1 comment

Comments

@rafaelbco
Copy link
Member

If I do:

api.content.delete(objects=[])

I expect that the function will do nothing and exit without errors. However, an exception is raised.

The reason is the first line of code of the delete function:

objects = objects or [obj]

Since objects is an empty list and obj is None (the default value) we end up with objects being [None].

An easy way to fix is to filter out None objects from the resulting list:

objects = objects or [obj]
objects = [o for o in objects if o is not None]
if not objects:
    return
@gforcada
Copy link
Sponsor Member

That could be handled on the decorators to keep the function simple and easy to read as well.

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

No branches or pull requests

2 participants