Skip to content

Commit

Permalink
Fix Singleton adding 0th arg to init
Browse files Browse the repository at this point in the history
  • Loading branch information
bujniewicz committed Nov 12, 2015
1 parent 5acc8fd commit 92599a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions basilisk/base.py
Expand Up @@ -31,7 +31,8 @@ def wrapper(*args, **kwargs):
"""
if args[0].sl_init:
new_args = list(args)
del new_args[1]
if hasattr(args[0], 'sl_name'):
del new_args[1]
return function(*new_args, **kwargs)
return wrapper

Expand Down Expand Up @@ -111,8 +112,6 @@ def __new__(cls, *args):
This magic method override makes sure that only one instance will be created.
"""
new_args = list(args)
new_args.insert(0, 'dummy')
if not isinstance(cls._instance, cls):
cls._instance = super(SingletonBase, cls).__new__(cls)
cls._instance.sl_init = True
Expand Down
1 change: 1 addition & 0 deletions basilisk/tests.py
Expand Up @@ -37,6 +37,7 @@ def __init__(self, sl_init=True):
This method sets the parameter checked by singleton_decorator.
"""
self.sl_init = sl_init
self.sl_name = 'A'

cls.Test = Test

Expand Down

0 comments on commit 92599a7

Please sign in to comment.