Skip to content

Commit

Permalink
workaround for python2
Browse files Browse the repository at this point in the history
  • Loading branch information
bonfus committed May 26, 2016
1 parent 2aac09b commit 343602f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions muesr/core/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ def __init__(self):
def __setattr__(self, key, value):
#check if attribute is present
_hasattr = False
try:
_hasattr = hasattr(self, key)
except SampleException:
# this is a work around till I find a better way to check
# properties that raises exceptions both in python2 and python3
if key in ['name', 'mm', 'current_mm_idx','sym','cell']:
_hasattr = True

else:
try:
_hasattr = hasattr(self, key)
except SampleException:
_hasattr = True

if self.__isfrozen and not _hasattr:
raise TypeError( "Cannot set attributes in this class" )
object.__setattr__(self, key, value)
Expand Down

0 comments on commit 343602f

Please sign in to comment.