aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/pywrap_tfe.i
diff options
context:
space:
mode:
authorGravatar Akshay Modi <nareshmodi@google.com>2018-04-06 10:28:10 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-04-06 10:31:53 -0700
commit5f8f0dc7998db78188c083b3c6945191145497a7 (patch)
tree143a0a08a846aeeb58c37ffd41d5634c7a36232f /tensorflow/python/pywrap_tfe.i
parent665e44f612c72d39717b0a5163dca82a07e1c174 (diff)
Allow TFE_NewContext to fail more reasonably when SWIG is checking status.
Before: TFE_Context would check nullptr, and the function would fail straight away. Now: TFE_Context is nullptr, so it skips down to checking the status, and an error is raised. I'm not able to find in SWIG documentation how to order typemaps in the generated code - ideally, I'd order it to check the status typemap first. This code makes it not dependent on this ordering either way. PiperOrigin-RevId: 191905893
Diffstat (limited to 'tensorflow/python/pywrap_tfe.i')
-rw-r--r--tensorflow/python/pywrap_tfe.i6
1 files changed, 3 insertions, 3 deletions
diff --git a/tensorflow/python/pywrap_tfe.i b/tensorflow/python/pywrap_tfe.i
index 7acb8eeb1a..5ee55301df 100644
--- a/tensorflow/python/pywrap_tfe.i
+++ b/tensorflow/python/pywrap_tfe.i
@@ -120,9 +120,9 @@ limitations under the License.
}
%typemap(out) (TFE_Context*) {
- if ($1 == nullptr) {
- SWIG_fail;
- } else {
+ // When the TFE_Context* returned is a nullptr, we expect the status is not
+ // OK. This will raise an error (happens in another typemap).
+ if ($1 != nullptr) {
$result = PyCapsule_New($1, nullptr, TFE_DeleteContextCapsule);
}
}