-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Undefined variable value yields '.' as node and may cause removing all files in tree. #3905
base: master
Are you sure you want to change the base?
Conversation
… cause rermoving all files in tree.
@@ -2000,6 +2001,19 @@ def CacheDir(self, path): | |||
|
|||
def Clean(self, targets, files): | |||
global CleanTargets | |||
|
|||
# Check for anything which evaluates to empty string, which would yield cleaning '.' | |||
targets_strings = [(t, self.subst(t)) for t in flatten(targets) if is_String(t) and ('$' in t or t == '')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be simpler to just let tlist
and flist
expand and check in them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't think using tlist or flist would allow proper checking for accidental '.' from undefined var.
Also you wouldn't be able to give as much information about what was wrong.
raise UserError( | ||
"Targets specified to Clean() include one which evaluates to an empty string: [%s]" % ",".join( | ||
["%s='%s'" % (str(t), s) for (t, s) in targets_strings])) | ||
if any([s == '' for t, s in files_strings]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that one stanza checks targets_strings and the other files_strings, but this still reads quite duplicative... any way to combine?
Attaching a test case made from the original report (suffixed .txt instead of .py due to github limitations) |
Fixes #2801. Undefined variable value yields '.' as node and may cause removing all files in tree.
Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)