Skip to content

Commit 14bf9e8

Browse files
committed
Only fail ws name validation in debug mode.
1 parent 5eeb47c commit 14bf9e8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Framework/API/src/AnalysisDataService.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,29 @@ std::shared_ptr<const WorkspaceGroup> AnalysisDataServiceImpl::GroupUpdatedNotif
3939
*/
4040
const std::string AnalysisDataServiceImpl::isValid(const std::string &name) const {
4141
std::regex validName("^[a-zA-Z_][\\w]*");
42-
4342
std::string error = "";
4443

4544
if (!std::regex_match(name, validName)) {
4645
error =
4746
"Invalid object name '" + name +
4847
"'. Names must start with a letter or underscore and contain only alpha-numeric characters and underscores.";
48+
49+
// Log a warning message to let user know we will stop allowing invalid variable names in the future.
50+
const std::string warningMessage =
51+
error + "\n"
52+
"Currently this is only a warning, but in a future version of Mantid this will raise an exception and "
53+
"the operation will fail.\n"
54+
"Please update your scripts to use valid Python identifiers for workspace names.";
55+
Kernel::Logger log("AnalaysisDataService");
56+
log.warning(warningMessage);
4957
}
58+
59+
// Fail in debug mode if name is not valid.
60+
#ifndef NDEBUG
5061
return error;
62+
#endif
63+
64+
return "";
5165
}
5266

5367
/**

0 commit comments

Comments
 (0)