[issue31754] Documented type of parameter 'itemsize' to PyBuffer_FillContiguousStrides is incorrect.

2017-10-10 Thread Robert Snoeberger

New submission from Robert Snoeberger :

The signature for PyBuffer_FillContiguousStrides in the documentation shows 
that the type of parameter 'itemsize' is Py_ssize_t [1]. This is different from 
the signature in Include/abstract.h which shows that the type as int [2].


[1] https://docs.python.org/3/c-api/buffer.html#c.PyBuffer_FillContiguousStrides
[2] 
https://github.com/python/cpython/blob/49b2734bf12dc1cda80fd73d3ec8896ae3e362f2/Include/abstract.h#L559-L563

--
assignee: docs@python
components: Documentation
messages: 304096
nosy: docs@python, snoeberger
priority: normal
severity: normal
status: open
title: Documented type of parameter 'itemsize' to 
PyBuffer_FillContiguousStrides is incorrect.
versions: Python 3.6

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



[issue21418] Segv during call to super_init in application embedding Python interpreter.

2014-05-02 Thread Robert Snoeberger

New submission from Robert Snoeberger:

While embedding the Python interpreter in an application, I have encountered a 
crash when the built-in function 'super' is invoked with no arguments. The 
crash occurs during a call to PyObject_Call.

A file is attached, super_invoke.c, that reproduces the crash. The reproduction 
steps on my machine are the following:

% gcc -o super_invoke super_invoke.c -I/path_to_py/include/python3.5m 
-L/path_to_py/lib -lpthread -ldl -lutil -lm -lpython3.5m -Xlinker 
-export-dynamic 
% ./super_invoke 
Call super with no arguments...
Segmentation fault
% 

The crash appears to occur in the function super_init contained in the file 
Objects/typeobject.c. The code path enters the if statement that checks for no 
input arguments. The following two lines cause the crash.

PyFrameObject *f = PyThreadState_GET()->frame;
PyCodeObject *co = f->f_code;

The PyFrameObject pointer 'f' is NULL.

--
files: super_invoke.c
messages: 21
nosy: snoeberger
priority: normal
severity: normal
status: open
title: Segv during call to super_init in application embedding Python 
interpreter.
type: crash
versions: Python 3.5
Added file: http://bugs.python.org/file35131/super_invoke.c

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



[issue21563] Segv during call to builtin_execfile in application embedding Python interpreter.

2014-05-23 Thread Robert Snoeberger

New submission from Robert Snoeberger:

While embedding the Python 2.7 interpreter in an application, I have 
encountered a crash when the built-in function 'execfile' is invoked with one 
argument.

A file is attached, execfile_invoke.c, that reproduces the crash. The 
reproduction steps on my machine are the following:

% gcc -o execfile_invoke execfile_invoke.c -I/usr/include/python2.7 -L/usr/lib 
-lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic
% ./execfile_invoke
Call execfile with one argument...
Segmentation fault
% 

I am using the following version of Python.

Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
[GCC 4.7.2] on linux2

The crash appears to occur because a call to PyEval_GetGlobals returns a NULL 
PyObject*,

globals = PyEval_GetGlobals();

and PyDict_GetItemString is called before a NULL check is performed.

In the Python 3 function builtin_exec, globals and locals are checked for NULL. 
If either is NULL, an exception with message "globals and locals cannot be 
NULL" is set.

if (!globals || !locals) {
 PyErr_SetString(PyExc_SystemError,
"globals and locals cannot be NULL");
   return NULL;
}

--
files: execfile_invoke.c
messages: 218988
nosy: snoeberger
priority: normal
severity: normal
status: open
title: Segv during call to builtin_execfile in application embedding Python 
interpreter.
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file35329/execfile_invoke.c

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



[issue21563] Segv during call to builtin_execfile in application embedding Python interpreter.

2014-05-26 Thread Robert Snoeberger

Robert Snoeberger added the comment:

I created a patch to add a check for NULL globals or locals. The file 
execfile.patch is attached. A system error is set with the message "globals and 
locals cannot be NULL" if either is NULL.

An open question I have is how should I create tests for this patch? I verified 
that the crash doesn't occur when I run the attached execfile_invoke.c program.

--
keywords: +patch
Added file: http://bugs.python.org/file35372/execfile.patch

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



[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.

2014-08-20 Thread Robert Snoeberger

New submission from Robert Snoeberger:

>>> import fractions
>>> fractions.gcd(16, float('inf'))
Traceback (most recent call last):
  File "", line 1, in 
fractions.gcd(16, float('inf'))
  File "C:\Python34-32bit\lib\fractions.py", line 24, in gcd
a, b = b, a%b
KeyboardInterrupt
>>> fractions.gcd(16, float('nan'))
Traceback (most recent call last):
  File "", line 1, in 
fractions.gcd(16, float('nan'))
  File "C:\Python34-32bit\lib\fractions.py", line 24, in gcd
a, b = b, a%b
KeyboardInterrupt
>>> 

With the iterative algorithm that is used 

a, b = b, a%b

b converges to float('nan'). It will never become 0 to break out of the loop. 
It might be nice to error when the iteration has converged b to a value other 
than 0.

--
components: Library (Lib)
messages: 225576
nosy: snoeberger
priority: normal
severity: normal
status: open
title: fractions.gcd results in infinite loop when nan or inf given as 
parameter.
type: enhancement
versions: Python 3.4

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



[issue23110] Document if argument to Py_SetPath requires static storage.

2014-12-24 Thread Robert Snoeberger

New submission from Robert Snoeberger:

The documentation for the Py_SetPath API does not indicate if the argument 
should point to a wide character array in static storage. However, the 
documentation for Py_GetPath says, "The returned string points into static 
storage; the caller should not modify its value." This leads me to believe that 
static storage is required for Py_SetPath.

The documentation for similar API functions, Py_SetPythonHome and 
Py_SetProgramName, indicates, "The argument should point to a zero-terminated 
wide character string in static storage whose contents will not change...".

--
assignee: docs@python
components: Documentation
messages: 233081
nosy: docs@python, snoeberger
priority: normal
severity: normal
status: open
title: Document if argument to Py_SetPath requires static storage.
type: enhancement
versions: Python 3.5

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