forked from clearlinux-pkgs/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch
51 lines (43 loc) · 1.79 KB
/
0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From ea3063c929c69f738bf65bc99dad1159803e772f Mon Sep 17 00:00:00 2001
From: Yong Tang <yong.tang.github@outlook.com>
Date: Sun, 3 Nov 2019 19:52:04 +0000
Subject: [PATCH 1/2] Fix TensorFlow on Python 3.8 logger issue
This fix tries to address the issue raised in 33799
where running tensorflow on python 3.8 (Ubuntu 18.04)
raised the following error:
```
TypeError: _logger_find_caller() takes from 0 to 1 positional arguments but 2 were given
```
The issue was that findCaller changed in Python 3.8
This PR fixes the issue.
This PR fixes 33799
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
---
tensorflow/python/platform/tf_logging.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tensorflow/python/platform/tf_logging.py b/tensorflow/python/platform/tf_logging.py
index 86a4957c9d..a397393e7f 100644
--- a/tensorflow/python/platform/tf_logging.py
+++ b/tensorflow/python/platform/tf_logging.py
@@ -57,9 +57,18 @@ def _get_caller(offset=3):
f = f.f_back
return None, None
-
# The definition of `findCaller` changed in Python 3.2
-if _sys.version_info.major >= 3 and _sys.version_info.minor >= 2:
+if _sys.version_info.major >= 3 and _sys.version_info.minor >= 8:
+ def _logger_find_caller(stack_info=False, stacklevel=1): # pylint: disable=g-wrong-blank-lines
+ code, frame = _get_caller(4)
+ sinfo = None
+ if stack_info:
+ sinfo = '\n'.join(_traceback.format_stack())
+ if code:
+ return (code.co_filename, frame.f_lineno, code.co_name, sinfo)
+ else:
+ return '(unknown file)', 0, '(unknown function)', sinfo
+elif _sys.version_info.major >= 3 and _sys.version_info.minor >= 2:
def _logger_find_caller(stack_info=False): # pylint: disable=g-wrong-blank-lines
code, frame = _get_caller(4)
sinfo = None
--
2.24.0