[
https://issues.apache.org/jira/browse/THRIFT-5488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18019537#comment-18019537
]
Csaba Ringhofer edited comment on THRIFT-5488 at 9/11/25 8:45 AM:
------------------------------------------------------------------
I bumped into this issue again using Python 3.11.13 and in some specific
environment - the issue came on a chainguard image with gcc 15 but not on my
desktop with gcc 9. Adding #define PY_SSIZE_T_CLEAN to one more file
(module.cpp) solved the issue. I am still trying to understand what causes the
difference.
was (Author: csringhofer):
I bumped into this issue again using Python 3.11.13 and in some specific
environment - the issue came on a chainguard image with GCC 15 but not on my
desktop with gcc9. Adding #define PY_SSIZE_T_CLEAN to one more file
(module.cpp) solved the issue. I am still trying to understand what causes the
difference.
> SystemError when using fast binary or compact protocol in python 3.10
> ----------------------------------------------------------------------
>
> Key: THRIFT-5488
> URL: https://issues.apache.org/jira/browse/THRIFT-5488
> Project: Thrift
> Issue Type: Bug
> Components: Python - Library
> Affects Versions: 0.15.0
> Reporter: Ali-Akber Saifee
> Assignee: Ali-Akber Saifee
> Priority: Major
> Fix For: 0.16.0
>
> Time Spent: 3h
> Remaining Estimate: 0h
>
> Up till python 3.9 a DeprecationWarning was raised when '#' formats were
> used without defining PY_SSIZE_T_CLEAN:
>
> {code:java}
> DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
> iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) {code}
>
> Starting with python 3.10 this now becomes a runtime SystemError. Details of
> change: [Python bug tracker 40943|https://bugs.python.org/issue40943]
> This specifically gets exercised in the c python extension module in
> ProtocolBase<Impl>::readBytes
> ([src/protocol.tcc|https://github.com/apache/thrift/blob/master/lib/py/src/ext/protocol.tcc#L279])
> when falling back to the building function.
> An easy way to reproduce the error is to pass an empty byte array to the
> [TSerializer.deserialize|https://github.com/apache/thrift/blob/master/lib/py/src/TSerialization.py#L32]
> method, for example:
> {code:java}
> buf = TTransport.TMemoryBuffer()
> transport = TTransport.TBufferedTransportFactory().getTransport(buf)
> factory = TBinaryProtocolAcceleratedFactory(transport)
> TSerialization.deserialize(Message(), b'', factory) # Message is a thrift
> struct. This raises a SystemError in python 3.10+{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)