Skip to content

Commit 8def4a9

Browse files
author
ldx
committed
Make Table6 a true singleton.
1 parent e167818 commit 8def4a9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

iptc/ip6tc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,16 +576,19 @@ class Table6(Table):
576576

577577
_cache = weakref.WeakValueDictionary()
578578

579-
def __new__(cls, name, autocommit=True):
579+
def __new__(cls, name, autocommit=None):
580580
obj = Table6._cache.get(name, None)
581581
if not obj:
582582
obj = object.__new__(cls)
583+
if autocommit is None:
584+
autocommit = True
585+
obj._init(name, autocommit)
583586
Table6._cache[name] = obj
584-
else:
587+
elif autocommit is not None:
585588
obj.autocommit = autocommit
586589
return obj
587590

588-
def __init__(self, name, autocommit=True):
591+
def _init(self, name, autocommit):
589592
"""
590593
Here *name* is the name of the table to instantiate, if it has already
591594
been instantiated the existing cached object is returned.

0 commit comments

Comments
 (0)