[issue35333] Rename private structs to use names closer to types

2018-11-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I don't know reasons against using the same name for the structure and the 
type. This can break extensions written before exposing the current Python C 
API in Python 1.5, but they should be already broken several times.

This is a cosmetic but large change. I suggest to ask on Python-Dev for the 
case if somebody has objections or better idea.

--

___
Python tracker 

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



[issue34589] Py_Initialize() and Py_Main() should not enable C locale coercion

2018-11-28 Thread Kubilay Kocak


Change by Kubilay Kocak :


--
nosy: +koobs

___
Python tracker 

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



[issue33930] Segfault with deep recursion into object().__dir__

2018-11-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is hard to get a noticeable difference in macrobenchmarks. I want to see 
results of microbenchmarks.

For tuples, the trashcan mechanism is the main culprit of the performance hit 
when use short-living tuples for passing arguments. For bound method objects 
the relative effect should be smaller, because looking up the method is more 
costly than building a tuple, and less bound method objects are created after 
implementing the method call optimization. But in any case we should know the 
maximal cost of this change before merging it.

--

___
Python tracker 

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



[issue35334] urllib3 fails with type error exception, when cannot reach PyPI - urllib3.util.retry

2018-11-28 Thread Arno-Can Uestuensoez


Arno-Can Uestuensoez  added the comment:

@xtreak
I didn't checked the source of the assignment of the instance of *Retry* to 
*self.total*. For me it was important to get the display of the actual source 
of the failure, which is the failed access to PyPI. Thus my proposal, just to 
intercept the error, display a bug-report, and display the quite good error 
message for the failed PyPI access already contained in the code. 

Thus the intention to replace:

>  File 
> "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py",
>  line 315, in increment
>
>total -= 1
>
> TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

by:

> Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after 
> connection broken by 
> 'ConnectTimeoutError(  object at/
>
>  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after 
> connection broken by 
'ConnectTimeoutError(
>  Could not find a version that satisfies the requirement evdev (from 
> versions: )
>
> No matching distribution found for evdev
>
> WARNING : Pip failed to install software!

Optionally with an additional error message for the faulty assignment to  the 
member *total*. But this is actually just a repetition counter, so even the 
integer replacement(>=1) should be OK. If an application uses it - wrongly - as 
a reference pointer, this will fail than immediately and the app recognises 
it's error straight away.

--

___
Python tracker 

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



[issue35334] urllib3 fails with type error exception, when cannot reach PyPI - urllib3.util.retry

2018-11-28 Thread Christian Heimes


Christian Heimes  added the comment:

This is the wrong bug tracker for urllib3. The urllib3 package is not part of 
Python's standard library. 

As xtreak pointed out, it's not even a bug in urllib3 or pip. Debian ships a 
modified and patched version of pip that uses an incompatible version of 
urllib3. Please follow up on the Debian bug tracker,

--
nosy: +christian.heimes
resolution:  -> third party
stage:  -> resolved
status: open -> closed
type: crash -> behavior

___
Python tracker 

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



[issue34100] Same constants in tuples are not merged while compile()

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

Well, it's up to you. I will review your PR ;-)

--

___
Python tracker 

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



[issue19865] create_unicode_buffer() fails on non-BMP strings on Windows

2018-11-28 Thread Leonard de Ruijter


Leonard de Ruijter  added the comment:

I'm still able to reproduce this issue with ctypes under Python 3.7.0

--
nosy: +Leonard de Ruijter

___
Python tracker 

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



[issue35240] Travis CI: xvfb-run: error: Xvfb failed to start

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a22df4896f6b83c8741203118790ae281716bca5 by Victor Stinner in 
branch 'master':
bpo-35240: Add "doctest" job to Travis CI (GH-10753)
https://github.com/python/cpython/commit/a22df4896f6b83c8741203118790ae281716bca5


--

___
Python tracker 

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



[issue35322] test_datetime leaks memory on Windows

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset bde9d6bbb46ca59bcee5d5060adaa33c3ffee3a6 by Victor Stinner in 
branch 'master':
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759)
https://github.com/python/cpython/commit/bde9d6bbb46ca59bcee5d5060adaa33c3ffee3a6


--

___
Python tracker 

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



[issue34523] Choose the filesystem encoding before Python initialization (add _PyCoreConfig.filesystem_encoding)

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset bde9d6bbb46ca59bcee5d5060adaa33c3ffee3a6 by Victor Stinner in 
branch 'master':
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759)
https://github.com/python/cpython/commit/bde9d6bbb46ca59bcee5d5060adaa33c3ffee3a6


--

___
Python tracker 

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



[issue35240] Travis CI: xvfb-run: error: Xvfb failed to start

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

I created a new job to no longer run xvfb-run twice. Let's see if it works 
around the issue. At least, it should make Travis CI a little bit faster.

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



[issue35334] urllib3 fails with type error exception, when cannot reach PyPI - urllib3.util.retry

2018-11-28 Thread Arno-Can Uestuensoez


Arno-Can Uestuensoez  added the comment:

@christian.heimes , @xtreak

Thanks, just for documentation, hope this is the right place - putting one to 
debian later:

See: issue - 1486: https://github.com/urllib3/urllib3/issues/1486

for file: 
https://github.com/urllib3/urllib3/blob/master/src/urllib3/util/retry.py

Rem.: The issue is about the originator of the exception - which is not 
necessarily the original cause.

--

___
Python tracker 

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



[issue35330] When using mock to wrap an existing object, side_effect requires return_value

2018-11-28 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue34100] Same constants in tuples are not merged while compile()

2018-11-28 Thread INADA Naoki


Change by INADA Naoki :


--
pull_requests: +10008

___
Python tracker 

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



[issue34523] Choose the filesystem encoding before Python initialization (add _PyCoreConfig.filesystem_encoding)

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10009

___
Python tracker 

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



[issue35322] test_datetime leaks memory on Windows

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10010
stage:  -> patch review

___
Python tracker 

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



[issue35322] test_datetime leaks memory on Windows

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

bpo-34482 added the test in test_datetime which triggered the bug.

--

___
Python tracker 

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



[issue35336] Bug in C locale coercion with PYTHONCOERCECLOCALE=1

2018-11-28 Thread STINNER Victor


New submission from STINNER Victor :

PYTHONCOERCECLOCALE=1 should not force C locale coercion, Python should still 
check if the LC_CTYPE locale is "C".

Bug:

$ ./python -c 'import locale; print(locale.setlocale(locale.LC_CTYPE, None))'
fr_FR.UTF-8
$ PYTHONCOERCECLOCALE=1 ./python -c 'import locale; 
print(locale.setlocale(locale.LC_CTYPE, None))'
C.UTF-8

It should be fr_FR.UTF-8 as well in the second example :-( It seems to be a 
regression that I introduced in the middle of my refactoring on the Python 
initialization.

The bug is around:

static void
config_init_locale(_PyCoreConfig *config)
{
if (config->coerce_c_locale < 0) {
/* The C locale enables the C locale coercion (PEP 538) */
if (_Py_LegacyLocaleDetected()) {
config->coerce_c_locale = 1;
}
}
...
}

The 3.7 branch and the 3.7.0 release are affected :-(

$ ./python -V
Python 3.7.0
$ PYTHONCOERCECLOCALE=1 ./python -c 'import locale; 
print(locale.setlocale(locale.LC_CTYPE, None))'
C.UTF-8

--
components: Interpreter Core
messages: 330590
nosy: vstinner
priority: normal
severity: normal
status: open
title: Bug in C locale coercion with PYTHONCOERCECLOCALE=1
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue34100] Same constants in tuples are not merged while compile()

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10011

___
Python tracker 

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



[issue35322] test_datetime leaks memory on Windows

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 85ab974f78c0ebcfa611639864640d0273eb5466 by Victor Stinner in 
branch '3.7':
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759) (GH-10761)
https://github.com/python/cpython/commit/85ab974f78c0ebcfa611639864640d0273eb5466


--

___
Python tracker 

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



[issue34523] Choose the filesystem encoding before Python initialization (add _PyCoreConfig.filesystem_encoding)

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 85ab974f78c0ebcfa611639864640d0273eb5466 by Victor Stinner in 
branch '3.7':
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759) (GH-10761)
https://github.com/python/cpython/commit/85ab974f78c0ebcfa611639864640d0273eb5466


--

___
Python tracker 

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



[issue35322] test_datetime leaks memory on Windows

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

I tested manually that "python -m test test_datetime -R 3:3" pass on 3.7 and 
master branches.

Note: PyUnicode_DecodeLocale() is still untested, only _Py_DecodeLocaleEx() and 
_Py_EncodeLocaleEx() are tested.

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



[issue35134] Add a new Include/cpython/ subdirectory for the "CPython API" with implementation details

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10012

___
Python tracker 

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



[issue35134] Add a new Include/cpython/ subdirectory for the "CPython API" with implementation details

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 54ba556c6c7d8fd5504dc142c2e773890c55a774 by Victor Stinner in 
branch 'master':
bpo-35134: Create Include/cpython/tupleobject.h (GH-10764)
https://github.com/python/cpython/commit/54ba556c6c7d8fd5504dc142c2e773890c55a774


--

___
Python tracker 

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



[issue19865] create_unicode_buffer() fails on non-BMP strings on Windows

2018-11-28 Thread Mark Lawrence


Change by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue35330] When using mock to wrap an existing object, side_effect requires return_value

2018-11-28 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I did some debugging with docstring for wraps.


> `wraps`: Item for the mock object to wrap. If `wraps` is not None then
>  calling the Mock will pass the call through to the wrapped object
>  (returning the real result). Attribute access on the mock will return a
>  Mock object that wraps the corresponding attribute of the wrapped object
>  (so attempting to access an attribute that doesn't exist will raise an
>  `AttributeError`).
>  If the mock has an explicit return_value set then calls are not passed to 
> the wrapped object and the return_value is returned instead.

So calling mock.Mock(wraps=c) sets the _mock_wraps with c. When we set 
m.func.side_effect and call m.func() it checks for the side_effect (func2) to 
be a callable and calls it [0]. It also checks if self._mock_wraps is not None 
which in this case is MyClass() and checks for the func of Myclass that is also 
called at [1] . As per the docstring since it wraps the actual object calling 
m.invalid_func without return_value set will cause attribute error like 
"AttributeError: 'MyClass' object has no attribute 'invalid_func'"

It seems to be a general case with mock itself where when side_effect and 
return_value are set then side_effect is called and ignores the return_value 
set unless the side_effect returns the sentinel value DEFAULT as in test [2]. I 
find this to be surprising.

$ ./python.exe
Python 3.8.0a0 (heads/master:b7278736b3, Nov 28 2018, 10:26:47)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest import mock
>>> m = mock.Mock()
>>> m.side_effect = lambda : 2
>>> m.return_value = 3
>>> m() # side_effect and return_value are set returning side_effect
2
>>> f = mock.Mock()
>>> f.return_value = 3
>>> f() # side_effect is not set thus returns only return_value
3

As per the original report when there is a return_value set without the 
side_effect it returns the set return_value. When there is a return_value set 
with the side_effect then return value of the side effect is returned though 
return_value is explicitly set like above also with wraps

>>> m = mock.Mock(wraps=c)
>>> print(m.func())
func called
1
>>> m.func.return_value = 3
>>> print(m.func())
3
>>> f = mock.Mock(wraps=c)
>>> f.func.side_effect = func2
>>> f.func.return_value = 3
>>> print(f.func())
func2 called
2

[0] 
https://github.com/python/cpython/blob/bde9d6bbb46ca59bcee5d5060adaa33c3ffee3a6/Lib/unittest/mock.py#L1031
[1] 
https://github.com/python/cpython/blob/bde9d6bbb46ca59bcee5d5060adaa33c3ffee3a6/Lib/unittest/mock.py#L1041
[2] 
https://github.com/python/cpython/blob/54ba556c6c7d8fd5504dc142c2e773890c55a774/Lib/unittest/test/testmock/testmock.py#L156

--
nosy: +mariocj89, michael.foord

___
Python tracker 

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



[issue35330] When using mock to wrap an existing object, side_effect requires return_value

2018-11-28 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

A little more discussion over side_effect and return_value precedence : 
issue22541

--

___
Python tracker 

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



[issue35337] Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode

2018-11-28 Thread STINNER Victor


New submission from STINNER Victor :

I propose to add assertions to PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode 
to check the index when Python is compiled in debug mode (./configure 
--with-pydebug).

This change is backward incompatible when PyTuple_GET_ITEM/PyTuple_SET_ITEM is 
used on a structseq with unnamed fields. Well, that's a bug in the user code, 
PyStructSequence_GET_ITEM/PyStructSequence_SET_ITEM should be used instead.

--
components: Interpreter Core
messages: 330597
nosy: vstinner
priority: normal
severity: normal
status: open
title: Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode
versions: Python 3.8

___
Python tracker 

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



[issue19865] create_unicode_buffer() fails on non-BMP strings on Windows

2018-11-28 Thread Josh Rosenberg


Change by Josh Rosenberg :


--
keywords: +3.2regression
versions: +Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue35337] Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +10013
stage:  -> patch review

___
Python tracker 

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



[issue19865] create_unicode_buffer() fails on non-BMP strings on Windows

2018-11-28 Thread Josh Rosenberg


Change by Josh Rosenberg :


--
keywords:  -3.2regression

___
Python tracker 

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



[issue35337] Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

My commit df108dc6610e41c54ed064a854e3903c143f0d77 already added 
assert(PyTuple_Check(op)) to these two macros.

--

___
Python tracker 

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



[issue35330] When using mock to wrap an existing object, side_effect requires return_value

2018-11-28 Thread Mario Corchero


Mario Corchero  added the comment:

I can indeed reproduce the issue. The problem seems to be here: 
https://github.com/python/cpython/blob/54ba556c6c7d8fd5504dc142c2e773890c55a774/Lib/unittest/mock.py#L1041

The simplified current logic in that code is:
- call side_effect, save the return value in ret.
- if return_value is not set, call the wraps object and return it.
- return the value in ret from the first step.

That explains why you see your "expected behavior" to happen only when return 
value is set.

Basically, the logic disables the current wrapped object ONLY if return value 
is set.
I am not sure why it was not done for `side_effect` as well.
Trying to perform that change in the sourcecode (nor run wraps if side_effect 
is set) results in no failure from the tests, which might mean it is a bug 

One might claim the code is there because `side_effect` might still be used to 
cause a side effect but not return, I would disagree, especially as setting 
`return_value` totally breaks it. As once the `return_value` is set, both 
`return_value` and `wraps` are ignored and `side_effect` takes preference due 
to line 1044.
Especially as the docs say about side_effect: 
`unless it returns DEFAULT, the return value of this function is used as the 
return value.`

I'd suggest a patch adding the `and not effect` to line 1041, so `side_effect` 
takes preference over `wraps`, the same way `return_value` does today.

The behavior of `side_effect` taken precedence over `return_value` is fine, 
that is how Mock works.



This bug can be reproduced without a class at all, see:

```
from unittest import mock
def func():
print('Original func called')
return "ORIGINAL"

m = mock.Mock(wraps=func)

def side_effect():
print('Side effect func called')
return "SIDE EFFECT"


m.side_effect = side_effect
print(m())
```

Results in:
```
Side effect func called
Original func called
ORIGINAL
```

Whilst the expected is:
```
Side effect func called
SIDE EFFECT
```



## TL;DR;

Indeed, `side_effect` seems broken when applied to an object with wraps and 
setting `return_value` kind of "fixes it".
I'd send a fix to add the check for `effect` unless michael.foord or someone 
else knows a good reason of why things are not like that. + tests

Noam Yorav-Raphael I am happy to send the patch if you don't have time :)

--

___
Python tracker 

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



[issue35337] Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1cdfcfc9843d35ab2cb87387d3a79b2c8a585a38 by Victor Stinner in 
branch 'master':
bpo-35337: Fix gettmarg(): use PyStructSequence_GET_ITEM() (GH-10765)
https://github.com/python/cpython/commit/1cdfcfc9843d35ab2cb87387d3a79b2c8a585a38


--

___
Python tracker 

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



[issue35338] set union/intersection/difference could accept zero arguments

2018-11-28 Thread David Miguel Susano Pinto


New submission from David Miguel Susano Pinto :

set union, intersection, difference methods accept any non-zero number of sets 
and return a new set instance, like so:

>>> a = set([1, 2])
>>> b = set([1, 3])
>>> c = set([3, 5])
>>> set.union(a, b, c)
{1, 2, 3, 5}

even if it's only one argument:

>>> set.union(a)
{1, 2}

I think it would be nice if zero arguments were not an error:

>>> set.union()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: descriptor 'union' of 'set' object needs an argument

This would allow to handle any sequence of sets which otherwise requires this:

if len(sequence):
return set.union(*sequence)
else:
return set()

--
messages: 330601
nosy: carandraug
priority: normal
severity: normal
status: open
title: set union/intersection/difference could accept zero arguments
type: enhancement
versions: Python 3.7

___
Python tracker 

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



[issue35330] When using mock to wrap an existing object, side_effect requires return_value

2018-11-28 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks @mariocj89 for the explanation. I just got to the docs part about 
side_effect and return_value precedence. I am curious to know about the 
behavior as well and at least this can be added as a test as I see only around 
3 tests for side_effect and there is no test for wraps behavior in this report 
I assume given that there were no test failures due to changing the logic.

--

___
Python tracker 

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



[issue35337] Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10014

___
Python tracker 

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



[issue35338] set union/intersection/difference could accept zero arguments

2018-11-28 Thread SilentGhost


SilentGhost  added the comment:

You can write your code like this:

   set().union(*sequence)

as well as: a.union(b, c) if you already have a set object available.

--
nosy: +SilentGhost
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue35338] set union/intersection/difference could accept zero arguments

2018-11-28 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I agree with @SilentGhost to use set().union(*sequence) which is compatible 
with Python 2 too.

--
nosy: +rhettinger, xtreak

___
Python tracker 

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



[issue34100] Same constants in tuples are not merged while compile()

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f7e4d3642fbb88f4e6243c952a0e223fb5df1c65 by Victor Stinner (INADA 
Naoki) in branch 'master':
bpo-34100: compile: Re-enable frozenset merging (GH-10760)
https://github.com/python/cpython/commit/f7e4d3642fbb88f4e6243c952a0e223fb5df1c65


--

___
Python tracker 

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



[issue30689] len() and iter() of ChainMap don't work with unhashable keys

2018-11-28 Thread ebw


ebw  added the comment:

I actually have a real life use case of that problem. Using the eval() function 
of pandas need to use a custom resolver:

class Resolver(object):
def __getitem__(self, name):
if name == "test":
return 0.5
else:
raise KeyError

resolvers = (Resolver(), )
pd.eval("test", resolvers=resolvers)

But pandas store the resolvers used for eval() in a DeepChainMap and uses 
bool(len(self.resolvers)) in the property has_resolvers. Which with my custom 
Resolver raise a KeyError because __getiem__ gets call with name = 0.

The way to solve/bypass the problem was to make Resolver a inherit from 
UserDict.

class Resolver(UserDict):
def __init__(self, data={}):
super(Resolver, self).__init__(data)
self.data["test"] = None

def __getitem__(self, name):
if (name == "test"):
return 0.5
else:
super(Resolver, self).__getitem__(name)

resolvers = (Resolver(), )
pd.eval("test", resolvers=resolvers)

I had to add a dummy "test" value to Resolver.data dict to avoid 
len(self.resolvers) to be 0. I tried to implement Resolver.__len__, keys... but 
it didn't help has ChainMap compute the len using set().union(*self.maps).

--
nosy: +ebw

___
Python tracker 

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



[issue34100] Same constants in tuples are not merged while compile()

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks INADA Naoki! Thanks a simple and cool optimization!

Maybe you might want to document it at 
https://docs.python.org/dev/whatsnew/3.8.html#optimizations ?

--

___
Python tracker 

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



[issue35335] msgfmt should be able to merge more than one po file

2018-11-28 Thread SilentGhost


SilentGhost  added the comment:

The best way is to propose a PR via github (here are some details: 
https://devguide.python.org/pullrequest/) This sort of change, can only be 
applied against master (future 3.8), so don't spend time on legacy releases.

--
nosy: +SilentGhost
versions:  -Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue35332] shutil.rmtree(..., ignore_errors=True) doesn't ignore errors from os.close()

2018-11-28 Thread SilentGhost


Change by SilentGhost :


--
nosy: +David.Edelsohn

___
Python tracker 

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



[issue35331] Incorrect __module__ attribute for _struct.Struct and perhaps a few others

2018-11-28 Thread SilentGhost


Change by SilentGhost :


--
nosy: +mark.dickinson, meador.inge, serhiy.storchaka
type:  -> behavior

___
Python tracker 

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



[issue35311] exception unpickling error causes `multiprocessing.Pool` to hang forever

2018-11-28 Thread SilentGhost


Change by SilentGhost :


--
nosy: +alexandre.vassalotti
type:  -> behavior

___
Python tracker 

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



[issue35338] set union/intersection/difference could accept zero arguments

2018-11-28 Thread Raymond Hettinger


Change 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



[issue28604] localeconv() doesn't support LC_MONETARY encoding different than LC_CTYPE encoding

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
title: Exception raised by python3.5 when using en_GB locale -> localeconv() 
doesn't support LC_MONETARY encoding different than LC_CTYPE encoding

___
Python tracker 

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



[issue28604] localeconv() doesn't support LC_MONETARY encoding different than LC_CTYPE encoding

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-31900: localeconv() should decode numeric fields from LC_NUMERIC 
encoding, not from LC_CTYPE encoding.

--

___
Python tracker 

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



[issue31900] localeconv() should decode numeric fields from LC_NUMERIC encoding, not from LC_CTYPE encoding

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-28604: localeconv() doesn't support LC_MONETARY encoding different 
than LC_CTYPE encoding.

--

___
Python tracker 

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



[issue31900] localeconv() should decode numeric fields from LC_NUMERIC encoding, not from LC_CTYPE encoding

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

The initial bug has been fixed, I close the issue.

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



[issue27777] cgi.FieldStorage can't parse simple body with Content-Length and no Content-Disposition

2018-11-28 Thread Pierre Quentel


Change by Pierre Quentel :


--
pull_requests: +10015

___
Python tracker 

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



[issue34921] NoReturn not allowed by get_type_hints when future import annotations is used

2018-11-28 Thread Ismo Toijala


Change by Ismo Toijala :


--
pull_requests: +10016

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10017

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

A test failed again on AppVeyor! In the 3.7 branch, on this test:

def busy_wait(duration):
deadline = time.monotonic() + duration
while time.monotonic() < deadline:
pass
(...)
def test_thread_time(self):
(...)
# bpo-33723: A busy loop of 100 ms should increase thread_time()
# by at least 15 ms, but less than 30 ms in other threads.
# Tolerate 15 and 30 ms because of the bad resolution
# of the clock on Windows (around 15.6 ms).
min_time = 0.015
max_time = 0.030
busy_time = 0.100

# thread_time() should include CPU time spent in current thread...
start = time.thread_time()
busy_wait(busy_time)
stop = time.thread_time()
self.assertGreaterEqual(stop - start, min_time)   # <= HERE =
(...)

FAIL: test_thread_time (test.test_time.TimeTestCase)
--
Traceback (most recent call last):
  File "C:\projects\cpython\lib\test\test_time.py", line 550, in 
test_thread_time
self.assertGreaterEqual(stop - start, min_time)
AssertionError: 0.0 not greater than or equal to 0.015

IMHO the root issue is that time.thread_time() and time.monotonic() clocks are 
just... unrelated... on Windows.

This time, I give up and wrote a PR to remove the "busy loop" tests, sorry! PR 
10773.

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue35339] Populating instances of class automatically

2018-11-28 Thread Daugeras


New submission from Daugeras :

Hello, I am not sure it is a bug, but it is a very strange behavior of Python, 
which I do not understand.

I created a class (mainly a structure) and instantiated an object of this class 
in a first function (Object 1). The function populates Object 1.
In another function, I instantiate another object of the same class (Object 2) 
, and Object 2 is automatically populated with the data of Object 1. Note than 
Object 1 and Object 2 have different memory adresses.

This behavior is very strange. Is it normal for Python or is it a Bug ?

--
messages: 330613
nosy: Daugeras
priority: normal
severity: normal
status: open
title: Populating instances of class automatically
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue35339] Populating instances of class automatically

2018-11-28 Thread Geoffrey Spear


Geoffrey Spear  added the comment:

It's impossible to guess exactly what you did from your vague description 
instead of actual code, but it may be covered by this FAQ question: 
https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects

(mutable objects as class rather than instance attributes will display similar 
behavior. This isn't a bug.)

--
nosy: +geoffreyspear

___
Python tracker 

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



[issue35340] global symbol "freegrammar" should be made static ore renamed

2018-11-28 Thread Matthias Klose


New submission from Matthias Klose :

seen at least on the 2.7, a new symbol polluting the symbol namespace.
the global symbol "freegrammar" should be made static ore renamed

--
components: Interpreter Core
messages: 330615
nosy: doko
priority: normal
severity: normal
status: open
title: global symbol "freegrammar" should be made static ore renamed
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



[issue35341] Add generic version of OrderedDict to typing module

2018-11-28 Thread Ismo Toijala


New submission from Ismo Toijala :

The other collections from the collections module (namedtuple, deque, ChainMap, 
Counter, defaultdict) have generic versions in the typing module for use in 
type annotations.

The problem is currently the following:

from __future__ import annotations
import typing
from collections import OrderedDict
# Understood by mypy
def f(d: OrderedDict[str, str]) -> None:
pass
typing.get_type_hints(f)

gives:

Traceback (most recent call last):
  File "foo.py", line 9, in 
typing.get_type_hints(f)
  File "/usr/lib/python3.7/typing.py", line 1001, in get_type_hints
value = _eval_type(value, globalns, localns)
  File "/usr/lib/python3.7/typing.py", line 260, in _eval_type
return t._evaluate(globalns, localns)
  File "/usr/lib/python3.7/typing.py", line 464, in _evaluate
eval(self.__forward_code__, globalns, localns),
  File "", line 1, in 
TypeError: 'type' object is not subscriptable

To fix this, a line like the following could be added to Lib/typing.py near 
line 1250:

OrderedDict = _alias(collections.OrderedDict, (KT, VT))

There might be a reasoning for why this has not been done yet, but I have not 
been able to find any.

If this is acceptable, I could prepare a PR.
I suppose there is no hope of a backport to 3.7, since this is a new feature 
(though very minor).

--
components: Library (Lib)
messages: 330616
nosy: itoijala
priority: normal
severity: normal
status: open
title: Add generic version of OrderedDict to typing module
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue29708] support reproducible Python builds

2018-11-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10019

___
Python tracker 

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



[issue34022] 6 tests fail using SOURCE_DATE_EPOCH env var

2018-11-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10018

___
Python tracker 

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



[issue34921] NoReturn not allowed by get_type_hints when future import annotations is used

2018-11-28 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:


New changeset f71a5922916abd6cc7bf7d99ed4715b6e96e5981 by Ivan Levkivskyi (Ismo 
Toijala) in branch '3.7':
bpo-34921: Allow escaped NoReturn in get_type_hints (GH-9750) (GH-10772)
https://github.com/python/cpython/commit/f71a5922916abd6cc7bf7d99ed4715b6e96e5981


--

___
Python tracker 

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



[issue35326] ctypes cast and from_address cause crash on Windows 10

2018-11-28 Thread Mordechai Botrashvily


Mordechai Botrashvily  added the comment:

Eryk, thanks :).
This really solved the problem.
Odd how it went unnoticed.

--

___
Python tracker 

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



[issue34022] 6 tests fail using SOURCE_DATE_EPOCH env var

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

test_compileall, test_importlib, test_py_compile: I created 
https://github.com/python/cpython/pull/10775 backport.

test_cmd_line_script, test_runpy and test_multiprocessing_main_handling 
failures are related to zipimport. They have been fixed in master by commit 
a6e956bcb0edbfe7f18af9be2215a5326ea6bf05 which modifies Lib/zipimport.py... but 
in 3.7, zipimport is written in C. It seems non-trivial to fix zipimport, and 
I'm not sure that it's worth it.

Note: test_posix now pass, no idea why it failed a few days ago.

--

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 48498dd57f79ab1d061c754ad6a2ebe1a7172b0e by Victor Stinner in 
branch 'master':
bpo-33723: Remove busy loop from test_time (GH-10773)
https://github.com/python/cpython/commit/48498dd57f79ab1d061c754ad6a2ebe1a7172b0e


--

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-11-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +10020
stage: resolved -> patch review

___
Python tracker 

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



[issue35342] email "default" policy raises exception iterating over unparseable date headers

2018-11-28 Thread Richard Brooksby


New submission from Richard Brooksby :

It is not possible to loop over the headers of a message with an unparseable 
date field using the "default" policy.  This means that a poison email can 
break email processing.

I expect to be able to process an email with an unparseable date field using 
the "default" policy.

$ python3 --version
Python 3.6.7
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> import email.policy
>>> email.message_from_string('Date: not a parseable date', 
>>> policy=email.policy.default).items()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.6/email/message.py", line 460, in items
for k, v in self._headers]
  File "/usr/lib/python3.6/email/message.py", line 460, in 
for k, v in self._headers]
  File "/usr/lib/python3.6/email/policy.py", line 162, in header_fetch_parse
return self.header_factory(name, value)
  File "/usr/lib/python3.6/email/headerregistry.py", line 589, in __call__
return self[name](name, value)
  File "/usr/lib/python3.6/email/headerregistry.py", line 197, in __new__
cls.parse(value, kwds)
  File "/usr/lib/python3.6/email/headerregistry.py", line 306, in parse
value = utils.parsedate_to_datetime(value)
  File "/usr/lib/python3.6/email/utils.py", line 210, in parsedate_to_datetime
*dtuple, tz = _parsedate_tz(data)
TypeError: 'NoneType' object is not iterable
>>> 

Related: 
https://docs.python.org/3/library/email.headerregistry.html#email.headerregistry.DateHeader
 does not specify what happens to the datetime field if a date header cannot be 
parsed.

Related: 
https://docs.python.org/3/library/email.utils.html#email.utils.parsedate_to_datetime
 does not specify what happens if a date cannot be parsed.

Suggested tests: random fuzz testing of the contents of all email headers, 
especially those with parsers in the header registry.

--
components: email
messages: 330621
nosy: barry, r.david.murray, rptb1
priority: normal
severity: normal
status: open
title: email "default" policy raises exception iterating over unparseable date 
headers
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue35342] email "default" policy raises exception iterating over unparseable date headers

2018-11-28 Thread Richard Brooksby


Change by Richard Brooksby :


--
versions: +Python 3.6 -Python 3.7

___
Python tracker 

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



[issue29708] support reproducible Python builds

2018-11-28 Thread miss-islington


miss-islington  added the comment:


New changeset 24b51b1a4919e310d338629cc60371387f475a32 by Miss Islington (bot) 
in branch '3.7':
bpo-34022: Stop forcing of hash-based invalidation with SOURCE_DATE_EPOCH 
(GH-9607)
https://github.com/python/cpython/commit/24b51b1a4919e310d338629cc60371387f475a32


--
nosy: +miss-islington

___
Python tracker 

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



[issue34022] 6 tests fail using SOURCE_DATE_EPOCH env var

2018-11-28 Thread miss-islington


miss-islington  added the comment:


New changeset 24b51b1a4919e310d338629cc60371387f475a32 by Miss Islington (bot) 
in branch '3.7':
bpo-34022: Stop forcing of hash-based invalidation with SOURCE_DATE_EPOCH 
(GH-9607)
https://github.com/python/cpython/commit/24b51b1a4919e310d338629cc60371387f475a32


--
nosy: +miss-islington

___
Python tracker 

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



[issue35342] email "default" policy raises exception iterating over unparseable date headers

2018-11-28 Thread Richard Brooksby


Change by Richard Brooksby :


--
versions: +Python 3.7

___
Python tracker 

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



[issue24412] setUpClass equivalent for addCleanup

2018-11-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

/home/serhiy/py/cpython/Lib/unittest/test/test_runner.py:259: 
DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(e, 'cleanup1')

--

___
Python tracker 

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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-11-28 Thread miss-islington


miss-islington  added the comment:


New changeset d46d753d152a5d01f9c454d18b1ae660509d9b16 by Miss Islington (bot) 
in branch '3.7':
bpo-33723: Remove busy loop from test_time (GH-10773)
https://github.com/python/cpython/commit/d46d753d152a5d01f9c454d18b1ae660509d9b16


--

___
Python tracker 

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



[issue27777] cgi.FieldStorage can't parse simple body with Content-Length and no Content-Disposition

2018-11-28 Thread Pierre Quentel


Pierre Quentel  added the comment:

I have submitted another Pull Request (10771) that seems to fix the bug while 
passing all the tests in test_cgi.py

--
nosy: +quentel

___
Python tracker 

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



[issue35342] email "default" policy raises exception iterating over unparseable date headers

2018-11-28 Thread R. David Murray


R. David Murray  added the comment:

This is effectively a duplicate of #30681, which has a solution, although it is 
not yet in final form per the last couple of comments on the issue and the PR.

--
resolution:  -> duplicate
stage:  -> resolved
superseder:  -> email.utils.parsedate_to_datetime() should return None when 
date cannot be parsed
versions: +Python 3.8

___
Python tracker 

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



[issue30681] email.utils.parsedate_to_datetime() should return None when date cannot be parsed

2018-11-28 Thread R. David Murray


R. David Murray  added the comment:

Reported again in issue #35342.

The existing PR is close to complete, but needs adjusted for the fact that we 
want (and want to document) that the utility raises errors (ie: catch the error 
in the header parser rather than having the utility return None).

--
versions: +Python 3.7, Python 3.8 -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



[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

I removed the "busy loop" tests from 3.7 and master.

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



[issue35339] Populating instances of class automatically

2018-11-28 Thread Daugeras


Daugeras  added the comment:

Hi Geoffrey,

Indeed you where right, this is not a bug.
The link you provided did solve my problem.
I declared classes with attributes as strings, lists, etc... and indeed it was 
the reason for the issue.
I changed it to instantiate the attributes in the __init__ method of the class, 
and it solved the problems.
Thanks again !!

--

___
Python tracker 

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



[issue35343] Importlib.reload has different behaviour in script and interactive mode

2018-11-28 Thread Owen Pembery


New submission from Owen Pembery :

This may be a bug, or may be a hole in my understanding of how importlib.reload 
works.

In short, when running importlib.reload in a script, it seems that a module is 
not reloaded before it is used, whereas running the same script a line at a 
time in interactive mode seems to reload the script.

Relevant scripts are in the github repository: 
https://github.com/orpembery/python-reload-bug.

I find the bug using python 3.5.2 on Ubuntu 16.04.

The expected output from running

python3 master.py

is:
1
2

However, I instead find that the output is:
1
1

If I paste the commands in master.py into the interpreter one at a time, I get 
the expected behaviour:

Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from shutil import copy
>>> 
>>> from importlib import reload
>>> # Move a file
... copy('fn_1.py','fn.py')
'fn.py'
>>> # Import it
... import fn
>>> # Run it
... fn.fn()
1
>>> # Move a different file to the same location.
... copy('fn_2.py','fn.py')
'fn.py'
>>> # Reload it
... reload(fn)

>>> # Run it
... fn.fn()
2


However, if the commands in master.py are pasted in all at one (i.e., with a 
single CTRL-V keystroke), I obtain the unexpected behaviour:
Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from shutil import copy
>>> from importlib import reload
>>> 
>>> # Move a file
... copy('fn_1.py','fn.py')
'fn.py'
>>> 
>>> # Import it
... import fn
>>> 
>>> # Run it
... fn.fn()
1
>>> 
>>> # Move a different file to the same location.
... copy('fn_2.py','fn.py')
'fn.py'
>>> 
>>> # Reload it
... reload(fn)

>>> 
>>> # Run it
... fn.fn()
1


Possible causes:
I'm very far from an expert, but it seems to be something to do with caching; 
running

python3 -B master.py

gives the expected behaviour.

--
components: Library (Lib)
messages: 330631
nosy: brett.cannon, orpembery
priority: normal
severity: normal
status: open
title: Importlib.reload has different behaviour in script and interactive mode
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



[issue35343] Importlib.reload has different behaviour in script and interactive mode

2018-11-28 Thread Owen Pembery


Change by Owen Pembery :


--
type:  -> behavior

___
Python tracker 

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



[issue35316] test_eintr fails randomly on macOS

2018-11-28 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Some buildbots failing with this problem:

https://buildbot.python.org/all/#/builders/145/builds/849

--

___
Python tracker 

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



[issue35316] test_eintr fails randomly on macOS

2018-11-28 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I will investigate with MacOS Mojave this week.

--

___
Python tracker 

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



[issue35316] test_eintr fails randomly on macOS

2018-11-28 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
assignee:  -> pablogsal

___
Python tracker 

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



[issue35316] test_eintr fails randomly on macOS

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

I'm unable to reproduce the issue using "./python.exe 
Lib/test/eintrdata/eintr_tester.py -v SelectEINTRTest.test_select" on macOS 
10.13.6.

--

___
Python tracker 

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



[issue33930] Segfault with deep recursion into object().__dir__

2018-11-28 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Can someone please explain me why this change has any impact? Does it mean 
> that _PyObject_GC_UNTRACK() macro has a bug?

Interestingly, this lonely and perplexing comment is left in  
PyObject_GC_UnTrack (the function):

void
PyObject_GC_UnTrack(void *op)
{
 /* Obscure:  the Py_TRASHCAN mechanism requires that we be able to
  * call PyObject_GC_UnTrack twice on an object.
  */
  if (_PyObject_GC_IS_TRACKED(op)) {
  _PyObject_GC_UNTRACK(op);
  }
}

--

___
Python tracker 

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



[issue35344] platform: get macOS version rather than darwin version?

2018-11-28 Thread STINNER Victor


New submission from STINNER Victor :

Would it be possible to get the macOS version (platform.mac_ver()) rather than 
the darwin version (uname()) for platform.platform()? As an user, I prefer the 
OS (macOS) version rather than the kernel (darwin) version.

Current output

$ ./python.exe -m platform
Darwin-17.7.0-x86_64-i386-64bit

versus

$ ./python.exe -c 'import platform; print(platform.mac_ver())'
('10.13.6', ('', '', ''), 'x86_64')

I tested on:

$ uname -a
Darwin macbook 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 
2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

$ sw_vers
ProductName:Mac OS X
ProductVersion: 10.13.6
BuildVersion:   17G65

--
components: Library (Lib), macOS
messages: 330636
nosy: ned.deily, ronaldoussoren, vstinner
priority: normal
severity: normal
status: open
title: platform: get macOS version rather than darwin version?
versions: Python 3.8

___
Python tracker 

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



[issue35344] platform: get macOS version rather than darwin version?

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

It seems like platform.mac_ver() can return None if plistlist is not available. 
platform.platform() can maybe try mac_ver(), but fallback on uname() if it's 
not available/working?

--

It seems like getting the macOS version without plistlib is not easy:
https://stackoverflow.com/questions/11072804/how-do-i-determine-the-os-version-at-runtime-in-os-x-or-ios-without-using-gesta

--

___
Python tracker 

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



[issue35337] Check index in PyTuple_GET_ITEM/PyTuple_SET_ITEM in debug mode

2018-11-28 Thread Zackery Spytz


Zackery Spytz  added the comment:

See also #14614.

--
nosy: +ZackerySpytz

___
Python tracker 

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



[issue35344] platform: get macOS version rather than darwin version?

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +10021
stage:  -> patch review

___
Python tracker 

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



[issue35345] Remove platform.popen(), deprecated since Python 3.3

2018-11-28 Thread STINNER Victor


New submission from STINNER Victor :

platform.popen() is deprecated since Python 3.3: bpo-11377. Calling the 
function emits a DeprecationWarning and the function is documented as being 
deprecated.

The function is documented in the "Win95/98 specific":
https://docs.python.org/dev/library/platform.html#win95-98-specific

Python 3.5 dropped Windows XP support. I don't think that Python 2.7 still 
support Windows 98. So it's time to remove support for this old OS.

Python 3 now has a os.popen() function:
https://docs.python.org/dev/library/os.html#os.popen

--
components: Library (Lib)
messages: 330639
nosy: vstinner
priority: normal
severity: normal
status: open
title: Remove platform.popen(), deprecated since Python 3.3
versions: Python 3.8

___
Python tracker 

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



[issue35345] Remove platform.popen(), deprecated since Python 3.3

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +10022
stage:  -> patch review

___
Python tracker 

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



[issue34022] 6 tests fail using SOURCE_DATE_EPOCH env var

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

> New changeset 24b51b1a4919e310d338629cc60371387f475a32 by Miss Islington 
> (bot) in branch '3.7':

With this change, only 3 tests fail on 3.7, and all these 3 fail because of 
zipimport: test_cmd_line_script, test_multiprocessing_main_handling and 
test_runpy.

Chih-Hsuan Yen:
> Looks like in https://github.com/python/cpython/pull/10327, Serhiy Storchaka 
> considers fixing these issues for 3.8 only - "It is easier to skip the test 
> on 3.7." and then remove the "needs backport to 3.7" label. How about 
> changing the target version to 3.8 only and close this issue?

Now I agree to close the issue :-)

I'm ok to not fix zipimport in 3.7.

Anyway, it's not like Python is perfect in the master branch: frozenset in 
marshal is still not reproducible. See bpo-29708.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8

___
Python tracker 

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



[issue35189] PEP 475: fnctl functions are not retried if interrupted by a signal (EINTR)

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +10023

___
Python tracker 

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



[issue35316] test_eintr fails randomly on macOS

2018-11-28 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +10024
stage:  -> patch review

___
Python tracker 

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



[issue35344] platform: get macOS version rather than darwin version?

2018-11-28 Thread Ronald Oussoren

Ronald Oussoren  added the comment:

Why do you want to change this?

The current behavior is consistent with the platform name (Darwin). I’ve filed 
an issue in the past to change the platform name to “macosx”, but there were 
good arguments to not change the behavior at the time. The existence of iOS 
might change that though. 

W.r.t. failing when the Plist is not present: that is unlikely to happen 
because this is a system file that is hard to remove and is AFAIK documented to 
exist. 

If the platform version info gets changed, the platform name should change as 
well. 

Ps. Sorry about the lack of references, I’m away from my computer.

--

___
Python tracker 

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



[issue14614] PyTuple_SET_ITEM could check bounds in debug mode

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, I didn't know this old issue (6 years old). I wrote an implementation of 
this issue for PyTuple_GET_ITEM/SET_ITEM: bpo-35337. Would you mind to have a 
look? It seems to be backward incompatible when these macros are misused on 
structseq.

--
nosy: +vstinner

___
Python tracker 

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



[issue34977] Release Windows Store app containing Python

2018-11-28 Thread Steve Dower


Steve Dower  added the comment:

Updated testing instructions - this one should work with just sideloading 
permissions I think.

iwr 
"https://dev.azure.com/Python/8e426817-76c0-4b99-ba9e-a48a1e4bd5db/_apis/build/builds/34760/artifacts?artifactName=appx&api-version=5.0-preview.5&%24format=zip";
 -outfile python37.zip
Expand-Archive .\python37.zip .
Add-AppxPackage appx\python.msix

To remove:
Remove-AppxPackage (Get-AppxPackage *Python.3.7)
(delete the downloaded files)

--

___
Python tracker 

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



[issue30681] email.utils.parsedate_to_datetime() should return None when date cannot be parsed

2018-11-28 Thread Tim Bell


Change by Tim Bell :


--
keywords: +patch
pull_requests: +10025
stage:  -> patch review

___
Python tracker 

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



[issue35189] PEP 475: fnctl functions are not retried if interrupted by a signal (EINTR)

2018-11-28 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 2956bffbc00127af65f69e04d7979021a21d1288 by Victor Stinner in 
branch 'master':
bpo-35189, bpo-35316: Make test_eintr less strict (GH-10782)
https://github.com/python/cpython/commit/2956bffbc00127af65f69e04d7979021a21d1288


--

___
Python tracker 

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



[issue35344] platform: get macOS version rather than darwin version?

2018-11-28 Thread STINNER Victor

STINNER Victor  added the comment:

> Why do you want to change this?

I created this issue after I read this comment:

> https://bugs.python.org/issue35316#msg330633
> I will investigate with MacOS Mojave this week.

"Mojave" seems to be the new thing, but I don't recall if my macbook is running 
it or not. So I checked "python3 -m platform" but it gives me... the darwin 
version. How am I supposed to guess the macOS version from this output?

As an user, I see/use "High Sierra" name, or sometimes "macOS 10.12", but I 
never see/use darwin versions.

Even inside Python, we rely on the macOS version, not the on the darwin 
version. For example, @requires_mac_ver of test.support rely on the *macOS* 
version.

Example from test_math:

# log2() is not accurate enough on Mac OS X Tiger (10.4)
@support.requires_mac_ver(10, 5)
def testLog2Exact(self):
...

> The current behavior is consistent with the platform name (Darwin). I’ve 
> filed an issue in the past to change the platform name to “macosx”, but there 
> were good arguments to not change the behavior at the time.

I don't expect that any library rely on platform.platform() to detect a 
platform, so I don't see any risk of backward incompatibility, whereas changing 
sys.platform would just break every single Python library for what? I don't see 
any benefit of replacing "darwin" with "macos" or "macosx".

By the way, we use "win32" for sys.platform, whereas all Windows are now 
64-bit...

> W.r.t. failing when the Plist is not present: that is unlikely to happen 
> because this is a system file that is hard to remove and is AFAIK documented 
> to exist. 

I was talking about the plistlib module, not the file on the disk. I am talking 
about these lines from platform.py:

try:
import plistlib
except ImportError:
return None

The import can fail for various reasons: module not provided by the Python 
implementation, missing depending (ex: "from xml.parsers.expat import 
ParserCreate" in plistlib.py causing an import error), etc.

I'm not saying that it should be common on CPython, just that it might happen 
in some weird cases :-)

--

___
Python tracker 

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



  1   2   >