From df3b9d84d5364a6b6ed91f7fca3b6366d77be7ae Mon Sep 17 00:00:00 2001 From: Sanath Kumar Ramesh Date: Fri, 7 Jun 2019 14:07:28 -0700 Subject: [PATCH] fix: WindowsError keyword is undefined on non-Windows platforms (#117) WindowsError is a subclass of `OSError`. It is defined and raised only in Windows. Hence the exception statement will return a `WindowsError keyword is undefined` in other platforms. Usually this error is encountered when CodeUri: /folder/does/not/exist. The builder tries to copy the files and fails because the path does not exist. On Windows, the exception handler works, but on Mac/Linux Python interpreter does not find the variable WindowsError and crashes. So it leads to a vague WindowsError on Mac/Linux. --- aws_lambda_builders/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws_lambda_builders/utils.py b/aws_lambda_builders/utils.py index d5b2ec9aa..b8e6e3ea7 100644 --- a/aws_lambda_builders/utils.py +++ b/aws_lambda_builders/utils.py @@ -36,7 +36,7 @@ def copytree(source, destination, ignore=None): try: # Let's try to copy the directory metadata from source to destination shutil.copystat(source, destination) - except WindowsError as ex: # pylint: disable=undefined-variable + except OSError as ex: # Can't copy file access times in Windows LOG.debug("Unable to copy file access times from %s to %s", source, destination, exc_info=ex)