Skip to content

Commit df53903

Browse files
authored
Merge pull request #121 from Json-To-String/variable-name-bug
Remove try except for variable checking in favor of string.isidentifi…
2 parents 7a12be5 + 0248d55 commit df53903

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

labscript/labscript.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,13 +721,9 @@ def load_globals(hdf5_filename):
721721
raise LabscriptError('Error whilst parsing globals from %s. \'%s\''%(hdf5_filename,name) +
722722
' is a reserved Python keyword.' +
723723
' Please choose a different variable name.')
724-
try:
725-
assert '.' not in name
726-
exec(name + ' = 0')
727-
exec('del ' + name )
728-
except:
729-
raise LabscriptError('ERROR whilst parsing globals from %s. \'%s\''%(hdf5_filename,name) +
730-
'is not a valid Python variable name.' +
724+
if not name.isidentifier():
725+
raise LabscriptError('Error whilst parsing globals from %s. \'%s\''%(hdf5_filename,name) +
726+
' is not a valid Python variable name.' +
731727
' Please choose a different variable name.')
732728

733729
# Workaround for the fact that numpy.bool_ objects dont

0 commit comments

Comments
 (0)