[issue24379] operator.subscript

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm with Martin about tests. Only one assertion per special case is needed, no 
need to write exponential number of combinations.

--

___
Python tracker 

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




[issue24379] operator.subscript

2015-07-12 Thread Joe Jevnik

Joe Jevnik added the comment:

is it normal to get a lot of 500s when using the review system?

--
Added file: http://bugs.python.org/file39906/operator_subscript_pyonly.patch

___
Python tracker 

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



[issue24379] operator.subscript

2015-07-12 Thread Joe Jevnik

Changes by Joe Jevnik :


Added file: http://bugs.python.org/file39907/operator_subscript_pyonly.patch

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> In sample() the selected set can be initialized to {n}

I originally used the {n} approach but it was less clear and it lead to a 
re-selection rather than undoing the rounding.  That would change the output.

> I like Tim's suggestion about import-time patching.

Sorry, but there's a limit to how much I'm willing to garbage-up the code over 
this issue.

> In choice() I would write the condition as "i == n > 0" to 
> avoid indexing with negative index

I'll write that as "'i == n and n > 0" which reads better and runs faster in 
the common case (look at the disassembly of each).

Attaching a revised patch.

> here's another timing variation:
>
>i = int(random() * n)
>return seq[i - (i == n)]

This ran a little slower than the conditional approach.

--
Added file: http://bugs.python.org/file39908/handle_double_rounding3.diff

___
Python tracker 

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



[issue24614] 404 link in Documenting Python, Style Guide

2015-07-12 Thread Julien Maisonneuve

New submission from Julien Maisonneuve:

The link to the Apple Publications Style Guide on this page 
https://docs.python.org/3.0/documenting/style.html lniks to a 404 page on 
https://developer.apple.com/ 
(https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/APStyleGuide/APSG_2008.pdf)

--
assignee: docs@python
components: Documentation
messages: 246640
nosy: Julien Maisonneuve, docs@python
priority: normal
severity: normal
status: open
title: 404 link in Documenting Python, Style Guide
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> I originally used the {n} approach but it was less clear and it lead to a 
> re-selection rather than undoing the rounding.  That would change the output.

In normal case j is never equal to n. In very rare cases on platforms with 
double rounding the unpatched code generates an IndexError, and changing this 
is the purpose of the patch. Re-selection is so good as undoing the rounding.

Please also note that double rounding causes an error not only when 
int(random() * n) == n. If random() returns 0.5 - 2**-54 and n = 2029*2, the 
result is different with double rounding and without it. This causes small bias 
even if IndexError is not raised.

--

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Mark Dickinson

Mark Dickinson added the comment:

Serhiy: there's already a small bias inherent in using `int(random() * n)`, 
regardless of double rounding, since in general `random()` gives 2**53 equally 
likely (modulo deficiencies in the source generator) outcomes and `n` need not 
be a divisor of `2**53`.  I don't think the double rounding is going to make 
that bias noticeably worse.

See issue 23974, which was resolved as "wont fix".

--

___
Python tracker 

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



[issue24614] 404 link in Documenting Python, Style Guide

2015-07-12 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report, Julien.

The up-to-date version of the document can be found at 
https://docs.python.org/devguide/documenting.html

Also, Python 3.0.1 documentation is really old and I think the "The Python 
documentation should follow the Apple Publications Style Guide wherever 
possible." part is no longer true.

--
nosy: +berker.peksag
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-12 Thread Ron Barak

Ron Barak added the comment:

I tried to apply the patch. Alas, I get an "Hmm... I can't seem to find a patch 
in there anywhere." error. 

See attached screenshot.

Did I apply the patch incorrectly?

--
Added file: http://bugs.python.org/file39909/issue24611.PNG

___
Python tracker 

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



[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-12 Thread Ron Barak

Ron Barak added the comment:

When I try to apply the patch manually, namely - editing Modules/posixmodule.c, 
and moving the #endif a few lines up, the make finishes correctly.

So, the patch does work: I'm probably not applying it correctly.

Could you point to my error in applying the patch?

--

___
Python tracker 

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



[issue24615] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Ron Barak

New submission from Ron Barak:

I wanted to add Python 2.7 to Unix.
I downloaded the sources to the VirtualBox on which the Unix is installed.

./configure is successful.
make is successful after I manually applied the changes in 
http://bugs.python.org/issue24611

However, 'make install' fails the installation of man pages (see attached).

(Note that Python 2.7.10 is installed and is accessible as 
/usr/local/bin/python2.7)


./configure --prefix=/usr   \
--enable-shared \
--with-system-expat \

without problems.

However, when I try to run make, it fails on:

cc –Kpthread –Wl,-Bexport –o python Modules/python.o libpython2.7.a -lsocket 
–lnsl –lpthread –ldl –lm 

Undefined   first referenced
symbol  in file
_PyInt_FromDev  libpython2.7.a(posixmodule.o) 
UX:ld: ERROR: Symbol referencing errors. No output written to python
*** Error code 1 (bu21)
UX:make: ERROR: fatal error.


Environment:

OS  Unixware 7.1.4
Python   2.7.10
CC  Optimizing C Compilation System (CCS) 4.2 05/11/04 (ux714.bl3af)

--
components: Build
files: make_install_fail.PNG
messages: 246646
nosy: ronbarak
priority: normal
severity: normal
status: open
title: 'make install' fails installation of man pages for Python 2.7.10 on 
Unixware 7.1.4
versions: Python 2.7
Added file: http://bugs.python.org/file39910/make_install_fail.PNG

___
Python tracker 

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



[issue24615] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Ron Barak

Changes by Ron Barak :


--
components: +Installation -Build

___
Python tracker 

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



[issue24615] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Ron Barak

Ron Barak added the comment:

EDIT 1 (cut and paste had some extraneous data):

I wanted to add Python 2.7 to Unix.
I downloaded the sources to the VirtualBox on which the Unix is installed.

./configure is successful.
make is successful after I manually applied the changes in 
http://bugs.python.org/issue24611

However, 'make install' fails the installation of man pages (see attached).

(Note that Python 2.7.10 is installed and is accessible as 
/usr/local/bin/python2.7)


Environment:

OS  Unixware 7.1.4
Python   2.7.10
CC  Optimizing C Compilation System (CCS) 4.2 05/11/04 (ux714.bl3af)

--
Added file: http://bugs.python.org/file39911/make_install_fail.PNG

___
Python tracker 

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



[issue24616] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Ron Barak

New submission from Ron Barak:

I wanted to add Python 2.7 to Unix.
I downloaded the sources to the VirtualBox on which the Unix is installed.

./configure is successful.
make is successful after I manually applied the changes in 
http://bugs.python.org/issue24611

However, 'make install' fails the installation of man pages (see attached).

(Note that Python 2.7.10 is installed and is accessible as 
/usr/local/bin/python2.7)


Environment:

OS  Unixware 7.1.4
Python   2.7.10
CC  Optimizing C Compilation System (CCS) 4.2 05/11/04 (ux714.bl3af)

--
components: Installation
files: make_install_fail.PNG
messages: 246648
nosy: ronbarak
priority: normal
severity: normal
status: open
title: 'make install' fails installation of man pages for Python 2.7.10 on 
Unixware 7.1.4
versions: Python 2.7
Added file: http://bugs.python.org/file39912/make_install_fail.PNG

___
Python tracker 

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



[issue24615] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Ron Barak

Changes by Ron Barak :


--
resolution:  -> duplicate
status: open -> closed

___
Python tracker 

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



[issue4963] mimetypes.guess_extension result changes after mimetypes.init()

2015-07-12 Thread Julian Sivertsen

Julian Sivertsen added the comment:

I bumped into a similar issue with mimetypes.guess_extension on Arch Linux 
64-bit in February.  The behavior is still present in python 3.4.3.

$ python test.py
.htm
$ python test.py
.html
$ cat test.py
from mimetypes import guess_extension

print(guess_extension('text/html'))
$ python
Python 3.4.3 (default, Mar 25 2015, 17:13:50)
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

--
nosy: +sivert

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm aware of issue 23974. But I want to say that double rounding causes not 
only bias from ideal distribution, but a difference between platforms. The 
result of sample() (with the same seed) can vary between platforms.

--

___
Python tracker 

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



[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d2b8354e87f5 by Serhiy Storchaka in branch '2.7':
Issue #24611: Fixed compiling the posix module on non-Windows platforms
https://hg.python.org/cpython/rev/d2b8354e87f5

--
nosy: +python-dev

___
Python tracker 

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



[issue24379] operator.subscript

2015-07-12 Thread Joe Jevnik

Changes by Joe Jevnik :


Added file: http://bugs.python.org/file39913/operator_subscript_pyonly.patch

___
Python tracker 

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



[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue24611] Compiling Python 2.7.10 Error on Unixware 7.1.4

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm not experienced with Unixware's version of the patch (perhaps it differs 
from Linux version), but try to use the -p1 option.

--

___
Python tracker 

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



[issue24616] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It would be more helpful if you sent text output instead of graphical 
screenshot. Just redirect stdout and stderr of the command to the file.

make install >make_install_fail.txt 2>&1

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue24616] 'make install' fails installation of man pages for Python 2.7.10 on Unixware 7.1.4

2015-07-12 Thread Ron Barak

Ron Barak added the comment:

@Serhiy,
Not only would posting text be clearer, but much easier.
Alas, the Unixware I use is on a VirtualBox, and VitualBox does not support 
Guest Extension on Unixware - which means that neither cut-and-paste nor 
sharing host filesystem are possible.

So, unless I get any ideas of how to get text off my Unixware on VirtualBox, 
screenshots are all I have.

--

___
Python tracker 

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



[issue24617] os.makedirs()'s [mode] not correct

2015-07-12 Thread John Jones

New submission from John Jones:

os.makedirs() gives the optional variable mode to set the permissions on the 
directories it creates.

While it seems to work for all triplet octal values (777,755,etc) it doesn't 
seem to work on values with the sticky bit (1777,1755,etc)

I know that to set the value as octal, you need, for some reason, to prepend a 
'0' to the number, such that the final value is '01755' - but even if you do 
int('1755',8) the error is there. Below I make a directory and then chmod it to 
the right value:

os.makedirs('/Users/Carolin/Desktop/demo',01703)
drwx-x 2 Carolin  staff  68 12 Jul 18:53 demo

os.chmod('/Users/Carolin/Desktop/demo',01703)
drwxwt 2 Carolin  staff  68 12 Jul 18:53 demo

--
messages: 246655
nosy: John Jones
priority: normal
severity: normal
status: open
title: os.makedirs()'s [mode] not correct
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Stefan Krah

Stefan Krah added the comment:

The double rounding problem even occurs between different versions
of gcc. I think ultimately we should put our foot down and ship with
sse2 enabled (not possible for 2.7 though, unless an LTS-PEP emerges).

If distributions want to break that, it's their business. :)
The gcc manual is quite upfront about the issue and really
recommends sse2 for reproducible results.

--

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> I think ultimately we should put our foot down and ship with
> sse2 enabled

That's good for x86 but that wouldn't solve the issue if it exists on other 
archs.
I trust Raymond to come up with an acceptable solution; though I think it would 
be good to add a comment linking to this issue, in any case.

--

___
Python tracker 

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



[issue24618] Invalid read in PyCode_New

2015-07-12 Thread Brad Larsen

New submission from Brad Larsen:

`PyCode_New` can read invalid heap memory.


File Objects/codeobject.c:

PyCodeObject *
PyCode_New(int argcount, int kwonlyargcount,
   int nlocals, int stacksize, int flags,
   PyObject *code, PyObject *consts, PyObject *names,
   PyObject *varnames, PyObject *freevars, PyObject *cellvars,
   PyObject *filename, PyObject *name, int firstlineno,
   PyObject *lnotab)
{
PyCodeObject *co;
unsigned char *cell2arg = NULL;
Py_ssize_t i, n_cellvars;

// ...

n_cellvars = PyTuple_GET_SIZE(cellvars);

// ...

/* Create mapping between cells and arguments if needed. */
if (n_cellvars) {
Py_ssize_t total_args = argcount + kwonlyargcount +
((flags & CO_VARARGS) != 0) + ((flags & CO_VARKEYWORDS) != 0); 
// *** 1 ***

// ...

/* Find cells which are also arguments. */
for (i = 0; i < n_cellvars; i++) {
Py_ssize_t j;
PyObject *cell = PyTuple_GET_ITEM(cellvars, i); 
for (j = 0; j < total_args; j++) {
PyObject *arg = PyTuple_GET_ITEM(varnames, j); 
// *** 2 ***
if (!PyUnicode_Compare(cell, arg)) {   
// *** 3 ***
cell2arg[i] = j;
used_cell2arg = 1;
break;
}   
}   
}

// ...
}

// ...
}

1. `total_args` is determined from parameters that are user-controlled
   (see `r_object` in `Python/marshal.c`, in the `TYPE_CODE` case,
   lines 1265--1277).
2. the `varnames` tuple is indexed with a value in the range [0, total_args),
   which could be larger than the range of valid indexes for `varnames`.
3. `arg` is now a bogus PyObject value, and causes a segfault in
   `PyUnicode_Compare`.


Environment:

$ python3.4 --version
Python 3.4.2

$ uname -a
Linux debian-8-amd64 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-3~deb8u1 
(2015-04-24) x86_64 GNU/Linux


POC:

from marshal import load
from io import BytesIO

payload = 
b'\xe3\x01\x00\xff\x00\x00\x00\x00\xfc\x01\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s\n\x00\x00\x00k\x00\x00|\x00\x00\x83\x01\x00S)\x01N)\x01\xda\x03foo)\x01\xda\x01x\xa9\x01\xda|x\xa9x\xa9\x00\xe3\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s\n\x00\x00\x00t\x00\x00|\x00\x00\x83\x01\x00S)\x01N)\x01\xda\x03foo)\x01\xda\x01x\xa9\x00r\x03\x00\x00\x00\xfa\x0fmk_tesTgases.py\xda\x08\x01\x00\x00\x00s\x00\x00\x00\x00r\x03\x00\x00\x00\xfa\x0fmk_testck_te\x00)\x01\xda\x01x\xa9x\xa9\x00\xe3\x01\x00\x00\x00\x00\x00\x80\x00\x01\x00\x00\x00\x02\x00\x00\x00C\x00\x00\x00s\n\x00\x00\x00t\x00\x00"\x00\x00\x83\x01\x00S)\x01N)\x01\xda\x03foo)\x01\xda\x01x\xa9\x00r\x03\x00\x00\x00\xfa\x0fmk_tMstgases\x11py\xda\x08$\x00\x00\x12s\x00\x00\x00\x00r\x03\x00'
load(BytesIO(payload))

--
components: Interpreter Core
files: invalid_read.py
messages: 246658
nosy: blarsen
priority: normal
severity: normal
status: open
title: Invalid read in PyCode_New
type: crash
versions: Python 3.4
Added file: http://bugs.python.org/file39914/invalid_read.py

___
Python tracker 

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



[issue24618] Invalid read in PyCode_New

2015-07-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue24617] os.makedirs()'s [mode] not correct

2015-07-12 Thread eryksun

eryksun added the comment:

This is not a bug, but perhaps the documentation could further clarify that the 
set of valid values for the mode parameter is platform dependent. The [POSIX 
specification][1] for mkdir() states that "[w]hen bits in mode other than the 
file permission bits are set, the meaning of these additional bits is 
implementation-defined". On Linux, mkdir honors the sticky bit (S_ISVTX). On OS 
X, on the other hand, the [man page][2] states that "the behavior of mkdir() is 
undefined when mode bits other than the low 9 bits are used. Use chmod(2) after 
mkdir() to explicitly set the other bits".

1. http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html
2. 
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/mkdir.2.html

--
nosy: +eryksun

___
Python tracker 

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



[issue24619] async/await parser issues

2015-07-12 Thread Stefan Krah

New submission from Stefan Krah:

If I understand the reference manual correctly, these should probably
be rejected by the compiler:

>>> async def f():
... def g(): pass
... async = 10
... 
>>> async def f():
... def async():
... pass
... 
>>> async def f(): async = 10
... 
>>> async def f():
... def await(): pass
... 
>>> 


And this should perhaps be accepted:

>>> async def f():
... return lambda await: await
  File "", line 2
return lambda await: await
  ^
SyntaxError: invalid syntax


This, too:

>>> async def f():
... async def g(): pass
... await z
  File "", line 3
await z
  ^
SyntaxError: invalid syntax

--
messages: 246660
nosy: gvanrossum, skrah, yselivanov
priority: normal
severity: normal
status: open
title: async/await parser issues

___
Python tracker 

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



[issue24620] Segfault with nonsensical random state

2015-07-12 Thread Stefan Krah

New submission from Stefan Krah:

While trying to find a possible cause for #24546, I came across this
glitch:

Python 3.6.0a0 (default:02b81a82a57d, Jul 12 2015, 20:33:44) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> s = (3, (999,)*625, None)
>>> random.setstate(s)
>>> random.choice([1,2,3,4,5])
Segmentation fault (core dumped)

--
messages: 246661
nosy: mark.dickinson, rhettinger, skrah
priority: normal
severity: normal
status: open
title: Segfault with nonsensical random state

___
Python tracker 

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



[issue24621] zipfile.BadZipFile: File is not a zip file

2015-07-12 Thread Yasar Luqman Ahmed

New submission from Yasar Luqman Ahmed:

I have a zip-file that can be opened/extracted with 7zip but gives an error 
when I try work with it in python:
Py2 (2.7.3 / Linux/Debian7):
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.7/zipfile.py", line 714, in __init__
self._GetContents()
  File "/usr/lib/python2.7/zipfile.py", line 748, in _GetContents
self._RealGetContents()
  File "/usr/lib/python2.7/zipfile.py", line 763, in _RealGetContents
raise BadZipfile, "File is not a zip file"
zipfile.BadZipfile: File is not a zip file


Py3 (3.4.3 / Windows 7 /64bit):
Traceback (most recent call last):
  File "", line 1, in 
badzip = ZipFile(bad)
  File "C:\Python34\lib\zipfile.py", line 937, in __init__
self._RealGetContents()
  File "C:\Python34\lib\zipfile.py", line 978, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

The zip-file is attached.

--
components: Library (Lib)
files: not_working.zip
messages: 246662
nosy: Yasar Luqman Ahmed
priority: normal
severity: normal
status: open
title: zipfile.BadZipFile: File is not a zip file
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file39915/not_working.zip

___
Python tracker 

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



[issue24622] tokenize.py: missing EXACT_TOKEN_TYPES

2015-07-12 Thread Stefan Krah

New submission from Stefan Krah:

ELLIPSIS and RARROW are missing in EXACT_TOKEN_TYPES. Patch attached.

--
files: tokenize.diff
keywords: patch
messages: 246663
nosy: meador.inge, skrah
priority: normal
severity: normal
status: open
title: tokenize.py: missing EXACT_TOKEN_TYPES
Added file: http://bugs.python.org/file39916/tokenize.diff

___
Python tracker 

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



[issue24621] zipfile.BadZipFile: File is not a zip file

2015-07-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Tim Peters

Tim Peters added the comment:

I have a question about this new snippet in choice():

+if i == n and n > 0:
+i = n - 1

What's the purpose of the "and n > 0" clause?  Without it, if i == n == 0 then 
i will be set to -1, which is just as good as 0 for the purpose of raising 
IndexError (seq[any_int] raises IndexError when seq is empty).

--

___
Python tracker 

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



[issue24623] Parser: broken line numbers for triple-quoted strings

2015-07-12 Thread Stefan Krah

New submission from Stefan Krah:

IMO the string should start at lineno=1, col_offset=0.


$ ./python 
Python 3.6.0a0 (default:02b81a82a57d, Jul 12 2015, 20:33:44) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> a = ast.parse('''"""xxx
... yyy
... zzz"""''')
>>> ast.dump(a, include_attributes=True)
"Module(body=[Expr(value=Str(s='xxx\\nyyy\\nzzz', lineno=3, col_offset=-1), 
lineno=3, col_offset=-1)])"

--
messages: 246665
nosy: skrah
priority: normal
severity: normal
status: open
title: Parser: broken line numbers for triple-quoted strings

___
Python tracker 

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



[issue24623] Parser: broken line numbers for triple-quoted strings

2015-07-12 Thread Stefan Krah

Changes by Stefan Krah :


--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue24620] Segfault with nonsensical random state

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Can't reproduce on 32-bit.

--
components: +Extension Modules
nosy: +serhiy.storchaka
stage:  -> needs patch
type:  -> crash

___
Python tracker 

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



[issue24620] Segfault with nonsensical random state

2015-07-12 Thread Stefan Krah

Stefan Krah added the comment:

I think it's just a matter of checking for self->index <= N in setstate().

--

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Tim Peters

Tim Peters added the comment:

Hmm.  Looks like the answer to my question came before, via "Custom collection 
can has non-standard behavior with negative indices."  Really?  We're worried 
about a custom collection that assigns some crazy-ass meaning to a negative 
index applied to an empty sequence?  Like what?  I don't really care about 
supporting insane sequences ;-)

--

___
Python tracker 

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



[issue24620] Segfault with nonsensical random state

2015-07-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

But I can reproduce the crash with other example.

import random
random.setstate((3, (1,)*624+(-10**9,), None))
random.random()

The index attribute can be set to negative value and this causes reading out of 
the buffer.

Here is a patch that fixes this.

--
keywords: +patch
stage: needs patch -> patch review
versions: +Python 2.7, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file39917/random_setstate_index.patch

___
Python tracker 

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



[issue23441] rlcompleter: tab on empty prefix => insert spaces

2015-07-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> My weak preference is with Martin’s simpler patch and relying on the
> Readline and the terminal to handle questions of tab stops and copied 
> text.

Fair enough. Still, it would be nice to add a test to test_rlcompleter. Does 
someone want to do this?

--

___
Python tracker 

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



[issue23239] SSL match_hostname does not accept IP Address

2015-07-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> ping

Sorry. I do not have time currently to tackle this issue. Feel free to submit 
and/or commit improvements if you feel like it.

--

___
Python tracker 

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



[issue24587] Tkinter stacking versus focus behavior on Windows

2015-07-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

This tracker is for patches to the CPython repository.  That includes tkinter, 
but does not include tk.

Ned, you know much more about OS variations in tk behavior than.  What do you 
think? (See initial post.)  What happens on Mac.  Should we ask Kevin W. about 
this?

--
nosy: +ned.deily

___
Python tracker 

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



[issue23220] Documents input/output effects of how IDLE runs user code

2015-07-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

OK. "Both are true for backspace ('\b') and return ('\r')."

--

___
Python tracker 

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



[issue24567] random.choice IndexError due to double-rounding

2015-07-12 Thread Tim Peters

Tim Peters added the comment:

[Serhiy Storchaka]
> ... I want to say that double rounding causes not
> only bias from ideal distribution, but a difference
> between platforms

That's so, but not too surprising.  On those platforms users will see 
differences between "primitive" floating addition and multiplication (etc) 
operations too.

There's a tradeoff here.  In Python's earliest days, the bias was strongly in 
favor of letting platform C quirks shine through.  Partly to make Python-C 
interoperability easiest, but at least as much because hiding cross-platform fp 
quirks is a major effort and even Guido had only finite time ;-)  As the years 
go by, the bias has been switching in favor of hiding platform quirks.  I hope 
Python 3 continues in that vein, but Python 2 probably needs to stay pretty 
much where it is.

--

___
Python tracker 

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



[issue24136] document PEP 448: unpacking generalization

2015-07-12 Thread Konstantin Molchanov

Konstantin Molchanov added the comment:

I've updated the Calls syntax reference in reference/expressions and the 
assignment object description in reference/simple_stmts.

Please tell me if I'm generally doing OK. If I'm not, please guide me to the 
right direction.

--
Added file: http://bugs.python.org/file39918/reference_calls_syntax_update.diff

___
Python tracker 

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



[issue24136] document PEP 448: unpacking generalization

2015-07-12 Thread Konstantin Molchanov

Changes by Konstantin Molchanov :


Added file: http://bugs.python.org/file39919/replace_sequence_with_iterable.diff

___
Python tracker 

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



[issue24624] Itertools documentation says iterator when iterable is intended

2015-07-12 Thread Neil Girdhar

New submission from Neil Girdhar:

In the description of the consume recipe:

def consume(iterator, n):
"Advance the iterator n-steps ahead. If n is none, consume entirely."
# Use functions that consume iterators at C speed.
if n is None:
# feed the entire iterator into a zero-length deque
collections.deque(iterator, maxlen=0)
else:
# advance to the empty slice starting at position n
next(islice(iterator, n, n), None)

iterator should be replaced with iterable.  This function accepts strings for 
example, which are not iterators.

--
assignee: docs@python
components: Documentation
messages: 246676
nosy: docs@python, neil.g
priority: normal
severity: normal
status: open
title: Itertools documentation says iterator when iterable is intended
type: enhancement
versions: Python 3.5

___
Python tracker 

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



[issue24553] improve test coverage for subinterpreters

2015-07-12 Thread Nick Coghlan

Nick Coghlan added the comment:

As a possible starting point for this, I'll point to 
https://hg.python.org/cpython/file/02b81a82a57d/Lib/test/__main__.py

Now, I'd expected running that in a process that was *already* running regrtest 
to fail miserably (it would stomp all over itself).

But what we could potentially do is launch a *clean* subprocess, where the only 
thing it did was:

from _testcapi import run_in_subinterp

regrtest_in_subinterpreter = (
"""
from test import regrtest
regrtest.main_in_temp_cwd()
"""
)
run_in_subinterp(regrtest_in_subinterpreter)

I'd currently expect that to fail as well, but I think the failures might be 
enlightening :)

I'm also not sure we need to integrate this directly into the main regrtest 
test runner - it could just be a separate submodule invoked like "python -m 
test.subinterpretertest".

If we later decided to integrate it, then it could go behind a 
"-usubinterpreter" resource that invoked "test.subinterpretertest" in a 
subprocess.

--

___
Python tracker 

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



[issue24624] Itertools documentation says iterator when iterable is intended

2015-07-12 Thread Steven D'Aprano

Steven D'Aprano added the comment:

On Mon, Jul 13, 2015 at 01:37:26AM +, Neil Girdhar wrote:
> 
> New submission from Neil Girdhar:
> 
> In the description of the consume recipe:
[...]
> iterator should be replaced with iterable.  This function accepts strings for 
> example, which are not iterators.

It *accepts* strings, but it doesn't consume them. It runs through the 
string, but the string still exists and you can iterate over it again 
and again and again.

The intent of the recipe is to consume an *iterator* not arbitrary 
iterables. I don't believe the recipe or its description needs to be 
changed.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue24625] py.exe executes #! in windows

2015-07-12 Thread 진모씨

New submission from 진모씨:

Well. A program linked to .py extension in windows (called py.exe) parses 
hashbang line(#!) and tries to execute program.

So hashbang like this:
#!/bin/env python
doesn't works, and
#!calc
executes calculator. I guess it is bug.

--
components: Windows
messages: 246679
nosy: paul.moore, steve.dower, tim.golden, zach.ware, 진모씨
priority: normal
severity: normal
status: open
title: py.exe executes #! in windows
versions: Python 2.7

___
Python tracker 

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



[issue24626] please sync cgi.parse document

2015-07-12 Thread hiroaki itoh

New submission from hiroaki itoh:

https://docs.python.org/2/library/cgi.html#cgi.parse
  (the file defaults to ``sys.stdin`` and environment
   defaults to ``os.environ``)
https://docs.python.org/3/library/cgi.html#cgi.parse
  (the file defaults to ``sys.stdin``)

maby this fix had applied only to python2 branch, so please update to py3 also.

--
assignee: docs@python
components: Documentation
messages: 246680
nosy: docs@python, xwhhsprings
priority: normal
severity: normal
status: open
title: please sync cgi.parse document
type: behavior
versions: Python 3.4

___
Python tracker 

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



[issue24624] Itertools documentation says iterator when iterable is intended

2015-07-12 Thread R. David Murray

Changes by R. David Murray :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue24625] py.exe executes #! in windows

2015-07-12 Thread R. David Murray

R. David Murray added the comment:

Py.exe does not work exactly like unix.  Unless you can point to documentation 
of py.exe that is wrong or does not cover this, this should be closed as not a 
bug.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue24627] Import bsddb result in error on OS X (Python 2.7.10)

2015-07-12 Thread Luke Jang

New submission from Luke Jang:

As title. I installed Python using brew.

$ python 
Python 2.7.10 (default, Jul  9 2015, 13:34:07) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bsddb
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python/2.7.10_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py",
 line 67, in 
import _bsddb
ImportError: No module named _bsddb
>>>

--
components: Library (Lib)
messages: 246682
nosy: Luke Jang
priority: normal
severity: normal
status: open
title: Import bsddb result in error on OS X (Python 2.7.10)
versions: Python 2.7

___
Python tracker 

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



[issue24620] Segfault with nonsensical random state

2015-07-12 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue24624] Itertools documentation says iterator when iterable is intended

2015-07-12 Thread Neil Girdhar

Neil Girdhar added the comment:

Ah, good point.

--

___
Python tracker 

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



[issue24627] Import bsddb result in error on OS X (Python 2.7.10)

2015-07-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Macintosh
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

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



[issue24625] py.exe executes #! in windows

2015-07-12 Thread eryksun

eryksun added the comment:

To support cross-platform shebangs, the launcher special-cases the following 
virtual commands [1]:

/usr/bin/env python
/usr/bin/python
/usr/local/bin/python
python

The "env" virtual command searches the PATH environment variable. Note that 
it's /usr/bin/env since that's the most common location for the env utility on 
POSIX systems. If /bin/env is used there should at least be a symlink to it in 
/usr/bin. 

[1]: https://docs.python.org/3/using/windows.html#shebang-lines

--
nosy: +eryksun
versions: +Python 3.4 -Python 2.7

___
Python tracker 

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



[issue24627] Import bsddb result in error on OS X (Python 2.7.10)

2015-07-12 Thread Ned Deily

Ned Deily added the comment:

You are using a third-party build of Python from the homebrew package manager. 
You probably need to install additional brew packages to provide bsddb support 
so you should ask somewhere else for help with that, perhaps stackoverflow.com.

--
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue24627] Import bsddb result in error on OS X (Python 2.7.10)

2015-07-12 Thread Tim Smith

Tim Smith added the comment:

Hi; I'm a Homebrew maintainer. Please open an issue at 
https://github.com/Homebrew/homebrew.

--
nosy: +tdsmith

___
Python tracker 

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