Csaba Ringhofer created THRIFT-5892:
---------------------------------------

             Summary: PY_SSIZE_T_CLEAN error in some environments
                 Key: THRIFT-5892
                 URL: https://issues.apache.org/jira/browse/THRIFT-5892
             Project: Thrift
          Issue Type: Bug
          Components: Python - Library
    Affects Versions: 0.22.0, 0.16.0
            Reporter: Csaba Ringhofer


The error described in THRIFT-5488 comes up in some environments even after the 
original fix. I could reproduce this on a chainguard based docked image (GCC 
15), while on my Ubuntu desktop things worked well (GCC 9) . I don't know the 
exact cause of the different behavior, on guess is the different GCC version
Other info on the environment:
Python: 3.11.13
Thrift: 0.16 / 0.22 / master (probably all versions between but I didn't try)

Adding #define PY_SSIZE_T_CLEAN to 
https://github.com/apache/thrift/blob/master/lib/py/src/ext/module.cpp before 
including Python.h solved the issue.

The issue was discover in https://github.com/cloudera/impyla which tries to use 
the native binary protocol module:
{code}
>>> from impala.dbapi import connect
>>> con=connect(host=...)
>>> cur=con.cursor()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/impala-test-3/lib/python3.11/site-packages/impala/hiveserver2.py", 
line 129, in cursor
    session = self.service.open_session(user, configuration)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/impala-test-3/lib/python3.11/site-packages/impala/hiveserver2.py", 
line 1189, in open_session
    resp = self._rpc('OpenSession', req, True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/impala-test-3/lib/python3.11/site-packages/impala/hiveserver2.py", 
line 1082, in _rpc
    response = self._execute(func_name, request, retry_on_http_error)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/impala-test-3/lib/python3.11/site-packages/impala/hiveserver2.py", 
line 1100, in _execute
    return func(request)
           ^^^^^^^^^^^^^
  File 
"/tmp/impala-test-3/lib/python3.11/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py",
 line 196, in OpenSession
    return self.recv_OpenSession()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File 
"/tmp/impala-test-3/lib/python3.11/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py",
 line 215, in recv_OpenSession
    result.read(iprot)
  File 
"/tmp/impala-test-3/lib/python3.11/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py",
 line 1415, in read
    iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to