Fix error when clime.now is imported in a module without any callables #25

Merged
merged 2 commits into from Jan 6, 2015

Conversation

Projects
None yet
2 participants
@uranusjr
Contributor

uranusjr commented Jan 5, 2015

To reproduce, run import clime.now in an empty module.

This patch eats the exception and outputs nothing if there's nothing to print.

I also removed the cmd_func local variable because it is not needed anywhere.

uranusjr added some commits Jan 5, 2015

Fix StopIteration error if there're no usages
If clime.now is imported in a module with no functions at all, the
usage list would be empty. In this case next(iusages) will fail with
a StopIteration error.

This patch eats the exception and outputs nothing if there's nothing
to print.
@@ -632,7 +632,6 @@ def append_usage(cmd_name, without_name=False):
usages.append(Command(cmd_func, cmd_name).build_usage(without_name))
usages = []
- cmd_func = None

This comment has been minimized.

@moskytw

moskytw Jan 6, 2015

Owner

can it be deleted?

@moskytw

moskytw Jan 6, 2015

Owner

can it be deleted?

This comment has been minimized.

@uranusjr

uranusjr Jan 6, 2015

Contributor

PyFlakes thinks so.

(clime)tp-mba:clime uranusjr$ pyflakes clime/core.py
clime/core.py:635: local variable 'cmd_func' is assigned to but never used
@uranusjr

uranusjr Jan 6, 2015

Contributor

PyFlakes thinks so.

(clime)tp-mba:clime uranusjr$ pyflakes clime/core.py
clime/core.py:635: local variable 'cmd_func' is assigned to but never used

This comment has been minimized.

@moskytw

moskytw Jan 6, 2015

Owner

okay, yeah, that is right.

@moskytw

moskytw Jan 6, 2015

Owner

okay, yeah, that is right.

moskytw added a commit that referenced this pull request Jan 6, 2015

Merge pull request #25 from uranusjr/fix-empty-iter-error
Fix error when clime.now is imported in a module without any callables

@moskytw moskytw merged commit 67ef3a7 into moskytw:dev Jan 6, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment