Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Error during connection via Paramiko in Pythonista beta 340008
-
Error is
Unknown exception: PY_SSIZE_T_CLEAN macro must be defined for '#' formats Traceback (most recent call last): File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1799, in run self.kex_engine.parse_next(ptype, m) File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/kex_group1.py", line 76, in parse_next return self._parse_kexdh_reply(m) File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/kex_group1.py", line 113, in _parse_kexdh_reply self.transport._activate_outbound() File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 2136, in _activate_outbound engine = self._get_cipher(self.local_cipher, key_out, IV_out) File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1667, in _get_cipher return self._cipher_info[name]['class'].new(key, self._cipher_info[name]['mode'], '', counter) File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/Crypto/Cipher/AES.py", line 96, in new return AESCipher(key, *args, **kwargs) File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/Crypto/Cipher/AES.py", line 60, in __init__ blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs) File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/Crypto/Cipher/blockalgo.py", line 142, in __init__ self._cipher = factory.new(key, *args, **kwargs) SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats --- error during connection to: iMac : PY_SSIZE_T_CLEAN macro must be defined for '#' formats
-
@cvp Well according to the error message, the PY SSIZE T CLEAN macro must be declared for '#' forms. This macro is important to how Python handles numbers and is typically included in Python headers for compatibility.
So To avoid this problem, specify the PY SSIZE T CLEAN macro in your code before including any Python header files.
#define PY_SSIZE_T_CLEAN #include <Python.h>
Also this code can be included at the beginning of your script, before importing the paramiko module. If you use a package that uses paramiko internally, you may need to edit its source code to include this snippet as well.
And if this does not resolve the issue, there could be a problem with the version of the paramiko module you are using. You could try upgrading to a newer version of the module to see if that addresses the problem.
that is what i think -
@tanjiro887 thanks to try to help me but your code is C-code and under Pythonista we only can program in Python. I guess that your advice could be good for @omz who develops Pythonista in C, but I also guess he is aware of the problem and I'm confident he will solve it in next beta/version.
Anyway, welcome in this forum -
@cvp oh okay and thank you :)
-
@omz this problem should have been resolved in 340007 but is still there in 340008 and is very annoying because SFTP does not work anymore.
-
@omz thanks, it works now in 340009