[issue30095] HTMLCalendar allow custom classes

2017-04-23 Thread Oz Tiram

Oz Tiram added the comment:

@Walter, 

I implemented two possible solutions. Chronologically speaking V2 was 
implemented before V1, but it's a bit über-smart and might surprise it's
users requiring the class attributes to be some kind of iterable.

The first version is my current preferred solution.

I intentionally didn't create a PR for that yet. 

These are the branches:

https://github.com/oz123/cpython/tree/issue30095-v1
https://github.com/oz123/cpython/tree/issue30095-v2

--

___
Python tracker 

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



[issue15718] Possible OverflowError in __len__ method undocumented (when called via len() function)

2017-04-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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



[issue29840] Avoid raising OverflowError in bool()

2017-04-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This was documented in issue15718.

--
resolution:  -> wont fix
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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-23 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-23 Thread Mark Dickinson

Mark Dickinson added the comment:

This is probably worth bringing up on the python-dev or python-ideas mailing 
lists for greater visibility. I can't think of any plausible non-historical 
reason why it makes sense for comparisons to behave one way and arithmetic 
operators another. Altering this might be a PEP-level change, though.

The "Coercion rules" section[1] of the Python 2.7 docs is a bit more explicit 
about the intent:

"""
Exception to the previous item: if the left operand is an instance of a 
built-in type or a new-style class, and the right operand is an instance of a 
proper subclass of that type or class and overrides the base’s __rop__() 
method, the right operand’s __rop__() method is tried before the left operand’s 
__op__() method.
"""

so the check for an override was clearly intentional, rather than an 
implementation convenience or accident. (It's also clearly intentional in the 
source and comments.) The 3.x docs don't have the "and overrides" language; I 
haven't figured out why and when that language changed.


[1] 
https://docs.python.org/release/2.7.6/reference/datamodel.html#coercion-rules

--

___
Python tracker 

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



[issue30141] If you forget to call do_handshake, then everything seems to work but hostname is disabled

2017-04-23 Thread Nathaniel Smith

New submission from Nathaniel Smith:

Basically what it says in the title... if you create an SSL object via 
wrap_socket with do_handshake_on_connect=False, or via wrap_bio, and then 
forget to call do_handshake and just go straight to sending and receiving data, 
then the encrypted connection is successfully established and everything seems 
to work. However, in this mode the hostname is silently *not* checked, so the 
connection is vulnerable to MITM attacks.

(I guess from reading the SSL_read and SSL_write manpages that openssl is just 
silently doing the handshake automatically – very helpfully! – but it's only 
Python's do_handshake code that knows to check the hostname?)

This doesn't affect correctly written programs that follow the documentation 
and either use do_handshake_on_connect=True (the default for wrap_socket) or 
explicitly call do_handshake, so it's not a super-scary bug. But IMHO it 
definitely shouldn't be this easy to silently fail-open.

The attached test script sets up a TLS echo server that has a certificate for 
the host "trio-test-1.example.org" that's signed by a locally trusted CA, and 
then checks:

- connecting to it with do_handshake and expecting the correct hostname: works, 
as expected
- connecting to it with do_handshake and expecting a different hostname: 
correctly raises an error due to the mismatched hostnames
- connecting to it withOUT do_handshake and expecting a different hostname: 
incorrectly succeeds at connecting, sending data, receiving data, etc., without 
any error

and it checks using both ctx.wrap_socket(..., do_handshake_on_connect=False) 
and a little custom socket wrapper class defined using ctx.wrap_bio(...).

I've only marked 3.5 and 3.6 as affected because those are the only versions 
I've tested, but I suspect other versions are affected as well.

--
assignee: christian.heimes
components: SSL
files: ssl-handshake.zip
messages: 292158
nosy: christian.heimes, njs
priority: normal
severity: normal
status: open
title: If you forget to call do_handshake, then everything seems to work but 
hostname is disabled
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file46827/ssl-handshake.zip

___
Python tracker 

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



[issue26143] Ensure that IDLE's stdlib imports are from the stdlib

2017-04-23 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I will make this one of my priority issues once I get up to speed with the new 
workflow.  However, it is not a trivial issue, and I am not sure that all my 
beliefs of a year ago were correct.  What I really do not want to do is break 
IDLE running when users do not make a mistake.

Do you have access to IDLE on any system other than Windows?

--
stage: needs patch -> test needed
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



[issue26143] Ensure that IDLE's stdlib imports are from the stdlib

2017-04-23 Thread Terry J. Reedy

Terry J. Reedy added the comment:

>From the viewpoint of IDLE and masking, the stdlib has three parts: idlelib, 
>other modules that IDLE imports, and other modules that IDLE does not import.  
>As I already noted, this division is different for IDLE and user processes.

IDLE may delay importing some idlelib modules, and I intend to do this more if 
possible.  But I am not going to worry about someone creating an idlelib 
directory with duplicate names.  If someone does this, too bad.

Modules that IDLE does not import are not a concern for the operation of IDLE. 
If a *user* program masks an stdlib module that the program intends to import, 
it is not IDLE's direct concern.

This issue is about other modules that IDLE *does* import -- directly *or* 
indirectly.  IDLE does not import 'random' -- the word does not appear in 
idlelib.  On the other hand, in 3.6.1,
>>> import sys
>>> 'random' in sys.modules
True
For a user random.py to block IDLE startup, it must be that some module that 
imports it accesses some attribute during import, possibly as part of a 'from' 
import.

In order to make new code unit-testable, it should be put in a new 'fix_path' 
function, with a detailed specification.

--

___
Python tracker 

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



[issue30141] If you forget to call do_handshake, then everything seems to work but hostname is disabled

2017-04-23 Thread Christian Heimes

Christian Heimes added the comment:

Sigh, this is the seventh or eight security issue related to Python's hostname 
verification, maybe more. I know for years that Python's current approach is 
buggy and a collection of bad ideas. That's it, I'm going to rip out 
ssl.match_hostname() and let OpenSSL handle all verification internally. I've 
been working on another PEP that features the change for quite some time. I'll 
to finish my SSL PEP before PyCon and language summit. 

Here is a quick proof-of-concept implementation (requires OpenSSL >= 1.0.2 and 
libressl >= 2.5).

https://github.com/tiran/cpython/tree/openssl_check_hostname

--

___
Python tracker 

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



[issue30142] The "callable" fixer doesn't exist

2017-04-23 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The "callable" fixer was removed in dbdf029a5575f6e6ec0140260236963ed7d2c2be, 
but it still is mentioned in the documentation.

https://docs.python.org/3/library/2to3.html#2to3fixer-callable

--
assignee: docs@python
components: 2to3 (2.x to 3.x conversion tool), Documentation
messages: 292162
nosy: benjamin.peterson, docs@python, gregory.p.smith, serhiy.storchaka
priority: normal
severity: normal
status: open
title: The "callable" fixer doesn't exist
versions: Python 2.7, 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



[issue30143] Using collections ABC from collections.abc rather than collections in 2to3 converted code

2017-04-23 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch makes 2to3 generating a code that uses abstract collection 
classes Sequence and Mapping from collections.abc rather than collections. 
Since abstract collection classes now are defined in collections.abc and 
collections contains only aliases for compatibility, this is more idiomatic 
Python 3 code.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 292163
nosy: benjamin.peterson, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Using collections ABC from collections.abc rather than collections in 
2to3 converted code
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



[issue30143] Using collections ABC from collections.abc rather than collections in 2to3 converted code

2017-04-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1375

___
Python tracker 

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



[issue30141] If you forget to call do_handshake, then everything seems to work but hostname checking is disabled

2017-04-23 Thread Nathaniel Smith

Changes by Nathaniel Smith :


--
title: If you forget to call do_handshake, then everything seems to work but 
hostname is disabled -> If you forget to call do_handshake, then everything 
seems to work but hostname checking is disabled

___
Python tracker 

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



[issue30144] Import collections ABC from collections.abc rather than collections

2017-04-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1376

___
Python tracker 

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



[issue30144] Import collections ABC from collections.abc rather than collections

2017-04-23 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Now abstract collection classes are defined in collections.abc rather than 
collections. collections contains just aliases for compatibility. Importing 
collections ABC from collections.abc is more idiomatic. And when aliases will 
be removed from collection this will be the only way.

But some code still imports them from collections. Proposed patch makes it 
importing them from collections.abc.

The most basic modules like locale, weakref and pathlib could import them just 
from _collections_abc for decreasing the startup time, but this is different 
issue.

The patch doesn't touch the collections module itself and its tests, and the 
_decimal module which imports collections.MutableMapping in C code (changing 
this would require more rewriting).

--
components: Library (Lib)
messages: 292164
nosy: rhettinger, serhiy.storchaka, stutzbach
priority: normal
severity: normal
stage: patch review
status: open
title: Import collections ABC from collections.abc rather than collections
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



[issue30144] Import collections ABC from collections.abc rather than collections

2017-04-23 Thread Stefan Krah

Stefan Krah added the comment:

I thought splitting off abc was done for performance reasons (reduce the number 
of imports at Python startup), not for more idiomatic code.

--
nosy: +skrah

___
Python tracker 

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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-23 Thread Eric Wieser

Changes by Eric Wieser :


--
nosy: +Eric.Wieser

___
Python tracker 

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



[issue30144] Import collections ABC from collections.abc rather than collections

2017-04-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If this is the main cause I can replace collections.abc in this patch with 
_collections_abc. But I prefer to do this in separate commit. My next patch 
will include other changes for the number of imports.

--

___
Python tracker 

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



[issue30142] The "callable" fixer doesn't exist

2017-04-23 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
assignee: docs@python -> Mariatta
keywords: +easy
nosy: +Mariatta
stage:  -> needs patch

___
Python tracker 

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



[issue30024] Treat `import a.b.c as m` as `m = sys.modules['a.b.c']`

2017-04-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1377

___
Python tracker 

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



[issue30024] Treat `import a.b.c as m` as `m = sys.modules['a.b.c']`

2017-04-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

PR 1264 implements this idea.

Seems this is a duplicate of issue23203 which contains the same idea.

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



[issue30145] Create a How to or Tutorial documentation for asyncio

2017-04-23 Thread Mariatta Wijaya

New submission from Mariatta Wijaya:

We could use a How To or a tutorial for asyncio in the docs.

--
assignee: docs@python
components: Documentation, asyncio
messages: 292168
nosy: Mariatta, docs@python, yselivanov
priority: normal
severity: normal
status: open
title: Create a How to or Tutorial documentation for asyncio
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



[issue26143] Ensure that IDLE's stdlib imports are from the stdlib

2017-04-23 Thread Matthew Cowles

Matthew Cowles added the comment:

> Do you have access to IDLE on any system other than Windows?

I don't have a Windows machine at all.

For what it's worth, here's the behavior I'm talking about, albeit with an old 
version of Python:

$ mkdir testidle
$ cd testidle 
$ /usr/local/bin/python 
/Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/idlelib/idle.py
 # Works
$ >random.py
$ /usr/local/bin/python 
/Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/idlelib/idle.py
[. . .]
Unhandled server exception!
Thread: SockThread
[. . .]
import tempfile
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", 
line 34, in 
from random import Random as _Random
ImportError: cannot import name Random

*** Unrecoverable, server exiting!

Of course no one starts IDLE from a command line in real life and so a beginner 
gets send down a blind alley with a misleading error message about firewall 
software.

--

___
Python tracker 

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



[issue23404] 'make touch' does not work with git clones of the source repository

2017-04-23 Thread Brett Cannon

Brett Cannon added the comment:

Yep, that's exactly what I was suggesting, Martin (and sorry if I missed you 
saying that earlier; on vacation so trying to keep email/open source time to 
minimum :) .

--

___
Python tracker 

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



[issue30144] Import collections ABC from collections.abc rather than collections

2017-04-23 Thread Raymond Hettinger

Raymond Hettinger added the comment:

+1 This patch looks like a step in the right direction.

--

___
Python tracker 

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



[issue27613] Empty iterator with fake __len__ is rendered as a single bracket ] when using json's iterencode

2017-04-23 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Per PEP-8, the Python preferred-style is, "For sequences, (strings, lists, 
tuples), use the fact that empty sequences are false."

Yes: if not seq:
if seq:

No: if len(seq):
if not len(seq):

The Python libraries are not obliged to defend themselves against non-sensical 
types (i.e. defining an empty iterator as a subclass of list and returning a 
non-zero len).

I recommend leaving the code as-is and closing a "not a bug".  In a way, this 
report is no more interesting than observing that a __hash__ that returns a 
random value on each call doesn't work well in a dictionary.

--

___
Python tracker 

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



[issue27613] Empty iterator with fake __len__ is rendered as a single bracket ] when using json's iterencode

2017-04-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This looks as a strong argument to me. Thanks Raymond.

--
resolution:  -> not a bug
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



[issue29352] provide the authorative source for s[i:j] negative slice indices (<-len(s)) behavior for standard sequences

2017-04-23 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: docs@python -> rhettinger
nosy: +rhettinger

___
Python tracker 

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



[issue29619] st_ino (unsigned long long) is casted to long long in posixmodule.c:_pystat_fromstructstat

2017-04-23 Thread Xavier de Gaye

Xavier de Gaye added the comment:

sizeof(unsigned long long) is 8 on Android x86 and HAVE_LARGEFILE_SUPPORT is 
undefined.
According to msg280053 HAVE_LARGEFILE_SUPPORT is also undefined on Android 
x86_64 (and also on Linux x86_64).

> Maybe the code should be simplified to always use unsigned long long.
Yes. If I understand correcty, one could only use 'unsigned long long' to 
assert at build time and use the smallest of the two unsigned long that fits 
with the size of st->st_ino at runtime.

--

___
Python tracker 

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



[issue30146] Fix for issue 8743 not available in python MacOS 3.6.1

2017-04-23 Thread Horacio Hoyos

New submission from Horacio Hoyos:

Hi, attempt 2.

My system is MacOs Yosemite (10.10.5), I have installed Python 3.6.1 downloaded 
from the official Python website.

I was having issues while testing a custom Set implementation using the 
_collections_abc base MutableSet and found that my issue was apparently 
resolved with issue 8743. From the fix, in the attached script I would expect 
the and operation between my set implementation and a string to fail with a 
TypeError, given that string is not an instance of Set. However, the error is 
not raised, i.e. the print statement is executed. 

>From the discussion on issue 8743, I would expect _collections_abc.py to have 
>a test for Set instances, but is not the case (for example):

def __and__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
return self._from_iterable(value for value in other if value in self)

That is, I was expecting a isinstance(other, Set) somewhere there.

In my previous post I was told my python installation was broken. However, I 
checked the collections_abc.py in my windows system and is the same. I am not 
an expert on the Python build system, but the patch in bug 8743 applies to 
/Lib/_abcoll.py, but I guess _collections_abc.py is generated somehow.

--
components: Library (Lib), macOS
messages: 292175
nosy: Horacio Hoyos, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: Fix for issue 8743 not available in python MacOS 3.6.1
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



[issue25794] __setattr__ does not always overload operators

2017-04-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Eryk, could you create a pull request? Please take into account my and Berker's 
comments on Rietveld.

--

___
Python tracker 

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



[issue30147] change in interface for compiled regex.pattern

2017-04-23 Thread Greg Lindahl

New submission from Greg Lindahl:

The following script runs fine in python 3.6 and recently started failing the 
assertion in 3.7-dev and nightly

import re

r = re.compile(re.escape('/foo'))
print(r)
print(r.pattern)
assert r.pattern.startswith('\\/')

--
components: Regular Expressions
messages: 292177
nosy: ezio.melotti, mrabarnett, wumpus
priority: normal
severity: normal
status: open
title: change in interface for compiled regex.pattern
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



[issue30146] Fix for issue 8743 not available in python MacOS 3.6.1

2017-04-23 Thread R. David Murray

R. David Murray added the comment:

You don't appear to have successfully attached the script.  Can you try again 
please?

The patching in the issue you point to does not patch __and__, it just sets it 
equal to __rand__.

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



[issue30147] change in re.escape output is not docuented in whatsnew

2017-04-23 Thread R. David Murray

R. David Murray added the comment:

re.escape was escaping too much previously, and this has been fixed in 3.7 (and 
only 3.7, because it may cause testing issues such as you have observed).  See 
issue 29995.

A note needs to be added to the 'porting' section of whats new covering this.

--
assignee:  -> docs@python
components: +Documentation -Regular Expressions
nosy: +docs@python, r.david.murray, serhiy.storchaka
stage:  -> needs patch
title: change in interface for compiled regex.pattern -> change in re.escape 
output is not docuented in whatsnew
type:  -> behavior

___
Python tracker 

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



[issue30146] Fix for issue 8743 not available in python MacOS 3.6.1

2017-04-23 Thread Ned Deily

Ned Deily added the comment:

And rather than focusing on what lines of code you believe are missing, please 
provide a complete script or lines of Python code with any instructions on how 
to run them, the actual output you see when you run it, and what you expect the 
output should be.  Otherwise, we just have to guess at what the issue here is 
and we'll probably guess wrong.

--

___
Python tracker 

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



[issue30148] Pathological regex behaviour

2017-04-23 Thread Jussi Pakkanen

New submission from Jussi Pakkanen:

Attached is a script that runs a single regex against one line of text taking 
over 12 seconds.

If you run the exact same regex in Perl it finishes immediately.

The slowness has something to do with spaces. If you replace consecutive spaces 
in the input with one, the evaluation is immediate.

This bug was originally discovered here: 
https://bugzilla.gnome.org/show_bug.cgi?id=781569

--
components: Regular Expressions
files: retest.py
messages: 292181
nosy: ezio.melotti, jpakkane, mrabarnett
priority: normal
severity: normal
status: open
title: Pathological regex behaviour
type: resource usage
Added file: http://bugs.python.org/file46828/retest.py

___
Python tracker 

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



[issue30147] Change in re.escape output is not documented in whatsnew

2017-04-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: change in re.escape output is not docuented in whatsnew -> Change in 
re.escape output is not documented in whatsnew

___
Python tracker 

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



[issue30146] Fix for issue 8743 not available in python MacOS 3.6.1

2017-04-23 Thread Horacio Hoyos

Horacio Hoyos added the comment:

Guess my second attempt didn't work as expected ;-).

I have attached the file now. To run just invoke the script:

$ python3 example.py
s&t did not screen-out general iterables

I would expect to see no output.

--
Added file: http://bugs.python.org/file46829/example.py

___
Python tracker 

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



[issue30148] Pathological regex behaviour

2017-04-23 Thread Matthew Barnett

Matthew Barnett added the comment:

If 'ignores' is '', you get this:

(?:\b(?:extern|G_INLINE_FUNC|%s)\s*)

which can match an empty string, and it's tried repeatedly.

That's inadvisable.

There's also:

(?:\s+|\*)+

which can match whitespace in multiple ways.

That's inadvisable too.

If the pattern really doesn't match the string (and it doesn't!), then it won't 
find out until it has tried _all_ of the possibilities.

Some implementations, such as Perl's, have extra checks to try to reduce the 
problem.

--

___
Python tracker 

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



[issue30149] inspect.signature() doesn't support partialmethod without explicit self parameter

2017-04-23 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

>>> import functools, inspect
>>> class A:
... f = functools.partialmethod((lambda self, x, y, *args: ...), 1)
... 
>>> inspect.signature(A.f)

>>> class A:
... f = functools.partialmethod((lambda *args: ...), 1)
... 
>>> inspect.signature(A.f)
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/inspect.py", line 3007, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/home/serhiy/py/cpython/Lib/inspect.py", line 2757, in from_callable
follow_wrapper_chains=follow_wrapped)
  File "/home/serhiy/py/cpython/Lib/inspect.py", line 2227, in 
_signature_from_callable
return sig.replace(parameters=new_params)
  File "/home/serhiy/py/cpython/Lib/inspect.py", line 2780, in replace
return_annotation=return_annotation)
  File "/home/serhiy/py/cpython/Lib/inspect.py", line 2725, in __init__
raise ValueError(msg)
ValueError: duplicate parameter name: 'args'

--
components: Library (Lib)
messages: 292184
nosy: ncoghlan, rhettinger, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: inspect.signature() doesn't support partialmethod without explicit self 
parameter
type: behavior
versions: 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



[issue27613] Empty iterator with fake __len__ is rendered as a single bracket ] when using json's iterencode

2017-04-23 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Thank you Raymond.  What I missed before is a) the OP's misnamed EmptyIterator 
is an iterable (possibly non-empty) but not an iterator, empty or otherwise, 
and b) a sequence __len__ that lies is just a bug.  (So is a iterator that does 
not yield the contents of a collection.)  A non-0 length(lst) is a promise that 
lst[0] exists.  Depending on this is routine.  If json.encoder line 296, 'for 
value in lst:' were replaced by the following, which should be equivalent,
for i in range(len(list)):
value = lst[i]
the encoding would die with IndexError.

The intention that buggy code should not cause a crash was met in this case.

--

___
Python tracker 

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



[issue30146] Difference in behavior between set() and collections.abc.MutableSet() derived objects

2017-04-23 Thread Ned Deily

Ned Deily added the comment:

OK, thanks for supplying a concrete example.  From it, it's clear that it has 
nothing specific to do with Python on macOS.  Adding Raymond as maintainer of 
sets.

--
components:  -macOS
nosy: +rhettinger -ronaldoussoren
title: Fix for issue 8743 not available in python MacOS 3.6.1 -> Difference in 
behavior between set() and collections.abc.MutableSet() derived objects

___
Python tracker 

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



[issue30150] raw debug allocators to not return malloc alignment

2017-04-23 Thread Julian Taylor

New submission from Julian Taylor:

The debug raw allocator do not return the same alignment as malloc. See  
_PyMem_DebugRawAlloc:
https://github.com/python/cpython/blob/master/Objects/obmalloc.c#L1873

The line
return p + 2*SST

adds 2 * sizeof(size_t) to the pointer returned by malloc.
On for example x32 malloc returns 16 byte aligned memory but size_t is 4 bytes.
This makes all memory returned by the debug allocators not aligned the what the 
system assumes on such platforms.

--
components: Interpreter Core
messages: 292187
nosy: jtaylor
priority: normal
severity: normal
status: open
title: raw debug allocators to not return malloc alignment
versions: Python 2.7, 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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-23 Thread Stephan Hoyer

Stephan Hoyer added the comment:

Posted to python-ideas:
https://mail.python.org/pipermail/python-ideas/2017-April/045451.html

Mark -- just out of curiosity, could you point me to where this logic is 
implemented in CPython's source?

This feels like something that could once been called a bug but that by now may 
have become a feature, by virtue of how long it's lasted out in the world.

--

___
Python tracker 

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



[issue30140] Binary arithmetic does not always call subclasses first

2017-04-23 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 26896f2832324dde85cdd63d525571ca669f6f0b by Mariatta (csabella) 
in branch 'master':
bpo-29751: Improve PyLong_FromString documentation (GH-915)
https://github.com/python/cpython/commit/26896f2832324dde85cdd63d525571ca669f6f0b


--
nosy: +Mariatta

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
stage: patch review -> backport needed

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1379

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1378

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
pull_requests: +1380

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset d51d093b9bbca108f59bad0f1730c48ebf5b2e14 by Mariatta in branch 
'3.5':
[3.5] bpo-29751: Improve PyLong_FromString documentation (GH-915) (#1267)
https://github.com/python/cpython/commit/d51d093b9bbca108f59bad0f1730c48ebf5b2e14


--

___
Python tracker 

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



[issue30146] Difference in behavior between set() and collections.abc.MutableSet() derived objects

2017-04-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset ea0efa3bc1d0b832da75519c6f85d767ae44feda by Mariatta in branch 
'3.6':
[3.6] bpo-29751: Improve PyLong_FromString documentation (GH-915) (#1266)
https://github.com/python/cpython/commit/ea0efa3bc1d0b832da75519c6f85d767ae44feda


--

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 9eb5ca0774f94215be48442100c829db2484e146 by Mariatta in branch 
'master':
bpo-29751: add Cheryl Sabella to Misc/ACKS (GH-1268)
https://github.com/python/cpython/commit/9eb5ca0774f94215be48442100c829db2484e146


--

___
Python tracker 

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



[issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

2017-04-23 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

I merged the PR, backported it to 3.5 and 3.6, and added Cheryl to Misc/ACKS.

Thanks everyone :)

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



[issue30100] WeakSet should allow discard and remove on items that can't have weak references

2017-04-23 Thread donkopotamus

Changes by donkopotamus :


--
title: WeakSet should all discard and remove on items that can have weak 
references -> WeakSet should allow discard and remove on items that can't have 
weak references

___
Python tracker 

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



[issue23404] 'make touch' does not work with git clones of the source repository

2017-04-23 Thread Nick Coghlan

Nick Coghlan added the comment:

As Martin notes, my concern is that I can go for years without having to touch 
the low level files (since syntax changes are rare), so it's important to me to 
make it easy to remember and/or relearn how to regenerate them.

However, suitable make commands (e.g. a "make regen" target, with "make 
regen-X" subtargets) would qualify as "easy to remember", and would also be 
amenable to automated testing in combination with a `make clobber-gen` command.

(Tangent on target naming: I think 'rebuild' would be confusing, while 
'regenerate' is a bit long, especially if there are more specific subtargets. 
'regen' is just a shortened version of the latter)

--

___
Python tracker 

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



[issue30144] Import collections ABC from collections.abc rather than collections

2017-04-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 2e576f5aec1f8f23f07001e2eb3db9276851a4fc by Serhiy Storchaka in 
branch 'master':
bpo-30144: Import collections ABC from collections.abc rather than collections. 
(#1263)
https://github.com/python/cpython/commit/2e576f5aec1f8f23f07001e2eb3db9276851a4fc


--

___
Python tracker 

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



[issue30151] Race condition in use of _PyOS_SigintEvent on windows

2017-04-23 Thread Nathaniel Smith

New submission from Nathaniel Smith:

As pointed out in this stackoverflow answer: 
http://stackoverflow.com/a/43578450/
and since I seem to be collecting signal-handling bugs these days :-), there's 
a race condition in how the interpreter uses _PyOS_SigintEvent to allow 
control-C to break out of functions like time.sleep on Windows. Suppose we have 
a call to time.sleep(), and the user hits control-C while it's running.

What's supposed to happen is:

- the windows implementation of pysleep in Modules/timemodule.c does 
ResetEvent(hInterruptEvent)
- then it blocks waiting for the interrupt event to be set *or* the timeout to 
expire
- the C-level signal handler runs in a new thread, which sets the "hey a signal 
arrived" flag and then sets the event
- the main thread wakes up because the event is set, and runs 
PyErr_CheckSignals()
- this notices that that the signal has arrived and runs the Python-level 
handler, all is good

But what can happen instead is:

- before doing CALL_FUNCTION, the eval loop checks to see if any signals have 
arrived. They haven't.
- then the C implementation of time.sleep starts executing.
- then a signal arrives; the signal handler sets the flag and sets the event
- then the main thread clears the event again
- then it blocks waiting for the event to be set or the timeout to expire. But 
the C-level signal handler's already done and gone, so we don't realize that 
the flag is set and we should wake up and run the Python-level signal handler.

The solution is that immediately *after* calling 
ResetEvent(_PyOS_SigintEvent()) but *before* sleeping, we should call 
PyErr_CheckSignals(). This catches any signals that arrived before we called 
ResetEvent, and any signals that arrive after that will cause the event to 
become set and wake us up, so that eliminates the race condition.

This same race-y pattern seems to apply to appear in Modules/timemodule.c, 
Modules/_multiprocessing/semaphore.c, and Modules/_winapi.c. _winapi.c also 
handles the event in a weird way that doesn't make sense to me – if the user 
hits control-C it raises an OSError instead of running the signal handler? OTOH 
I *think* Modules/_io/winconsoleio.c already handles the race condition 
correctly, and I don't dare make a guess about whatever Parser/myreadline.c is 
doing.

--
components: Interpreter Core
messages: 292196
nosy: njs
priority: normal
severity: normal
status: open
title: Race condition in use of _PyOS_SigintEvent on windows
versions: 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



[issue30151] Race condition in use of _PyOS_SigintEvent on windows

2017-04-23 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Oh, I should also say that this isn't actually affecting me, I just figured 
that once I was aware of the bug it was worth making a record here. Might be a 
good starter bug for someone trying to get into CPython's internals :-)

--

___
Python tracker 

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