Skip to content

Commit

Permalink
class Alpr: Set self.loaded to False before exception
Browse files Browse the repository at this point in the history
There are currently [46 open issues related to `loaded`](https://github.com/openalpr/openalpr/search?p=2&q=loaded&type=issues).  Many of these [`AttributeError` issues](https://github.com/openalpr/openalpr/search?q=AttributeError&type=issues) are caused because `self.loaded` is only defined at the end of this method on (line 117).  If an exception is raised (like line 62, etc.) then `self.loaded` is _never_ defined so subsequent code fails when trying to determine if `Alpr` has successfully loaded.

Closes openalpr#311
Closes openalpr#414
Closes openalpr#426
Closes openalpr#461 
Closes openalpr#508
Closes openalpr#533
Closes openalpr#660
Closes openalpr#732
Closes openalpr#738
Closes openalpr#764
Closes openalpr#806
Closes openalpr#837 
Closes openalpr#913 
Closes openalpr#916 
Related to openalpr#555
Related to Homebrew/homebrew-core#89948
  • Loading branch information
cclauss committed Nov 25, 2021
1 parent 736ab0e commit b352e75
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/bindings/python/openalpr/openalpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, country, config_file, runtime_dir):
:param runtime_dir: The path to the OpenALPR runtime data directory
:return: An OpenALPR instance
"""
self.loaded = False # Will be set to True at the end of this method.
country = _convert_to_charp(country)
config_file = _convert_to_charp(config_file)
runtime_dir = _convert_to_charp(runtime_dir)
Expand Down

0 comments on commit b352e75

Please sign in to comment.