[issue36379] nb_inplace_pow is always called with an invalid argument

2019-03-20 Thread Zuzu_Typ


New submission from Zuzu_Typ :

Using the C-API, the inplace_pow numbermethod is always called with the third 
argument pointing to an invalid address.

The reason is likely that self.__ipow__ only takes one argument, resulting in a 
binaryfunc (self, arg), though inplace_pow is a ternaryfunc.
When trying to use the third argument in any way, Python crashes.

The third arg should be nonexistent, NULL or Py_None.

--
components: Build, Extension Modules
messages: 338458
nosy: Zuzu_Typ
priority: normal
severity: normal
status: open
title: nb_inplace_pow is always called with an invalid argument
type: crash
versions: Python 2.7, Python 3.7

___
Python tracker 
<https://bugs.python.org/issue36379>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36379] nb_inplace_pow is always called with an invalid argument

2019-03-20 Thread Zuzu_Typ


Zuzu_Typ  added the comment:

Even though __ipow__ might be documented to take a third argument, if you build 
an inplace_pow function using the C-API, you can only pass one argument to it.

You can see that in the attached screenshot.

The example class shown in the screenshot can be found here: 
https://github.com/Zuzu-Typ/Python-C-API-extension-template

With the little template I wasn't able to reproduce the crash, but I did 
reassure myself that the third object is neither Py_None nor NULL, by adding 
"if (obj2 == Py_None || obj2 == NULL) return NULL;" before line 469 in 
"template.c", because calling __ipow__ still returned an example_class 
instance, instead of an error message, as it should if it returned NULL.

--
Added file: https://bugs.python.org/file48225/Doesn't Work.png

___
Python tracker 
<https://bugs.python.org/issue36379>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36379] nb_inplace_pow is always called with an invalid argument

2019-03-20 Thread Zuzu_Typ


Zuzu_Typ  added the comment:

This isn't about the CPython Interpreter, it's about the C-API, the APIT for 
writing c-extensions for Python.

I know it works in CPython.

--

___
Python tracker 
<https://bugs.python.org/issue36379>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33406] [ctypes] increase refcount of a CFUNCTYPE instance when passing to a CDLL

2018-05-01 Thread Zuzu_Typ

New submission from Zuzu_Typ :

It should be considered to increase the refcount of functions that are passed 
on to an external library at some point.

If this is not done and e.g. the function was a local variable, when leaving 
the scope it gets garbage-collected. When the library now tries to execute said 
function, an access violation occurs.

So if the refcount were increased either upon creating the CFUNCTYPE instance 
or when it's passed on, this could be avoided.

--
components: ctypes
messages: 316047
nosy: Zuzu_Typ
priority: normal
severity: normal
status: open
title: [ctypes] increase refcount of a CFUNCTYPE instance when passing to a CDLL
type: behavior

___
Python tracker 
<https://bugs.python.org/issue33406>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com