Skip to content

Fix UnboundLocalError by ensuring 'out' variable is always initialized#7

Open
ruose1314 wants to merge 1 commit into
mainfrom
fix-unboundlocalerror-issue
Open

Fix UnboundLocalError by ensuring 'out' variable is always initialized#7
ruose1314 wants to merge 1 commit into
mainfrom
fix-unboundlocalerror-issue

Conversation

@ruose1314

Copy link
Copy Markdown

The issue was in the load_array function, line 651, it would raise an UnboundLocalError since the returned variable 'out' is defined in if statement, I Initialized 'out' to 'None' at the start of the function to ensure it's always defined (line 671).

@marklescroart

Copy link
Copy Markdown
Member

Thanks for pointing this out, there is an issue here, but I don't think this is the correct fix. It sounds like you have run into a case for which the file extension is not known - what was the file you were trying to load? It must not have been '.mat'., '.mp4', '.npy', or any of the possible hdf file extensions ('.hdf', '.hf', '.hdf5', '.h5', '.hf5'). If that's the case, better to throw a not-supported error (NotImplementedError) for the particular file type than to simply return none. This should be done with an else statement following the other if and elif statements that govern loading of other file types. Can you make this change instead, and I'll accept the pull request?

@marklescroart

Copy link
Copy Markdown
Member

In cleaning up some outstanding issues - this still seems worth doing. @ruose1314 , want to do this? Or should I? (we may need to rebase to merge at this point, might be a good exercise)

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.

2 participants