Skip to content

Use a more compatable way to get wrapper_descriptor and method_wrapper#30

Open
Daetalus wants to merge 1 commit into
testing-cabal:masterfrom
Daetalus:master
Open

Use a more compatable way to get wrapper_descriptor and method_wrapper#30
Daetalus wants to merge 1 commit into
testing-cabal:masterfrom
Daetalus:master

Conversation

@Daetalus

Copy link
Copy Markdown

The original code use type(type.call) to get the type
wrapper_descriptor and use type(all.__call__) to get type
method_wrapper. according the comment in here:
https://github.com/Daetalus/funcsigs/blob/master/funcsigs/__init__.py#L170.
It could avoid infinite recursive or sefault.

In Pyston, the type of type.__call__ is instancemethod. So it will
cause segfault. I change it to type(bytearray.__add__), because in
Pyston, its type is wrapper_descriptor, this is also work in CPython
2.x and CPython 3.x.

More information, please see scikit-learn/scikit-learn#7162.

The original code use type(type.__call__) to get the type
`wrapper_descriptor` and use `type(all.__call__)` to get type
`method_wrapper`. according the comment in here:
https://github.com/Daetalus/funcsigs/blob/master/funcsigs/__init__.py#L170.
It could avoid infinite recursive or sefault.

In Pyston, the type of `type.__call__` is `instancemethod`. So it will
cause segfault. I change it to `type(bytearray.__add__)`, because in
Pyston, its type is `wrapper_descriptor`, this is also work in CPython
2.x and CPython 3.x.

More information, please see scikit-learn/scikit-learn#7162.
Comment thread funcsigs/__init__.py
_WrapperDescriptor = type(type.__call__)
_MethodWrapper = type(all.__call__)
_WrapperDescriptor = type(bytearray.__add__)
_MethodWrapper = type(u'str'.__add__)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not plain 'str'.__add__? u'' introduces an incompatibility with Python 3.2

@Daetalus Daetalus Sep 4, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emm... This is because in Pyston, the type of 'str'.__add__ still is instancemethod.

Pyston v0.6.0 (rev 8dd1298946b5dbe2b28f75a7a6d2de6486765438), targeting Python 2.7.7
>> type('str'.__add__)
<type 'instancemethod'>
>> type(u'str'.__add__)
<type 'method-wrapper'>

And according the description of funcsigs in README file, I thought we can drop the Python 3.2 support.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me :-)

@Daetalus

Daetalus commented Sep 15, 2016

Copy link
Copy Markdown
Author

Guys? @epsy @msabramo @rbtcollins Does there has a better way to do this?

@epsy

epsy commented Sep 15, 2016

Copy link
Copy Markdown

(I'm only a user of funcsigs, I don;t have merge approval access)

I suppose it's entirely fair to drop Python 3.2 support at this point.

@Daetalus

Copy link
Copy Markdown
Author

Thanks for review it! @epsy

@lesteve

lesteve commented Dec 7, 2016

Copy link
Copy Markdown

ping @rbtcollins maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants