This is an automated email from the ASF dual-hosted git repository.

yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 065e449aa73d87d98c0cf44709892c04344f9989
Author: Yongtao Huang <99629139+hyongtao...@users.noreply.github.com>
AuthorDate: Sat Jul 8 11:00:49 2023 +0800

    Fix: BaseException.message deprecated since Python 2.6 (#15943)
    
    Long log:
    
    `BaseException.message` was deprecated since Python 2.6 and removed in 
Python 3.
    
    This is a tiny example:
    ```
    def test_func():
        if 1 == 2:
            allen_dic = {}  # trigger an exception
        allen_dic['allen'] = 'handsome'
    
    try:
        test_func()
    except Exception as e:
        raise Exception("Error msg: %s" % e.message)
    ```
    
    Run the example in _Python3_, error result is shown as below:
    ```
    Traceback (most recent call last):
      File "hello.py", line 9, in <module>
        raise Exception("Error msg: %s" % e.message)
    AttributeError: 'UnboundLocalError' object has no attribute 'message'
    ```
    
    **Solution**: substitute `str(e)` for `e.message`
    
    Signed-off-by: Yongtao Huang <yongt...@vmware.com>
---
 gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py 
b/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py
index d2f52f33b2..8ba11b7933 100644
--- a/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py
+++ b/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py
@@ -2024,7 +2024,7 @@ def impl(context, type):
         result = curs.fetchall()
         segment_info = [(result[s][0], result[s][1]) for s in 
range(len(result))]
     except Exception as e:
-        raise Exception("Could not retrieve segment information: %s" % 
e.message)
+        raise Exception("Could not retrieve segment information: %s" % str(e))
     finally:
         conn.close()
 
@@ -2067,7 +2067,7 @@ def impl(context, filename, some, output):
         result = curs.fetchall()
         segment_info = [(result[s][0], result[s][1]) for s in 
range(len(result))]
     except Exception as e:
-        raise Exception("Could not retrieve segment information: %s" % 
e.message)
+        raise Exception("Could not retrieve segment information: %s" % str(e))
     finally:
         conn.close()
 
@@ -2113,7 +2113,7 @@ def impl(context, filename, contain, output):
         result = curs.fetchall()
         segment_info = [(result[s][0], result[s][1]) for s in 
range(len(result))]
     except Exception as e:
-        raise Exception("Could not retrieve segment information: %s" % 
e.message)
+        raise Exception("Could not retrieve segment information: %s" % str(e))
     finally:
         conn.close()
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cloudberry.apache.org
For additional commands, e-mail: commits-h...@cloudberry.apache.org

Reply via email to