[issue27761] Private _nth_root function loses accuracy

2016-08-26 Thread Tim Peters

Tim Peters added the comment:

Serhiy, I don't know what you're thinking there, and the code doesn't make much 
sense to me.  For example, consider n=2.  Then m == n, so you accept the 
initial `g = x**(1.0/n)` guess.  But, as I said, there are cases where that 
doesn't give the best result, while the other algorithms do.  For example, on 
this box:

>>> serhiy(7.073208563506701e+46, 2)
2.6595504438733062e+23
>>> pow(7.073208563506701e+46, 0.5)  # exactly the same as your code
2.6595504438733062e+23

>>> nroot(7.073208563506701e+46, 2)  # best possible result
2.6595504438733066e+23
>>> import math
>>> math.sqrt(7.073208563506701e+46) # also achieved by sqrt()
2.6595504438733066e+23

On general principle, you can't expect to do better than plain pow() unless you 
do _something_ that gets the effect of using more than 53 mantissa bits - 
unless the platform pow() is truly horrible.  Using pow() multiple times is 
useless; doing Newton steps _in_ native float (C double) precision is useless; 
even some form of "binary search" is useless because just computing g**n (in 
native precision) suffers rounding errors worse than pow() suffered to begin 
with.

So long as you stick to native precision, you're fighting rounding errors at 
least as bad as the initial rounding errors you're trying to correct.  There's 
no a priori reason to even hope iterating will converge.

--

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What if use pow() with exactly represented degree in approximating step?

def rootn(x, n):
g = x**(1.0/n)
m = 1 << (n-1).bit_length()
if n != m:
g = (x*g**(m-n))**(1.0/m)
return g

Maybe it needs several iterations, because it converges slower than Newton 
approximation. But every step can be faster.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-08-26 Thread Martin Panter

Changes by Martin Panter :


Added file: https://bugs.python.org/file44237/Python3.6.ctypes.160823.patch

___
Python tracker 

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



[issue12319] [http.client] HTTPConnection.request not support "chunked" Transfer-Encoding to send data

2016-08-26 Thread Martin Panter

Martin Panter added the comment:

I committed my patch, so now file bodies are chunk-encoded by default. The 
Windows buildbots pass the relevant tests again.

This does mean that old code that uploaded a file to a HTTP-1.0-only server, 
and relied on Python automatically setting Content-Length, will no longer work 
in 3.6. Let me know if you think this is a serious problem, and maybe we can 
find another solution.

--
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



[issue19884] Importing readline produces erroneous output

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 55ec5fdc3099 by Martin Panter in branch '2.7':
Issue #19884: Avoid spurious output on OS X with Gnu Readline
https://hg.python.org/cpython/rev/55ec5fdc3099

New changeset 782d9b5d2e90 by Martin Panter in branch '3.5':
Issue #19884: Avoid spurious output on OS X with Gnu Readline
https://hg.python.org/cpython/rev/782d9b5d2e90

New changeset 72e034afeb55 by Martin Panter in branch 'default':
Issue #19884: Merge Readline updates from 3.5
https://hg.python.org/cpython/rev/72e034afeb55

--

___
Python tracker 

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



[issue25825] AIX shared library extension modules installation broken

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ca1ddd365f5f by Martin Panter in branch '3.5':
Issue #25825: Fix references to $(LIBPL) installation path on AIX
https://hg.python.org/cpython/rev/ca1ddd365f5f

New changeset 5a05c0eeefc3 by Martin Panter in branch 'default':
Issue #25825: Merge $(LIBPL) fix from 3.5
https://hg.python.org/cpython/rev/5a05c0eeefc3

--

___
Python tracker 

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



[issue27803] ctypes automatic byref failing on custom classes attributes

2016-08-26 Thread Eryk Sun

Eryk Sun added the comment:

Terry, the provided example is incomplete and doesn't make sense as it stands. 
For better or worse, windll.dllname attempts to load WinDLL(dllname) and cache 
the resulting library on the windll loader. (The library in turn caches 
function pointers, which means this design is a problem waiting to happen, 
which has happened a few times with various projects conflicting with each 
other over windll.kernel32 function prototypes. I recommend using WinDLL 
instead.)

I gather that Erwan wants ctypes.byref() and the implicit _byref that's called 
by PyCPointerType_from_param to be enhanced to support objects that define 
_as_parameter_. So I'm changing the issue type accordingly.

--
nosy: +eryksun
type: behavior -> enhancement

___
Python tracker 

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



[issue26027] Support Path objects in the posix module

2016-08-26 Thread Martin Panter

Martin Panter added the comment:

One more thing, ;) the Windows buildbots are failing to removing a temporary 
file:

http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/8173/steps/test/logs/stdio

==
ERROR: test_path_t_converter (test.test_os.PathTConverterTests)
--
Traceback (most recent call last):
  File 
"C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\support\__init__.py", 
line 365, in unlink
_unlink(filename)
  File 
"C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\support\__init__.py", 
line 336, in _unlink
_waitfor(os.unlink, filename)
  File 
"C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\support\__init__.py", 
line 304, in _waitfor
func(pathname)
PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process: '@test_5716_tmp'

Subsequently, other tests fail, probably because this file already exists.

--
status: closed -> open

___
Python tracker 

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



[issue27761] Private _nth_root function loses accuracy

2016-08-26 Thread Tim Peters

Tim Peters added the comment:

I don't care about correct rounding here, but it is, e.g., a bit embarrassing 
that

>>> 64**(1/3)
3.9996

Which you may or may not see on your box, depending on your platform pow(), but 
which you "should" see:  1/3 is not a third, it's a binary approximation that's 
a little less than 1/3, so 64 to that power should be less than 4.

There are two practical problems with `nroot`, both already noted:  (1) Its 
very cheap initial guess comes at the cost of requiring multiple iterations to 
get a guess good to 54 bits.  That can be repaired, and already showed how.  
(2) The larger `n`, the more bits it requires.  As Mark noted, at n=5 we're 
doing multi-million bit arithmetic.  That's inherent - and slow.

My simple fractions.Fraction function suffers the second problem too, but is 
even slower for large n.

But if you give up on guaranteed correct rounding, this is really quite easy:  
as I noted before, a single Newton iteration approximately doubles the number 
of "good bits", so _any_ way of getting the effect of extra precision in a 
single iteration will deliver a result good enough for all practical purposes.  
Note that an error bound of strictly less than 1 ulp is good enough to 
guarantee that the exact result is delivered whenever the exact result is 
representable.

Here's one way, exploiting that the decimal module has adjustable precision:

import decimal
def rootn(x, n):
c = decimal.getcontext()
oldprec = c.prec
try:
c.prec = 40
g = decimal.Decimal(x**(1.0/n))
g = ((n-1)*g + decimal.Decimal(x)/g**(n-1)) / n
return float(g)
finally:
c.prec = oldprec

Now memory use remains trivial regardless of n.  I haven't yet found a case 
where the result differs from the correctly-rounded `nroot()`, but didn't try 
very hard.  And, e.g., even at the relatively modest n=5000, it's over 500 
times faster than `nroot` (as modified to use a scaled x**(1/n) as an excellent 
starting guess, so that it too always gets out after its first Newton step).  
At n=5, it's over 15000 times faster.

For n less than about 70, though, `nroot` is faster.  It's plenty fast for me 
regardless.

Note:  just in case there's confusion about this, `rootn(64.0, 3)` returns 
exactly 4.0 _not_ necessarily because it's "more accurate" than pow() on this 
box, but because it sees the exact 3 instead of the approximation to 1/3 pow() 
sees.  That approximation is perfectly usable to get a starting guess 
(64**(1/3)) good to nearly 53 bits.  The real improvement comes from the Newton 
step using _exactly_ 3.

That said, I have seen rare cases where this (and `nroot`) give a better result 
than the platform pow() even for n=2 (where 1/n _is_ exactly representable).

--

___
Python tracker 

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



[issue27425] Tests fail because of git's newline preferences on Windows

2016-08-26 Thread Martin Panter

Martin Panter added the comment:

Emanuel: fix_newlines_2.patch seems to change the contents of batch from CRLF 
to LF newlines, undoing revision 640ccb924b5f. This seems like a step in the 
wrong direction. Notice $ means LF, and ^M$ means CRLF:

$ curl https://bugs.python.org/file44225/fix_newlines_2.patch | cat -A
. . .
diff --git a/Tools/unicode/genwincodecs.bat b/Tools/unicode/genwincodecs.bat$
. . .
-c:\python30\python genwincodec.py 720 > build/cp720.py^M$
. . .
+c:\python30\python genwincodec.py 720 > build/cp720.py$

However, the test_sax change may be sensible.

test_random_warning_1.patch looks okay.

--
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



[issue12319] [http.client] HTTPConnection.request not support "chunked" Transfer-Encoding to send data

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 216f5451c35a by Martin Panter in branch 'default':
Issue #12319: Always send file request bodies using chunked encoding
https://hg.python.org/cpython/rev/216f5451c35a

--

___
Python tracker 

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



[issue27871] ctypes docs must be more explicit about the type a func returns

2016-08-26 Thread Eryk Sun

Eryk Sun added the comment:

See section 2.7 in the ctypes docs: 

Fundamental data types, when returned as foreign function call
results, or, for example, by retrieving structure field members
or array items, are transparently converted to native Python
types. In other words, if a foreign function has a restype of
c_char_p, you will always receive a Python bytes object, not a
c_char_p instance.

Subclasses of fundamental data types do not inherit this
behavior. So, if a foreign functions restype is a subclass of
c_void_p, you will receive an instance of this subclass from the
function call. Of course, you can get the value of the pointer
by accessing the value attribute.

For example:

class my_char_p(ctypes.c_char_p):
pass

>>> locale = ctypes.create_string_buffer(b'en_US.UTF-8')
>>> setlocale.restype = ctypes.c_char_p
>>> result = setlocale(0, locale)
>>> result
b'en_US.UTF-8'

>>> setlocale.restype = my_char_p
>>> result = setlocale(0, locale)
>>> result
my_char_p(31391216)
>>> result.value
b'en_US.UTF-8'

> when he/she passes that value into the next library function

A function that takes pointer arguments really should have argtypes defined so 
that there's no chance of accidentally getting the default integer conversion 
to a C int.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
versions:  -Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue26027] Support Path objects in the posix module

2016-08-26 Thread Brett Cannon

Brett Cannon added the comment:

Thanks for catching that, Martin. I removed the test for bytearray as it was 
originally written before the deprecation.

--
status: open -> closed

___
Python tracker 

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



[issue26027] Support Path objects in the posix module

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 32b93ba32aa0 by Brett Cannon in branch 'default':
Issue #26027: Don't test for bytearray in path_t as that's now
https://hg.python.org/cpython/rev/32b93ba32aa0

--

___
Python tracker 

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



[issue26638] Avoid warnings about missing CLI options when building documentation

2016-08-26 Thread Martin Panter

Martin Panter added the comment:

Terry: the four "ini" syntax highlighting warnings were also mentioned in 
. In that bug, we fixed many 
other similar warnings, but I think we left those as being less easy to fix.

One thing (other than suppress_warnings = ['ref.option']) that might help you 
see warnings relevant to your change is if you first build the docs without 
your change, ignore all those warnings, and then rebuild with your change. The 
second build may produce less irrelevant warnings.

--

___
Python tracker 

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



[issue12178] csv writer doesn't escape escapechar

2016-08-26 Thread Wayne Harris

Wayne Harris added the comment:

Hi, 

I can confirm that this behavior still exists in my current python versions 
(3.5.2 & 2.7.11). I'm happy to take a look at the code, but considering I made 
this account specifically to comment on this issue I assume someone else will 
want to, as well.

If you want to make sure this is still broken, just use any of the docs' reader 
and writer examples, adding a trailing escape char to the end.

--
nosy: +Apathymannequin

___
Python tracker 

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



[issue26027] Support Path objects in the posix module

2016-08-26 Thread Martin Panter

Martin Panter added the comment:

This change causes test_os to produce warnings, and can fail:

$ hg update b64f83d6ff24
$ ./python -bWerror -m test -u all -W test_os
[. . .]
==
ERROR: test_path_t_converter (test.test_os.PathTConverterTests) (name='stat', 
path=bytearray(b'@test_12055_tmp'))
--
Traceback (most recent call last):
  File "/media/disk/home/proj/python/cpython/Lib/test/test_os.py", line 2865, 
in test_path_t_converter
result = fn(path, *extra_args)
DeprecationWarning: stat: path should be string, bytes, os.PathLike or integer, 
not bytearray

Similar warnings:
DeprecationWarning: lstat: path should be string, bytes or os.PathLike, not 
bytearray
DeprecationWarning: access: path should be string, bytes, os.PathLike or 
integer, not bytearray
DeprecationWarning: open: path should be string, bytes or os.PathLike, not 
bytearray

--
nosy: +martin.panter
status: closed -> open

___
Python tracker 

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



[issue27830] Add _PyObject_FastCallKeywords(): avoid the creation of a temporary dictionary for keyword arguments

2016-08-26 Thread Martin Panter

Martin Panter added the comment:

FYI revision ffcfa4f005a3 removed the code that uses your new _PyStack_AsDict() 
function, so now there is a compiler warning:

Objects/abstract.c:2313:1: warning: ‘_PyStack_AsDict’ defined but not used 
[-Wunused-function]
 _PyStack_AsDict(PyObject **stack, Py_ssize_t nkwargs, PyObject *func)
 ^~~

--
nosy: +martin.panter

___
Python tracker 

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



[issue27873] multiprocessing.pool.Pool.map should take more than one iterable

2016-08-26 Thread Tim Peters

Tim Peters added the comment:

Note that `Pool` grew `starmap()` and `starmap_async()` methods in Python 3.3 
to (mostly) address this.

The signature difference from the old builtin `map()` remains regrettable.  
Note that the `Pool` version differs from the `concurrent.futures` version of 
`map()` in this respect too.

--
nosy: +tim.peters

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy: +skrah

___
Python tracker 

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



[issue27873] multiprocessing.pool.Pool.map should take more than one iterable

2016-08-26 Thread Raymond Hettinger

Raymond Hettinger added the comment:

-0 We need better motivation than "that is was map() does".  Instead, are 
should look at whether there are compelling use cases and its impact on the 
complexity of the multiprocessing implementation.  I usually just prezip my 
data and it works fine.

--
assignee:  -> davin
nosy: +davin, rhettinger

___
Python tracker 

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



[issue27873] multiprocessing.pool.Pool.map should take more than one iterable

2016-08-26 Thread Jason Yu

New submission from Jason Yu:

Hello all, 

The official doc describes `Pool.map(func, iterable[, chunksize])` as "A 
parallel equivalent of the map() built-in function.". 

Since the function signature of `map` is `map(function, iterable, ...)`, I 
hereby suggest that `Pool.map` should change its function signature to 
`Pool.map(function, iterable, ... [, chunksize])`. This will bring true 
equivalent to these functions. 

Tell me what you think. 

Pool.map: 
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.map
 

map: https://docs.python.org/3/library/functions.html#map 

Jason

--
components: Interpreter Core
messages: 273741
nosy: Jason Yu
priority: normal
severity: normal
status: open
title: multiprocessing.pool.Pool.map should take more than one iterable
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue27805] io.open('/dev/stdout', 'a') raises OSError with errno=ESPIPE

2016-08-26 Thread Martin Panter

Changes by Martin Panter :


--
title: os.open('/dev/stdout', 'a') raises OSError with errno=ESPIPE -> 
io.open('/dev/stdout', 'a') raises OSError with errno=ESPIPE

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray

R. David Murray added the comment:

Oh, my apologies.  I was not reading your message with enough attention, you 
are only talking about the zero case.  A check for zero would not be crazy, and 
I think there are enough operations involved in left shift that the performance 
impact would not be measurable.  I'll leave that to the math experts, though.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue27872] Update os/os.path docs to mention path-like object support

2016-08-26 Thread Brett Cannon

Changes by Brett Cannon :


--
keywords: +easy

___
Python tracker 

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



[issue27872] Update os/os.path docs to mention path-like object support

2016-08-26 Thread Brett Cannon

Changes by Brett Cannon :


--
priority: normal -> deferred blocker

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce

Alex Groce added the comment:

I mean a Python long.  GMP mpz (via gmpy2) is supposed to be "drop-in" 
replacement, but it's choice to handle 0 << N even if N is too large to 
allocate (since you get back a 1-bit number, 0) seems reasonable, if not 
required for correct behavior.  If this is by design, it seems reasonable (if 
the zero check is considered too expensive, for example).

--

___
Python tracker 

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



[issue27872] Update os/os.path docs to mention path-like object support

2016-08-26 Thread Brett Cannon

New submission from Brett Cannon:

Now that PEP 519 support has been added to the os and os.path modules, the 
documentation needs to be appropriately updated to mention which functions 
support a "path-like object" (and in some cases a path-like object or an int 
for file descriptors).

--
assignee: brett.cannon
components: Documentation
messages: 273738
nosy: brett.cannon
priority: normal
severity: normal
stage: needs patch
status: open
title: Update os/os.path docs to mention path-like object support
versions: Python 3.6

___
Python tracker 

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



[issue27182] PEP 519 support in the stdlib

2016-08-26 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee: brett.cannon -> 

___
Python tracker 

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



[issue27182] PEP 519 support in the stdlib

2016-08-26 Thread Brett Cannon

Brett Cannon added the comment:

The os and os.path modules are now done! The means PEP 519 is finished. At this 
point individual modules will need to be checked to see if they do (not) 
support os.PathLike.

--

___
Python tracker 

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



[issue27283] Add a "What's New" entry for PEP 519

2016-08-26 Thread Brett Cannon

Brett Cannon added the comment:

Applied in https://hg.python.org/cpython/rev/95361959d451

--
resolution:  -> fixed
stage: commit 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



[issue27524] Update os.path for PEP 519/__fspath__()

2016-08-26 Thread Brett Cannon

Changes by Brett Cannon :


--
resolution:  -> fixed
stage: needs patch -> 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



[issue26027] Support Path objects in the posix module

2016-08-26 Thread Brett Cannon

Brett Cannon added the comment:

Thanks to Jelle for the initial commit and Serhiy for the code review!

--
resolution:  -> fixed
stage: commit 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



[issue27524] Update os.path for PEP 519/__fspath__()

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b64f83d6ff24 by Brett Cannon in branch 'default':
Issue #26027, #27524: Add PEP 519/__fspath__() support to os and
https://hg.python.org/cpython/rev/b64f83d6ff24

--
nosy: +ned.deily, python-dev

___
Python tracker 

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



[issue26027] Support Path objects in the posix module

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b64f83d6ff24 by Brett Cannon in branch 'default':
Issue #26027, #27524: Add PEP 519/__fspath__() support to os and
https://hg.python.org/cpython/rev/b64f83d6ff24

--
nosy: +python-dev

___
Python tracker 

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



[issue27871] ctypes docs must be more explicit about the type a func returns

2016-08-26 Thread Christian Kothe

New submission from Christian Kothe:

The ctypes documentation leaves an important detail very implicit, which can 
cause non-deterministic hard crashes when overlooked. The issue is that when 
you explicitly set the .restype of a function to c_void_p, the function returns 
not a c_void_p (like a newcomer might assume) but an int -- and when he/she 
passes that value into the next library function (which should have gotten a 
c_void_p), then they'll get a hard crash if that memory location lies outside 
the 32-bit range.

I take it that the implicit assumption in ctypes is that the data types that 
you get back from the library calls are native python types where applicable 
for convenience, and the restype (just like argtypes) only configures the 
marshaling layer. However, that's not very explicitly stated anywhere (except 
maybe between the lines).

--
components: ctypes
messages: 273732
nosy: Christian Kothe
priority: normal
severity: normal
status: open
title: ctypes docs must be more explicit about the type a func returns
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray

R. David Murray added the comment:

Wait, when you talk about 'long', are you using that in the C sense?  Because 
python long integers are size-limited only by the amount of memory.

--

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray

R. David Murray added the comment:

If it raises a MemoryError, then it is working as designed.  Returning 0 would 
be the wrong answer, so I don't understand why GMP would do that.

--

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce

Alex Groce added the comment:

Allocates, then fails to perform the operation (with MemoryError).  Neither a 
crash nor resource allocation, precisely, just fails to carry out operation GMP 
integers can do under the same circumstances.

--

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread R. David Murray

R. David Murray added the comment:

Are you saying that Python aborts, or that it raises a MemoryError?

--
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



[issue27850] Remove 3DES from cipher list (sweet32 CVE-2016-2183)

2016-08-26 Thread Jim Jewett

Jim Jewett added the comment:

I think a python call is fine to require ... if they don't have the python
source they should have a support contract. I assume the advice followed is
intermediate, based on the earlier comment about xp and ie?

On Aug 26, 2016 9:46 AM, "Christian Heimes"  wrote:

>
> Christian Heimes added the comment:
>
> Patch for 3DES and ChaCha20 (#27766).
>
> For ChaCha the patch does not check CPU cap vector and just follows the
> advice from https://wiki.mozilla.org/Security/Server_Side_TLS#
> Modern_compatibility
>
> --
> keywords: +patch
> Added file: https://bugs.python.org/file44233/Remove-3DES-from-
> and-add-ChaCha20-Poly1305-to-cipher.patch
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce

Alex Groce added the comment:

AND, right shift >> does not allocate memory, so there is a lack of symmetry 
that indicates the optimization might be desired.

see 

https://github.com/agroce/tstl/tree/master/examples/gmpy2/leftshiftalloc.py
vs.
https://github.com/agroce/tstl/tree/master/examples/gmpy2/rightshiftalloc.py

to compare behaviors, but these are depending on memory size, this was 
generated on MacBook Pro OS X Yosemite machine with 16GB)

--

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce

Alex Groce added the comment:

(to clarify:

0 << N

allocates memory (which can fail, raising MemoryError) based on N.  GMP simply 
returns 0 for any N.

--

___
Python tracker 

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



[issue21541] Provide configure option --with-ssl for compilation with custom openssl

2016-08-26 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag

___
Python tracker 

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



[issue20562] sqlite3 returns result set with doubled first entry

2016-08-26 Thread Berker Peksag

Berker Peksag added the comment:

This is basically a duplicate of issue 10513.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> sqlite3.InterfaceError after commit

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Alex Gaynor

Alex Gaynor added the comment:

- The 2.7 patch contains numerous references to 3.6, these should be rewritten 
to 2.7.x
-

--

___
Python tracker 

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



[issue8145] Documentation about sqlite3 isolation_level

2016-08-26 Thread Berker Peksag

Berker Peksag added the comment:

sqlite_transaction_doc.patch looks good to me and applies cleanly to current 
default branch. One minor note: It would be nice to document that the default 
mode is "BEGIN DEFERRED" in Connection.isolation_level documentation.

--
nosy: +berker.peksag
stage: patch review -> commit review
versions: +Python 3.5, Python 3.6 -Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue27867] various issues due to misuse of PySlice_GetIndicesEx

2016-08-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I presume you are suggesting to raise if the length changes.  This is similar 
to raising when a dict is mutated while iterating.  Note that we do not do this 
with mutable sequences.  (If the iteration is stopped with out-of-memory error, 
so be it.)

An alternate approach would be to first fully evaluate start, stop, step , *and 
then length*, to ints, in that order, before using any of them.  In particular, 
have everything stable before comparing and adjusting start and stop to length. 
 This way, slices would continue to always work, barring other exceptions in 
__index__ or __length__.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue10513] sqlite3.InterfaceError after commit

2016-08-26 Thread Berker Peksag

Berker Peksag added the comment:

This is now fixed in 2.7 and 3.5+. Thank you all for your patience!

--
nosy: +berker.peksag
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



[issue23129] sqlite3 COMMIT nested in SELECT returns unexpected results

2016-08-26 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report! This is a duplicate of issue 10513. I've pushed a patch 
to fix this for 2.7 and 3.5+ in 030e100f048a and 81f614dd8136.

--
components: +Extension Modules
nosy: +berker.peksag
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> sqlite3.InterfaceError after commit
versions: +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



[issue10513] sqlite3.InterfaceError after commit

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 030e100f048a by Berker Peksag in branch '2.7':
Issue #10513: Fix a regression in Connection.commit()
https://hg.python.org/cpython/rev/030e100f048a

--

___
Python tracker 

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



[issue27870] Left shift of zero allocates memory

2016-08-26 Thread Alex Groce

New submission from Alex Groce:

Using a random testing system to compare Python long behavior to GMP (via 
gmpy2), I notice that in a low-memory situation (created by allocating many 
large integers in both Python and GMP), a left-shift of 0 by large number of 
bytes:

- returns 0 via gmpy2
- causes a memory error in Python, e.g.:

...
val4 = val3 << val4
val3: 0 (GMP) 0 (Python)
val4: 1459166279268040830 (GMP) 1459166279268040830 (Python)
[operation successful via GMP]
Python(4463,0x7fff7152c300) malloc: *** mach_vm_map(size=19403902408704) 
failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug


Auto-generated test is attached, though probably not needed to understand the 
issue.  File is not minimized, since I suspect most of the code is just to 
choke memory, and you probably need the right memory config to replay, but it 
shows the basic idea.

For more info, see https://github.com/agroce/tstl/tree/master/examples/gmpy2

--
files: leftshiftalloc.py
messages: 273717
nosy: Alex Groce
priority: normal
severity: normal
status: open
title: Left shift of zero allocates memory
type: resource usage
versions: Python 2.7
Added file: https://bugs.python.org/file44236/leftshiftalloc.py

___
Python tracker 

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



[issue10513] sqlite3.InterfaceError after commit

2016-08-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 81f614dd8136 by Berker Peksag in branch '3.5':
Issue #10513: Fix a regression in Connection.commit()
https://hg.python.org/cpython/rev/81f614dd8136

New changeset 685f32972c11 by Berker Peksag in branch 'default':
Issue #10513: Merge from 3.5
https://hg.python.org/cpython/rev/685f32972c11

--
nosy: +python-dev

___
Python tracker 

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



[issue27855] 2to3: Wrong code output w/ has_key without trailing space

2016-08-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

If you don't want to sign the CA, https://www.python.org/psf/contrib/, and 
upload a file without a guarantee, which is never given ;-), just give the 
patch in a text message.  While it may be unreasonable to *expect* 2to3 to 
handle this, it also might not be unreasonable for it to do so.  It would be 
especially useful if one were converting to Py3 and not planning to maintain 
the 2.x code.

My concern is that this might be one of multiple similar situations, so that 
patching just one might not be all that helpful.  But I have not looked at the 
list of fixers to determine is other are affected.

--
nosy: +benjamin.peterson, terry.reedy
versions: +Python 3.5, Python 3.6 -Python 3.4

___
Python tracker 

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



[issue27869] test failures on Bash on Windows

2016-08-26 Thread Brett Cannon

Changes by Brett Cannon :


--
title: test failures on Bash for Windows -> test failures on Bash on Windows

___
Python tracker 

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



[issue27869] test failures on Bash for Windows

2016-08-26 Thread Brett Cannon

New submission from Brett Cannon:

test_logging and test_socket seem to hang, and then there are 35 failures:

test_asyncio test_asyncore test_dbm_dumb test_dbm_gnu test_eintr
test_epoll test_faulthandler test_fcntl test_ftplib test_gettext
test_httpservers test_import test_largefile test_mailbox test_mmap
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_main_handling test_multiprocessing_spawn
test_netrc test_os test_pathlib test_pep277 test_posix
test_resource test_shutil test_signal test_socketserver test_stat
test_subprocess test_tarfile test_time test_unicode_file
test_wsgiref test_zipfile

--
components: Library (Lib), Windows
messages: 273714
nosy: brett.cannon, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: test failures on Bash for Windows
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue27051] Create PIP gui

2016-08-26 Thread R. David Murray

R. David Murray added the comment:

Something like gksudo would be what you would use to use this application to do 
a GUI install, but what specific program you use to get root for running a gui 
application does depend on the distribution. (For example, I'd use 'sux' to 
become root and then run it, on my system.)  But in general no one should be 
running GUI PIP as root: for root installs you should be using the distribution 
package manager.

That said, the standard way of "elevating privileges" in unix and mac is to use 
sudo.  You'd just add 'sudo' to the front of the pip command string when you 
call POpen.  But I'm not sure this is a feature that should be supported, since 
in interferes with system package management

--
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



[issue27805] os.open('/dev/stdout', 'a') raises OSError with errno=ESPIPE

2016-08-26 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
stage:  -> test needed
title: In Python 3, open('/dev/stdout', 'a') raises OSError with errno=ESPIPE 
-> os.open('/dev/stdout', 'a') raises OSError with errno=ESPIPE
type:  -> behavior

___
Python tracker 

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



[issue27867] various issues due to misuse of PySlice_GetIndicesEx

2016-08-26 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +mark.dickinson, 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



[issue27868] Unconditionally state when a build succeeds

2016-08-26 Thread Brett Cannon

New submission from Brett Cannon:

When setup.py succeeds at building but couldn't build some dependency it says 
"Python build finished successfully!" and then lists the modules that couldn't 
be built. But if you are able to actually build everything then nothing is 
printed to stdout. Due to the fact that getting everything to build takes so 
much effort, when I finally reached the nirvana that is all modules built I 
thought my build had actually failed thanks to nothing being printed to stdout.

It might be worth always printing out that the build succeeded no matter 
whether a extension module had issues being built or not.

--
assignee: brett.cannon
messages: 273712
nosy: brett.cannon
priority: normal
severity: normal
stage: needs patch
status: open
title: Unconditionally state when a build succeeds
versions: Python 3.6

___
Python tracker 

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



[issue27803] ctypes automatic byref failing on custom classes attributes

2016-08-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I ran the the following, which I don't understand, and therefore don't what 
should happen, on Win 10, 3.6.0a3.

from ctypes import *
from ctypes.wintypes import *

class CustomPHKEY(object):
def __init__(self, value):
self._as_parameter_ = HKEY(value)

function = windll.function
function.argtypes = [POINTER(HKEY)]
function.restype = LONG
result = CustomPHKEY(0)
function(result)

Traceback (most recent call last):
  File "F:\Python\mypy\tem.py", line 8, in 
function = windll.function
  File "C:\Programs\Python36\lib\ctypes\__init__.py", line 417, in __getattr__
dll = self._dlltype(name)
  File "C:\Programs\Python36\lib\ctypes\__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

--
nosy: +terry.reedy

___
Python tracker 

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



[issue27051] Create PIP gui

2016-08-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I don't know anything about user permissions on *nix.  There are people on 
python-list who should.

--

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-26 Thread Steve Holden

Steve Holden added the comment:

OK, here's what I think should be close to the final patch. I've updated the 
documentation, rebuilt it and verified it reads OK, and confirmed that the new 
code passes all tests except those skipped for platform reasons (I think they 
expect a Windows environment). This includes the new test to confirm that 
ordering is retained over all 120 possible combinations of five keys.

Please let me know if any further updates are needed.

--
Added file: https://bugs.python.org/file44235/csv_full.patch

___
Python tracker 

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



[issue27867] various issues due to misuse of PySlice_GetIndicesEx

2016-08-26 Thread tehybel

New submission from tehybel:

Here I will describe 6 issues with various core objects (bytearray, list) and
the array module.

Common to them all is that they arise due to a misuse of the function
PySlice_GetIndicesEx. 

This type of issue results in out-of-bounds array indexing which leads to memory
disclosure, use-after-frees or memory corruption, depending on the
circumstances.

For each issue I've attached a proof-of-concept script which either prints
leaked heap memory or segfaults on my machine (64-bit linux, --with-pydebug,
python 3.5.2).



Issue 1: out-of-bounds indexing when taking a bytearray's subscript

While taking the subscript of a bytearray, the function bytearray_subscript in
/Objects/bytearrayobject.c calls PySlice_GetIndicesEx to validate the given
indices. 

Some of these indices might be objects with an __index__ method, and thus
PySlice_GetIndicesEx could call back into python code.

If the evaluation of the indices modifies the bytearray, the indices might no
longer be safe, despite PySlice_GetIndicesEx saying so. 

Here is a PoC which lets us read out 64 bytes of uninitialized memory from the
heap:

---

class X:
def __index__(self):
b[:] = []
return 1

b = bytearray(b"A"*0x1000)
print(b[0:64:X()])

---

Here's the result on my system:

$ ./python poc17.py
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xce\x86\x9ff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')



Issue 2: memory corruption in bytearray_ass_subscript

This issue is similar to the one above. The problem exists when assigning to a
bytearray via subscripting. The relevant function is bytearray_ass_subscript.
The relevant line is again the one calling PySlice_GetIndicesEx.

Here's a PoC which leads to memory corruption of the heap:

---

class X:
def __index__(self):
del b[0:0x1]
return 1

b = bytearray(b"A"*0x1)
b[0:0x8000:X()] = bytearray(b"B"*0x8000)

---

Here's the result of running it:

(gdb) r poc20.py 
Program received signal SIGSEGV, Segmentation fault.
PyCFunction_NewEx (ml=0x8b4140 , 
self=self@entry=0x77f0e898, 
module=module@entry=0x0) at Objects/methodobject.c:31
31  free_list = (PyCFunctionObject *)(op->m_self);
(gdb) p op
$13 = (PyCFunctionObject *) 0x4242424242424242





Issue 3: use-after-free when taking the subscript of a list

This issue is similar to the one above, but it occurs when taking the subscript
of a list rather than a bytearray. The relevant code is in list_subscript which
exists in /Objects/listobject.c. Here's a PoC:

---

class X:
def __index__(self):
b[:] = [1, 2, 3]
return 2

b = [123]*0x1000
print(b[0:64:X()])

---

It results in a segfault here because of a use-after-free:

(gdb) run ./poc18.py 
Program received signal SIGSEGV, Segmentation fault.
0x00483553 in list_subscript (self=0x76d53988, item=) at Objects/listobject.c:2441
2441Py_INCREF(it);
(gdb) p it
$2 = (PyObject *) 0xfbfbfbfbfbfbfbfb




Issue 4: use-after-free when assigning to a list via subscripting

The same type of issue exists in list_ass_subscript where we assign to the list
using a subscript. Here's a PoC which also results in a use-after-free:

---

class X:
def __index__(self):
b[:] = [1, 2, 3]
return 2

b = [123]*0x1000
b[0:64:X()] = [0]*32

---

(gdb) r poc19.py 
Program received signal SIGSEGV, Segmentation fault.
0x00483393 in list_ass_subscript (self=, item=, 
value=) at Objects/listobject.c:2603
2603Py_DECREF(garbage[i]);
(gdb) p garbage[i]
$4 = (PyObject *) 0xfbfbfbfbfbfbfbfb




Issue 5: out-of-bounds indexing in array_subscr

Same type of issue. The problem is in the function array_subscr in
/Modules/arraymodule.c. 

Here's a PoC which leaks and prints uninitialized memory from the heap:

---

import array

class X:
def __index__(self):
del a[:]
a.append(2)
return 1

a = array.array("b")
for _ in range(0x10):
a.append(1)

print(a[0:0x10:X()])

---

And the result:

$ ./python poc22.py
array('b', [2, -53, -53, -53, -5, -5, -5, -5, -5, -5, -5, -5, 0, 0, 0, 0])





Issue 6: out-of-bounds indexing in array_ass_subscr

Same type of issue, also in the array module. Here's a PoC which segfaults here:

---

import array

class X:
def __index__(self):
del a[:]
return 1

a = array.array("b")
a.frombytes(b"A"*0x100)
del a[::X()]

---





How should these be fixed? 

I would suggest that in each instance we could add a check after calling
PySlice_GetIndicesEx. The check should validate that the "length" argument
passed to PySlice_GetIndicesEx did not change during the call.  But maybe there
is a better way?

(By the way: these issues might also exist in 2.7, I did not check.)

--

[issue27861] sqlite3 type confusion and multiple frees

2016-08-26 Thread Xiang Zhang

Xiang Zhang added the comment:

issue27861_conn_isolation_level.patch now adds argument type and value check 
along with eliminating the potential sf.

--
Added file: 
https://bugs.python.org/file44234/issue27861_conn_isolation_level.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

There are still quite a few references to `PROTOCOL_SSLv23` in 
Doc/library/ssl.rst. Should they be updated as well?

--

___
Python tracker 

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



[issue27850] Remove 3DES from cipher list (sweet32 CVE-2016-2183)

2016-08-26 Thread Christian Heimes

Christian Heimes added the comment:

Patch for 3DES and ChaCha20 (#27766).

For ChaCha the patch does not check CPU cap vector and just follows the advice 
from https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility

--
keywords: +patch
Added file: 
https://bugs.python.org/file44233/Remove-3DES-from-and-add-ChaCha20-Poly1305-to-cipher.patch

___
Python tracker 

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



[issue27840] functools.partial: don't copy keywoard arguments in partial_call()?

2016-08-26 Thread Ned Deily

Changes by Ned Deily :


--
resolution:  -> rejected
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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Added file: 
https://bugs.python.org/file44232/Port-Python-s-SSL-module-to-OpenSSL-1.1.0-3.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: 
https://bugs.python.org/file44038/Port-Python-s-SSL-module-to-OpenSSL-1.1.0.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: 
https://bugs.python.org/file44230/Port-Python-2.7-s-SSL-module-to-OpenSSL-1.1.0-3.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: 
https://bugs.python.org/file44048/Port-Python-s-SSL-module-to-OpenSSL-1.1.0-2.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: 
https://bugs.python.org/file44037/Port-Python-2.7-s-SSL-module-to-OpenSSL-1.1.0.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: 
https://bugs.python.org/file44229/Port-Python-2.7-s-SSL-module-to-OpenSSL-1.1.0-3.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Added file: 
https://bugs.python.org/file44230/Port-Python-2.7-s-SSL-module-to-OpenSSL-1.1.0-3.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Added file: 
https://bugs.python.org/file44231/Port-Python-2.7-s-SSL-module-to-OpenSSL-1.1.0-3.patch

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-08-26 Thread Christian Heimes

Changes by Christian Heimes :


Added file: 
https://bugs.python.org/file44229/Port-Python-2.7-s-SSL-module-to-OpenSSL-1.1.0-3.patch

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-26 Thread Xiang Zhang

Xiang Zhang added the comment:

issue27861_conn_cursor.patch tries to solve the first issue.

--
Added file: https://bugs.python.org/file44228/issue27861_conn_cursor.patch

___
Python tracker 

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



[issue27866] ssl: get list of enabled ciphers

2016-08-26 Thread Christian Heimes

New submission from Christian Heimes:

SSLContext has a set_ciphers() method but no method to get the actual list of 
enabled ciphers. https://github.com/tiran/cpython/tree/feature/openssl_ciphers 
implements get_ciphers()

>>> import ssl, pprint
>>> ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
>>> ctx.set_ciphers('ECDHE+AESGCM:!ECDSA')
>>> pprint.pprint(ctx.get_ciphers())
[{'alg_bits': 256,
  'description': 'ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA  '
 'Enc=AESGCM(256) Mac=AEAD',
  'id': 50380848,
  'name': 'ECDHE-RSA-AES256-GCM-SHA384',
  'protocol': 'TLSv1/SSLv3',
  'strength_bits': 256},
 {'alg_bits': 128,
  'description': 'ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH Au=RSA  '
 'Enc=AESGCM(128) Mac=AEAD',
  'id': 50380847,
  'name': 'ECDHE-RSA-AES128-GCM-SHA256',
  'protocol': 'TLSv1/SSLv3',
  'strength_bits': 128}]

With OpenSSL 1.1 the dict will have more fields.

Both the return value and functionality is different to 
https://docs.python.org/3/library/ssl.html#ssl.SSLSocket.shared_ciphers .

--
components: Library (Lib)
messages: 273703
nosy: alex, christian.heimes, dstufft, giampaolo.rodola, janssen
priority: normal
severity: normal
status: open
title: ssl: get list of enabled ciphers
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue27768] ssl: get CPU cap flags for AESNI and PCLMULQDQ

2016-08-26 Thread Christian Heimes

Christian Heimes added the comment:

GPS, I no longer want a general API for CPU cap vector. The ssl module and 3rd 
party packages are only interested in two properties of the current hardware: 
are AESNI and PCLMULQDQ instructions available and enabled.

I'm pretty sure ctypes won't work on Windows and OSX. The OpenSSL libraries are 
statically linked into the _ssl binary. The linker optimizer removes all 
functions that are not used. Somebody could give it a try, though.

--
title: ssl: add public API for IA-32 processor capabilities vector -> ssl: get 
CPU cap flags for AESNI and PCLMULQDQ

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-26 Thread Xiang Zhang

Xiang Zhang added the comment:

I considered that but don't why decide to preserve it. But now that you mention 
it, I'll do that later.

--

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-26 Thread Berker Peksag

Berker Peksag added the comment:

Please split issue27861.patch into two patches.

It would be better if isolation_level wouldn't accept values other than None, 
"" (empty string), "deferred", "immediate", "exclusive".

--
stage: needs patch -> patch review

___
Python tracker 

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



[issue27051] Create PIP gui

2016-08-26 Thread Upendra Kumar

Upendra Kumar added the comment:

Can I somehow change the setup.py script such that I can create a new set of 
(group, user) with specific privileges only needed for installation and 
uninstallation.

Once a new set of (group, user) is created, I can always do 

os.setgid(gid) and os.setuid(uid)

But, I can't figure out how to change setup.py to create a new set of 
permissions during installation. It should be possible because at time of 
installation setup.py runs with sudo privileges.

--

___
Python tracker 

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



[issue27051] Create PIP gui

2016-08-26 Thread Upendra Kumar

Upendra Kumar added the comment:

I facing problems in running the GUI application with root or elevated 
privileges. I earlier used gksudo for linux. It turns out be a not very general 
solution as all linux distros don't have gksudo.

Therefore, how to manage user permissions or group permissions. I want my 
program to run temporarirly with elevated permissions in order to install, 
update or uninstall python packages.

I am using subprocess. Is it possible to run subprocess with elevated 
privileges and again reset the permissions when the shell process ends?

--

___
Python tracker 

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



[issue27840] functools.partial: don't copy keywoard arguments in partial_call()?

2016-08-26 Thread STINNER Victor

STINNER Victor added the comment:

Ah yes sorry, I misunderstood the link between kwargs from a C function and
a PY function. The link is simple, it's the same object :-) This issue can
be closed.

--

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2016-08-26 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +xiang.zhang

___
Python tracker 

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



[issue27861] sqlite3 type confusion and multiple frees

2016-08-26 Thread Xiang Zhang

Xiang Zhang added the comment:

For the first issue, the doc says:

The cursor method accepts a single optional parameter cursorClass. If supplied, 
this must be a custom cursor class that extends sqlite3.Cursor.

So I think we should check the type and then raise TypeError.

For the second issue, it seems it just hits the Py_CLEAR comments.

issue27861 tries to fix this. Besides, it also alters Connection.cursor's doc 
since it now does not reflects the implementation.

--
keywords: +patch
nosy: +xiang.zhang
Added file: https://bugs.python.org/file44227/issue27861.patch

___
Python tracker 

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



[issue27842] Order CSV header fields

2016-08-26 Thread Steve Holden

Steve Holden added the comment:

Is there another way? :)

Sent from my iPhone

> On 26 Aug 2016, at 12:16, Raymond Hettinger  wrote:
> 
> 
> Raymond Hettinger added the comment:
> 
> Consider using itertools.permutations() to generate the 120 cases cases.
> 
> The news entry goes into Misc/NEWS (there is not .txt extension).
> 
> --
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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