[Python-Dev] signature for PySide ready (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Sat Aug 19 06:33:27 EDT 2017


On 19 August 2017 at 18:38, Christian Tismer <tismer at stackless.com> wrote:

On 19.08.17 09:37, Nick Coghlan wrote:

Either way, the answer to Christian's original question is that "Yes, supporting signature is also useful in Python 2.x", as even though the native inspect module doesn't support it, 3rd party backports do. I did not use a backport, but simply hacked it together, myself: - Take the signature part of Python 3.6 out, - Adjust the syntax to Python 2.7.

The backports we're talking about are the ones that can read signature attributes, as well as synthesise them from the underlying attributes on Python level functions and code objects.

The hairy part was my way to create the PySide PyCFunction objects in a compatible way like Python 3 does it: the handling of PyCFunction's "self" parameter is different (holds type info, Python 2 does not). That needed much more internal knowledge as intended...

Well, I thought the existence of signature might be a good reason to switch to Python 3, but if I support Python 2, the advantage is gone. But if it's ok with you, then I'll publish both versions.

The builtins and standard library extension modules in 2.7 will never gain signature information (since there's no equivalent of Argument Clinic to populate the text_signature attributes).

However, aside from it being extra work that they may not want to do, there's no particular reason for 3rd party modules to avoid providing better signatures in Python 2.x.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list