petrikas | 18 Apr 20:45 2015

[issue23995] msvcrt could not be imported


New submission from petrikas:

Python cannot access msvcrt's putwch() when using manage.py syncdb

To reproduce:
1. Call manage.py syncdb and try to create a new superuser
2. It crashes after inputting email (or before asking for the password)

Reproducible with 3.5a3, seems to be a regression from 3.4.3. Downgrading fixed the issue

----------
components: Library (Lib)
messages: 241438
nosy: petrikas
priority: normal
severity: normal
status: open
title: msvcrt could not be imported
type: crash
versions: Python 3.5

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue23995>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/python-python-bugs-list%40m.gmane.org

(Continue reading)

Mert Bora Alper | 18 Apr 19:48 2015

[issue23994] argparse fails to detect program name when there is a slash at the end of the program's path


New submission from Mert Bora Alper:

Sorry if the title is not descriptive enough.

When I try to execute a program from a directory which contains an `__main__.py` file, argparse fails to
detect programs name. For example:

    $ ls foo
    __main__.py
    $ python3 foo
    usage: foo [-h] [-c COUNT] length
    foo: error: the following arguments are required: length
    $ python3 foo/
    usage: [-h] [-c COUNT] length
    : error: the following arguments are required: length

----

    >>> argparse.__version__
    '1.1'

I followed same steps using Python 2.7.6 and got same result. It will probably be same on other versions too.
Same result can also be obtained when using zip files instead of directories.

I don't know if this is a bug since I don't know if I do something wrong or is this a design decision or not.

Thank you,
Bora

(Continue reading)

STINNER Victor | 18 Apr 11:25 2015

[issue23993] Use surrogateescape error handler by default in open() if the locale is C


New submission from STINNER Victor:

As a following of the issue #19977, I propose to use also the surrogateescape error handler in open() by
default if the locale is C.

Attached issue adds a new sys.getdefaulterrorhandler() function and use it in io.TextIOWrapper (and _pyio.TextIOWrapper).

We may use sys.getdefaulterrorhandler() in more places.

I don't think that it would be correct to use in for str.encode() or bytes.decode().

----------
components: Unicode
files: default_error_handler.patch
keywords: patch
messages: 241405
nosy: ezio.melotti, haypo, ncoghlan
priority: normal
severity: normal
status: open
title: Use surrogateescape error handler by default in open() if the locale is C
versions: Python 3.5
Added file: http://bugs.python.org/file39100/default_error_handler.patch

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue23993>
_______________________________________
_______________________________________________
(Continue reading)

Charles-François Natali | 18 Apr 11:00 2015

[issue23992] multiprocessing: MapResult shouldn't fail fast upon exception


New submission from Charles-François Natali:

hanger.py
"""
from time import sleep

def hang(i):
    sleep(i)
    raise ValueError("x" * 1024**2)
"""

The following code will deadlock on pool.close():
"""
from multiprocessing import Pool
from time import sleep

from hanger import hang

with Pool() as pool:
    try:
        pool.map(hang, [0,1])
    finally:
        sleep(0.5)
        pool.close()
        pool.join()
"""

The problem is that when one of the tasks comprising a map result fails with an exception, the corresponding
MapResult is removed from the result cache:
(Continue reading)

Antony Lee | 18 Apr 06:44 2015

[issue23991] ZipFile sanity checks


New submission from Antony Lee:

ZipFile.{open,read} could raise IsADirectoryError when called on a directory entry, rather than return
an empty bytes.
ZipFile.writestr could fail writing non-empty bytes to a directory entry.

Use case for open and read: I was trying to write a zip merger (taking multiple zip files and merge them into a
single zip).  Unfortunately, the obvious approach (iterate on the original infolists, extract each of
them and writestr them to the new ZipFile object) created invalid zip files because it'll create empty
files for each directory.  Raising IsADirectoryError would have brought attention to the issue much earlier.

The suggested modification to writestr is a bit different, but also makes sense because the bytes argument
is not written anywhere anyways in the case of directory entries.

----------
components: Library (Lib)
messages: 241396
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: ZipFile sanity checks
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue23991>
_______________________________________
_______________________________________________
(Continue reading)

Maries Ionel Cristian | 17 Apr 20:52 2015

[issue23990] Callable builtin doesn't respect descriptors


New submission from Maries Ionel Cristian:

It appears that callable doesn't really care for the descriptor protocol, so it return True even if
__call__ is actually an descriptor that raise AttributeError (clearly not callable at all).

Eg:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> callable
<built-in function callable>
>>> class A:
...   <at> property
...  def __call__(self):
...   raise AttributeError('go away')
...
>>> a = A()
>>> a
<__main__.A object at 0x000000000365B5C0>
>>> a.__call__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in __call__
AttributeError: go away
>>> callable(a)
True
>>> # it should be False :(

----------
(Continue reading)

VanL | 17 Apr 20:33 2015

[issue23989] Add recommendation to use requests to the documentation, per summit


New submission from VanL:

Attached is a basic patch to add a recommendation to use requests to the http.client documentation for 3.5.
It is implemented as a seealso at the top of the file: 

See Also: The Requests package is recommended for a higher-level http client interface.

If people are happy with the wording, I'll also add the same message to urllib.request and do the same with
previous versions (2.7, 3.3, and 3.4).

----------
assignee: docs <at> python
components: Documentation
files: recommend_requests.patch
keywords: patch
messages: 241349
nosy: VanL, docs <at> python
priority: normal
severity: normal
status: open
title: Add recommendation to use requests to the documentation, per summit
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file39088/recommend_requests.patch

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue23989>
_______________________________________
(Continue reading)

Albert Zeyer | 17 Apr 16:40 2015

[issue23988] keyworded argument count is wrong


New submission from Albert Zeyer:

Code:

class C(object):
	def __init__(self, a, b=2, c=3):
		pass

class D(C):
	def __init__(self, d, **kwargs):
		super(D, self).__init__(**kwargs)

class E(D):
	def __init__(self, **kwargs):
		super(E, self).__init__(**kwargs)

E(d=42, b=0, c=0)

You get the funny message:

TypeError: __init__() takes at least 2 arguments (3 given)

----------
components: Interpreter Core
messages: 241335
nosy: Albert.Zeyer
priority: normal
severity: normal
status: open
(Continue reading)

Ethan Furman | 17 Apr 10:09 2015

[issue23987] docs about containers membership testing wrong for broken objects


New submission from Ethan Furman:

https://docs.python.org/3/reference/expressions.html#comparisons:
----------------------------------------------------------------
The operators 'in' and 'not in' test for membership. 'x in s' evaluates to true if x is a member of s, and false
otherwise. 'x not in s' returns the negation of 'x in s'. All built-in sequences and set types support this
as well as dictionary, for which 'in' tests whether the dictionary has a given key. For container types
such as list, tuple, set, frozenset, dict, or collections.deque, the expression 'x in y' is equivalent to
'any(x is e or x == e for e in y)'.

StackOverflow question for context: http://stackoverflow.com/q/29692140/208880

Summary:  if a user creates a broken object such that __hash__ returns a random number with every
invocation, then that object will get lost in a dict or set; but the above statement about 'equivalent to'
claims that such an object will still be found.

On the other hand, https://docs.python.org/3/glossary.html#term-hashable says that a constant
return value is required for an object to be hashable (of course, Python can't tell if future calls to
__hash__ will return the same value).

Perhaps a link to the #term-hashable would be appropriate?

----------
messages: 241320
nosy: eric.araujo, ethan.furman, ezio.melotti, georg.brandl
priority: normal
severity: normal
status: open
title: docs about containers membership testing wrong for broken objects
(Continue reading)

wim glenn | 17 Apr 09:22 2015

[issue23986] Inaccuracy about "in" keyword for list and tuple


New submission from wim glenn:

The comparisons section of the python 2 docs says:

--- 

https://docs.python.org/2/reference/expressions.html#comparisons

For the list and tuple types, x in y is true if and only if there exists an index i such that x == y[i] is true.

---

But it's not strictly speaking correct.  Simplest counter-example:

x = float('nan')
y = [x]

The python 3 docs instead mention correct equivalent which is 

any(x is e or x == e for e in y)

----------
assignee: docs <at> python
components: Documentation
messages: 241317
nosy: docs <at> python, wim.glenn
priority: normal
severity: normal
status: open
(Continue reading)

Johan Dahlberg | 17 Apr 08:37 2015

[issue23985] Crash when deleting slices from duplicated bytearray


New submission from Johan Dahlberg:

Python 3.4.3 crashes after some time when running the attached program under Windows 7.

The program appends a fixed bytes "string" to two independent bytearray buffers.
If slices are removed from the beginnging of the two buffers and the two buffers are print:ed, the program
will crash at some random occation.

----------
components: Windows
files: bytearray_bug.py
messages: 241316
nosy: johan, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Crash when deleting slices from duplicated bytearray
type: crash
versions: Python 3.4
Added file: http://bugs.python.org/file39086/bytearray_bug.py

_______________________________________
Python tracker <report <at> bugs.python.org>
<http://bugs.python.org/issue23985>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/python-python-bugs-list%40m.gmane.org

(Continue reading)


Gmane