diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-09-10 19:50:28 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-10 19:53:39 -0700 |
commit | e6830cdb06efe6f4cea2e4f30aa98f66ee1b305a (patch) | |
tree | f51142af388f5e02ad636288c15921754c304322 /tensorflow/python/framework | |
parent | 497715e0a9bbb3c844a1902e319778cc30819f77 (diff) |
Resolving a bug where regex pattern for errors was not matching in case the error message had multiple newline characters.
PiperOrigin-RevId: 212381070
Diffstat (limited to 'tensorflow/python/framework')
-rw-r--r-- | tensorflow/python/framework/error_interpolation.py | 2 | ||||
-rw-r--r-- | tensorflow/python/framework/error_interpolation_test.py | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/tensorflow/python/framework/error_interpolation.py b/tensorflow/python/framework/error_interpolation.py index 46bda2e621..bc3c81b2a2 100644 --- a/tensorflow/python/framework/error_interpolation.py +++ b/tensorflow/python/framework/error_interpolation.py @@ -34,7 +34,7 @@ from tensorflow.python.util import tf_stack _NAME_REGEX = r"[A-Za-z0-9.][A-Za-z0-9_.\-/]*?" _TAG_REGEX = r"{{{{({name}) ({name})}}}}".format(name=_NAME_REGEX) _INTERPOLATION_REGEX = r"^(.*?)({tag})".format(tag=_TAG_REGEX) -_INTERPOLATION_PATTERN = re.compile(_INTERPOLATION_REGEX) +_INTERPOLATION_PATTERN = re.compile(_INTERPOLATION_REGEX, re.DOTALL) _ParseTag = collections.namedtuple("_ParseTag", ["type", "name"]) diff --git a/tensorflow/python/framework/error_interpolation_test.py b/tensorflow/python/framework/error_interpolation_test.py index d312b825d2..1b77548592 100644 --- a/tensorflow/python/framework/error_interpolation_test.py +++ b/tensorflow/python/framework/error_interpolation_test.py @@ -184,9 +184,14 @@ class InterpolateFilenamesAndLineNumbersTest(test.TestCase): interpolated_string = error_interpolation.interpolate( two_tags_with_seps, self.graph) expected_regex = ( - r"^;;;.*constant_op.py:[0-9]+\) ,,,.*constant_op.py:[0-9]*\) ;;;$") + r"^;;;.*constant_op.py:[0-9]+\) ,,,.*constant_op.py:[0-9]+\) ;;;$") self.assertRegexpMatches(interpolated_string, expected_regex) + def testNewLine(self): + newline = "\n\n{{node One}}" + interpolated_string = error_interpolation.interpolate(newline, self.graph) + self.assertRegexpMatches(interpolated_string, "constant_op.py:[0-9]+.*") + class InterpolateDeviceSummaryTest(test.TestCase): |