Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

python generate_sugar_files.py fails with : TypeError: 'NoneType' object is not iterable #11

Open
truedat101 opened this issue Feb 22, 2019 · 1 comment

Comments

@truedat101
Copy link

To reproduce, create a directory foo. Run the script as below. It will fail with this error.

Assumption: NoneType object is not iterable is quite often a sign of some non-defensive code. In the particular case, its the args.exclude_dirs being accessed in an unsafe manner, as an iterator, with no default set for exclude_dirs = []. I'd suggest either set default args for exclude_dirs, or check first: if args.exclude_dirs is not None:

$ python generate_sugar_files.py --top ./foo/ --var MYPROJ_SOURCES
Traceback (most recent call last):
  File "generate_sugar_files.py", line 159, in <module>
    Generator.run()
  File "generate_sugar_files.py", line 156, in run
    generator.create()
  File "generate_sugar_files.py", line 116, in create
    for x in args.exclude_dirs:
TypeError: 'NoneType' object is not iterable

NOTE: The same command above works if I pass an --exclude_dirs argument to a valid directory to exclude.

@ruslo
Copy link
Owner

ruslo commented Feb 22, 2019

I'd suggest either set default args for exclude_dirs, or check first: if args.exclude_dirs is not None

Pull request with a fix is welcome, both approaches look good for me.

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

No branches or pull requests

2 participants