[issue22852] urllib.parse wrongly strips empty #fragment

2014-11-13 Thread Stian Soiland-Reyes

Stian Soiland-Reyes added the comment:

I tried to make a patch for this, but I found it quite hard as the 
urllib/parse.py is fairly low-level, e.g. it is constantly encoding/decoding 
bytes and strings within each URI component. Basically the code assumes there 
are tuples of strings, with support for both bytes and strings baked in later.

As you see in 

https://github.com/stain/cpython/compare/issue-2285-urllib-empty-fragment?expand=1

the patch in parse.py is small - but the effect of that in test_urlparse.py is 
a bit bigger, as lots of test are testing for the result of urlsplit to have '' 
instead of None. It is uncertain how much real-life client code also check for 
'' directly. ("if not p.fragment" would of course still work - but "if 
p.fragment == ''" would not work anymore.

I therefore suggest an alternative to my patch above - to add some boolean 
fields like has_fragment, thus the existing component fields can keep their 
backwards compatible '' and b'' values even when a component is actually 
missing, and yet allowing geturl() to reconstitute the URI according to the RFC.

--
hgrepos: +279

___
Python tracker 

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



[issue22431] Change format of test runner output

2014-11-13 Thread Robert Collins

Robert Collins added the comment:

Yes, making customising the output easier is a good thing. One way is to use 
e.g. subunit.run (which can work with all unittest versions since 2.6) and 
write a custom filter. Or a custom TestResult and TextTestRunner can work too :)

--

___
Python tracker 

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



[issue22858] unittest.__init__:main shadows unittest.main

2014-11-13 Thread Robert Collins

New submission from Robert Collins:

This is just an ugly/hygiene thing. Since we've never advertised the submodules 
as the API, we should be able to fix this by moving main.py to e.g. __main__.py.

--
messages: 231101
nosy: rbcollins
priority: normal
severity: normal
status: open
title: unittest.__init__:main shadows unittest.main

___
Python tracker 

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



[issue22858] unittest.__init__:main shadows unittest.main

2014-11-13 Thread Robert Collins

Changes by Robert Collins :


--
components: +Library (Lib)
type:  -> behavior
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



[issue22859] unittest.TestProgram.usageExit no longer invoked

2014-11-13 Thread Robert Collins

New submission from Robert Collins:

Before the argparse migration usageExit was invoked and could be extended via 
subclasses, but it no longer is. We could delete it (and document it being no 
longer accessible) or put some glue in to reinstate it. I think deleting it is 
fine, as long as we make the argparse parser objects part of the API (so that 
folk have a reliable place to poke at to change help).

--
messages: 231102
nosy: rbcollins
priority: normal
severity: normal
status: open
title: unittest.TestProgram.usageExit no longer invoked

___
Python tracker 

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



[issue22859] unittest.TestProgram.usageExit no longer invoked

2014-11-13 Thread Robert Collins

Changes by Robert Collins :


--
components: +Library (Lib)
type:  -> behavior
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



[issue22860] unittest TestProgram hard to extend

2014-11-13 Thread Robert Collins

New submission from Robert Collins:

Some users of TestProgram would like to add options (e.g. testtools.run adds 
--list and --load-list) but there isn't a clean point to add them without bulk 
copying the implementation around.

We likely need some extra extension points as well - one reasonable test would 
be to make sure that testtools.run's TestProgram can be made much smaller by 
whatever patch fixes this bug.

--
components: Library (Lib)
messages: 231103
nosy: rbcollins
priority: normal
severity: normal
status: open
title: unittest TestProgram hard to extend
type: enhancement
versions: Python 3.5

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which is closer to current code but solves complexity issue and 
also fixes some bugs in current code.

$ ./python -c "import textwrap; print(textwrap.wrap('this-is-a-useful-feature', 
width=1, break_long_words=False))"
['this-', 'is-a', '-useful-', 'feature']
$ ./python -c "import textwrap; print(textwrap.wrap('what-d\x27you-call-it.', 
width=1, break_long_words=False))"
['what-d', "'you-", 'call-', 'it.']

--
versions: +Python 2.7, Python 3.4
Added file: http://bugs.python.org/file37188/wordsplit.patch

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Georg Brandl

Georg Brandl added the comment:

LGTM.

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't understand:

+expect = ("this-|is-a-useful-|feature-|for-|"
+  "reformatting-|posts-|from-|tim-|peters'ly").split('|')
+self.check_wrap(text, 1, expect, break_long_words=False)
+self.check_split(text, expect)

Why would "is-a-useful" remain unsplit? It looks like you're making up new 
rules.

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
versions:  -Python 2.7, Python 3.4

___
Python tracker 

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



[issue22860] unittest TestProgram hard to extend

2014-11-13 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +pitrou

___
Python tracker 

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



[issue22860] unittest TestProgram hard to extend

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

For another example use case:
https://github.com/numba/numba/blob/master/numba/tests/__init__.py#L22

--

___
Python tracker 

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



[issue22861] [2.7] ssl._dnsname_match() and unicode

2014-11-13 Thread STINNER Victor

New submission from STINNER Victor:

Hi,

I just modified the Trollius project ( http://trollius.readthedocs.org/ ) to 
support Python 2.7 with the newly backported ssl module. I ran the test suite 
of the Trollius and some tests are failing because of the exact exception 
message.

It looks like ssl._dnsname_match() calls repr() on a Unicode string:

elif len(dnsnames) == 1:
raise CertificateError("hostname %r "
"doesn't match %r"
% (hostname, dnsnames[0]))

Well, I don't know if using repr() on an unicode string is really a bug or not.

By the way, Trollius currently pass the hostname as a bytes string, whereas 
match_hostname() uses Unicode. No error is raised. Is it safe to compare bytes 
and Unicode to validate a certificate?

dnsname[0] comes from the commonName of the certificate subject.

The certificate used in Trollius test can be found at:
https://bitbucket.org/enovance/trollius/src/d456dd5103b0e2a35ef27fe0d55583b74a8196dd/tests/keycert3.pem?at=trollius

Example of error:

==
FAIL: test_create_server_ssl_match_failed (test_events.EPollEventLoopTests)
--
Traceback (most recent call last):
  File "tests/test_events.py", line 951, in test_create_server_ssl_match_failed
self.loop.run_until_complete(f_c)
  File "/home/haypo/prog/HG/trollius/trollius/test_utils.py", line 137, in 
__exit__
expected_regex.pattern, str(exc_value)))
  File "/home/haypo/prog/HG/trollius/trollius/test_utils.py", line 75, in 
_raiseFailure
raise self.test_case.failureException(msg)
AssertionError: "hostname '127.0.0.1' doesn't match 'localhost'" does not match 
"hostname '127.0.0.1' doesn't match u'localhost'"

--
messages: 231108
nosy: alex, haypo
priority: normal
severity: normal
status: open
title: [2.7] ssl._dnsname_match() and unicode
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



[issue22861] [2.7] ssl._dnsname_match() and unicode

2014-11-13 Thread STINNER Victor

STINNER Victor added the comment:

I worked around this issue by expecting a different error message on Python 2 
and Python 3:
https://bitbucket.org/enovance/trollius/commits/be404685d3fd8ba008e1a577438dc6f23b01c63a?at=trollius

+if compat.PY3:
+err_msg = "hostname '127.0.0.1' doesn't match 'localhost'"
+else:
+# http://bugs.python.org/issue22861
+err_msg = "hostname '127.0.0.1' doesn't match u'localhost'"

--

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread Florian Höch

New submission from Florian Höch:

If 'top' is an unicode directory name, os.listdir can still return non-unicode 
filenames if they can't be decoded. This case is not handled in the Python 2.x 
standard library version of os.walk and will cause join(top, name) to fail on 
such filenames with an UnicodeDecodeError.

--
components: Library (Lib)
messages: 231110
nosy: fhoech
priority: normal
severity: normal
status: open
title: os.walk fails on undecodable filenames
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread STINNER Victor

STINNER Victor added the comment:

What is your OS?

--
components: +Unicode
nosy: +ezio.melotti, haypo

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread Florian Höch

Florian Höch added the comment:

This problem only affects Linux as far as I know (in my case I'm using Fedora 
21 Beta).

--

___
Python tracker 

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



[issue22863] https://docs.python.org/ should make a true 2.7.8 version available

2014-11-13 Thread Marc-Andre Lemburg

New submission from Marc-Andre Lemburg:

The documentation shown for Python 2.7.8 currently includes 2.7.9 parts, e.g. 
for the ssl modules (https://docs.python.org/2.7/library/ssl.html).

Since there were so many changes to the ssl module for 2.7.9 which are not 
available in 2.7.8, I think it would be good to be able to not only select 
"2.7.8" from the doc version drop-down, but to also really get that particular 
version of the documentation, and provide a separate "2.7.9" snapshop as well.

I tried https://docs.python.org/2.7.8/library/ssl.html, but that doesn't seem 
to exist.

PS: I'm not sure whether this is the right tracker to report this. Feel free to 
move it elsewhere.

--
assignee: docs@python
components: Documentation
messages: 231113
nosy: docs@python, lemburg
priority: normal
severity: normal
status: open
title: https://docs.python.org/ should make a true 2.7.8 version available
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



[issue22863] https://docs.python.org/ should make a true 2.7.8 version available

2014-11-13 Thread Benjamin Peterson

Benjamin Peterson added the comment:

There's https://docs.python.org/release/2.7.8/

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread STINNER Victor

STINNER Victor added the comment:

Your problem has two solutions.

1) Upgrade to Python 3 which handles correctly your use case (thanks to the PEP 
383, surrogateescape error handler)

2) Only process filenames as bytes, and encode/decode manually (so you can 
decide how to handle undecodable filenames)

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is old rule. \w{2,}-(?=\w{2,} -- single letter shouldn't be separated. But 
there was a bug in such simple regex, it splits a word after non-word character 
(in particular apostrophe or hyphen) if it followed by word characters and 
hyphen. There were attempts to fix this bug in issue596434 and issue965425 but 
they missed a cases when non-word character is occurred inside a word.

Originally I had assigned this issue only to 3.5 because I supposed that the 
solution needs either new features in re or backward-incompatible changes to 
word splitting algorithm. But found solution doesn't require 3.5-only features, 
doesn't change interface, and fixes performance and behavior bugs. So I think 
it should be applied to maintained releases too.

--

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread Florian Höch

Florian Höch added the comment:

1) Is not yet possible for me unfortunately, some libraries I require are not 
yet available for Python 3 (but in the long run, this would be my preferred 
solution)

2) Would necessitate too many changes in a carefully crafted, unicode-only 
application. I think I'll just override os.listdir and filter out filenames 
that are not decodable, or override os.walk and do something equivalent.

--

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread STINNER Victor

STINNER Victor added the comment:

> 1) Is not yet possible for me unfortunately, some libraries I require are not 
> yet available for Python 3 (but in the long run, this would be my preferred 
> solution)

I'm curious, which libraries?

Oh, I forgot to say that it's not possible to fix this issue in Python 2. 
Backporting the PEP 383 in Python 2 requires deep changes in the Unicode 
machinery, starting by the UTF-8 codec. Currently, the UTF-8 encoder encodes 
surrogates which violates Unicode standard and makes impossible to use this 
codec with the surrogateescape error handler.

--

___
Python tracker 

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



[issue22858] unittest.__init__:main shadows unittest.main

2014-11-13 Thread R. David Murray

R. David Murray added the comment:

I'm afraid that just because we don't advertise it doesn't mean it isn't used.  
On the other hand, the split into submodules is relatively recent, so maybe we 
could get away with it without a deprecation cycle.  I'd like other developers 
opinions on that.

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread R. David Murray

Changes by R. David Murray :


--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue22862] os.walk fails on undecodable filenames

2014-11-13 Thread Florian Höch

Florian Höch added the comment:

> I'm curious, which libraries?

wxPython and wexpect (wexpect I could probably port myself, so the problem is 
mainly with wx)

> Oh, I forgot to say that it's not possible to fix this issue in Python 2. 
> Backporting the PEP 383 in Python 2 requires deep changes in the Unicode 
> machinery, starting by the UTF-8 codec.

Ok, that's understandable of course.

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> This is old rule. \w{2,}-(?=\w{2,} -- single letter shouldn't be separated.

I don't agree. This was an implementation detail. There was no test, and it 
wasn't specified anywhere.
If you think single letter shouldn't be separated, there should be some 
grammatical or typographical reference on the Internet to prove it.

> There were attempts to fix this bug in issue596434 and issue965425 

Those don't seem related to single letters between hyphens.

> But found solution doesn't require 3.5-only features, doesn't change 
> interface, and fixes performance and behavior bugs.

It does change behaviour in ways that could break existing code. The textwrap 
behaviour is underspecified so it's not ok to assume that previous behaviour 
was obviously buggy.

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread R. David Murray

R. David Murray added the comment:

https://owl.english.purdue.edu/owl/resource/576/01/

Rule 8.

So, no, in the middle of the word single letters aren't a problem, only at the 
beginning or the end of the word.

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



[issue22600] In Multiprocessing Queue() doesn't work with list : __.put(list) != __.get()

2014-11-13 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

"solution.put(c)" takes a *reference* to the list c.
And then the test() function continues running!

By the time the list is serialized and sent back to the main process (in 
another thread), the test() function has already changed it...

As you noticed, you can use immutable objects instead (string, int), or make a 
copy of the list: solution.put(c.copy())

--
nosy: +amaury.forgeotdarc
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue22864] Add filter to multiprocessing.Pool

2014-11-13 Thread Mike Drob

New submission from Mike Drob:

Being able to use a pool to easily run 'map' over an iterable is very powerful, 
but it would also be nice to run 'filter' (or potentially 'ifilter' or 
'filter_async', in keeping with the patterns already present).

--
components: Library (Lib)
messages: 231124
nosy: Mike.Drob
priority: normal
severity: normal
status: open
title: Add filter to multiprocessing.Pool
type: enhancement
versions: Python 2.7, Python 3.6

___
Python tracker 

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



[issue22462] Modules/pyexpat.c violates PEP 384

2014-11-13 Thread Matthias Klose

Matthias Klose added the comment:

according to  https://jenkins.qa.ubuntu.com/job/vivid-adt-python3.4/7/

test.test_pyexpat.HandlerExceptionTest now fails, but only when running in the 
installed location, not when running the tests from the builddir. any idea why?

--
nosy: +doko

___
Python tracker 

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



[issue22865] Allow pty.spawn to ignore data to copy

2014-11-13 Thread Geoff Shannon

New submission from Geoff Shannon:

While using the pty.py module I had cause to want to be able to silently eat 
characters from the input stream.  I discovered that because of the check for 
end of file being "if not data" that there was no way to do this.

Since the default function used by spawn and _copy is a thin wrapper on 
os.read, I figured that it would be useful to interpret None as a sentinel 
value meaning "this is not EOF, but there's nothing I actually want to copy 
over."

--
assignee: docs@python
components: Documentation, Library (Lib)
files: pty.patch
keywords: patch
messages: 231126
nosy: RadicalZephyr, docs@python
priority: normal
severity: normal
status: open
title: Allow pty.spawn to ignore data to copy
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file37189/pty.patch

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you David. If splitting single letter surrounded with hyphens is 
desirable, here is more complicated patch which does this. It deviates from 
original code more, but it doesn't look break any reasonable example.

> The textwrap behaviour is underspecified so it's not ok to assume that 
> previous behaviour was obviously buggy.

Aren't ['this-', 'is-a', '-useful-', 'feature'] and ['what-d', "'you-", 
'call-', 'it.'] obvious bugs?

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Added file: http://bugs.python.org/file37190/wordsplit_2.patch

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

To clarify, I would be fine with the previous patch if it didn't add the tests.

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> Aren't ['this-', 'is-a', '-useful-', 'feature'] and
> ['what-d', "'you-", 'call-', 'it.'] obvious bugs?

Obvious according to which rules?

If we want to improve the behaviour of textwrap, IMHO it should be in a 
separate issue. And someone would have to study the word-wrapping rules of the 
English language :-)

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread R. David Murray

R. David Murray added the comment:

What I usually do in cases like this is to add the tests but mark them with 
comments saying that the tests test current behavior but are not testing parts 
of the (currently defined) API.  That way you know if a change changes behavior 
and then can decide if that is a problem or not, as opposed to inadvertently 
changing behavior and only finding out when the bug reports roll in :)

But yeah, defining the rules textwrap should follow is a different issue than 
the performance issue.

--

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> To clarify, I would be fine with the previous patch if it didn't add the 
> tests.

The absent of tests could cause introducing new non-detected bugs and 
reappearing old bugs.

> Obvious according to which rules?

If you think a word should be splitted before hyphen or apostrophe, there 
should be some grammatical or typographical reference on the Internet to prove 
it.

I would be fine with moving the fix of textwrap behavior to a separate issue, 
but what to do with this issue then? We have not a patch which only fixes 
performance complexity and doesn't change the behavior.

--

___
Python tracker 

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



[issue14099] ZipFile.open() should not reopen the underlying file

2014-11-13 Thread David Wilson

David Wilson added the comment:

Per my comment on issue16569, the overhead of performing one seek before each 
(raw file data) read is quite minimal. I have attached a new (but incomplete) 
patch, on which the following microbenchmarks are based. The patch is 
essentially identical to Stepan's 2012 patch, except I haven't yet decided how 
best to preserve the semantics of ZipFile.close().

"my.zip" is the same my.zip from issue22842. It contains 10,000 files each 
containing 10 bytes over 2 lines.

"my2.zip" contains 8,000 files each containing the same copy of 64kb of 
/dev/urandom output. The resulting ZIP is 500mb.

For each test, the first run is the existing zipfile module, and the second run 
is with the patch. In summary:

* There is a 35% perf increase in str mode when handling many small files (on 
OS X at least)
* There is a 6% perf decrease in file mode when handling small sequential reads.
* There is a 2.4% perf decrease in file mode when handling large sequential 
reads.


>From my reading of zipfile.py, it is clear there are _many_ ways to improve 
>its performance (probably starting with readline()), and rejection of a 
>functional fix should almost certainly be at the bottom of that list.


For each of the tests below, the functions used were:

def a():
"""
Test concurrent line reads to a str mode ZipFile.
"""
zf = zipfile.ZipFile('my2.zip')
members = [zf.open(n) for n in zf.namelist()]
for m in members:
m.readline()
for m in members:
m.readline()

def c():
"""
Test sequential small reads to a str mode ZipFile.
"""
zf = zipfile.ZipFile('my2.zip')
for name in zf.namelist():
with zf.open(name) as zfp:
zfp.read(1000)

def d():
"""
Test sequential small reads to a file mode ZipFile.
"""
fp = open('my2.zip', 'rb')
zf = zipfile.ZipFile(fp)
for name in zf.namelist():
with zf.open(name) as zfp:
zfp.read(1000)

def e():
"""
Test sequential large reads to a file mode ZipFile.
"""
fp = open('my2.zip', 'rb')
zf = zipfile.ZipFile(fp)
for name in zf.namelist():
with zf.open(name) as zfp:
zfp.read()


 my.zip 

$ python3.4 -m timeit -s 'import my' 'my.a()'
10 loops, best of 3: 1.47 sec per loop

$ python3.4 -m timeit -s 'import my' 'my.a()'
10 loops, best of 3: 950 msec per loop

---

$ python3.4 -m timeit -s 'import my' 'my.c()'
10 loops, best of 3: 1.3 sec per loop

$ python3.4 -m timeit -s 'import my' 'my.c()'
10 loops, best of 3: 865 msec per loop

---

$ python3.4 -m timeit -s 'import my' 'my.d()'
10 loops, best of 3: 800 msec per loop

$ python3.4 -m timeit -s 'import my' 'my.d()'
10 loops, best of 3: 851 msec per loop


 my2.zip 

$ python3.4 -m timeit -s 'import my' 'my.a()'
10 loops, best of 3: 1.46 sec per loop

$ python3.4 -m timeit -s 'import my' 'my.a()'
10 loops, best of 3: 1.16 sec per loop

---

$ python3.4 -m timeit -s 'import my' 'my.c()'
10 loops, best of 3: 1.13 sec per loop

$ python3.4 -m timeit -s 'import my' 'my.c()'
10 loops, best of 3: 892 msec per loop

---

$ python3.4 -m timeit -s 'import my' 'my.d()'
10 loops, best of 3: 842 msec per loop

$ python3.4 -m timeit -s 'import my' 'my.d()'
10 loops, best of 3: 882 msec per loop

---

$ python3.4 -m timeit -s 'import my' 'my.e()'
10 loops, best of 3: 1.65 sec per loop

$ python3.4 -m timeit -s 'import my' 'my.e()'
10 loops, best of 3: 1.69 sec per loop

--
nosy: +dw
Added file: http://bugs.python.org/file37191/zipfile_concurrent_read_1.diff

___
Python tracker 

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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread Marc-Andre Lemburg

New submission from Marc-Andre Lemburg:

With the backport of the Python 3 ssl module, the default context options of 
the ssl module were changed.

While this provides better security in many cases, it also causes breakage with 
servers or clients which do not support TLSv1 and later.

The ssl module should provide a way to globally set the default context options 
to work around this to allow e.g. removing the OP_NO_SSLv3 option in order to 
get things to work again without having to change the application using the ssl 
module.

--
components: Library (Lib)
messages: 231133
nosy: lemburg
priority: normal
severity: normal
status: open
title: ssl module in 2.7.9 should provide a way to configure default context 
options
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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread R. David Murray

R. David Murray added the comment:

As I recall it, this was discussed extensively on the python-dev mailing list.  
Ideally someone should summarize that discussion here.

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



[issue22867] document behavior of calling atexit.register() while atexit._run_exitfuncs is running

2014-11-13 Thread Skip Montanaro

New submission from Skip Montanaro:

A discussion on comp.lang.python about prettying up the "if __name__ == 
'main__'" idiom led to a suggestion that a decorator could simple register the 
main function using atexit.register. That looks like it will work, but leaves 
open the possibility that while main() is running via atexit._run_exitfuncs, 
other exit functions might be registered.

As currently defined (at least in the Python version with 2.7), I think 
everything will work fine. Still, the behavior of adding new exit functions 
during exit is not defined. Would be kind of nice if this behavior was blessed, 
and then mentioned in the documentation.

--
assignee: docs@python
components: Documentation
messages: 231135
nosy: docs@python, skip.montanaro
priority: low
severity: normal
status: open
title: document behavior of calling atexit.register() while 
atexit._run_exitfuncs is running

___
Python tracker 

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



[issue22867] document behavior of calling atexit.register() while atexit._run_exitfuncs is running

2014-11-13 Thread Ethan Furman

Changes by Ethan Furman :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Per http://legacy.python.org/dev/peps/pep-0476/#opting-out the only way to do 
these things is horrednously ugly because it's hardly (if ever) a good idea.

--
nosy: +alex, benjamin.peterson

___
Python tracker 

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



[issue2636] Adding a new regex module (compatible with re)

2014-11-13 Thread Mateon1

Mateon1 added the comment:

Well, I found a bug with this module, on Python 2.7(.5), on Windows 7 64-bit 
when you try to compile a regex with the flags V1|DEBUG, the module crashes as 
if it wanted to call a builtin called "ascii".

The bug happened to me several times, but this is the regexp when the last one 
happened. http://paste.ubuntu.com/8993680/

I hope it's fixed, I really love the module and found it very useful to have 
PCRE regexes in Python.

--
nosy: +Mateon1
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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 13.11.2014 22:03, Benjamin Peterson wrote:
> 
> Benjamin Peterson added the comment:
> 
> Per http://legacy.python.org/dev/peps/pep-0476/#opting-out the only way to do 
> these things is horrednously ugly because it's hardly (if ever) a good idea.

The point here is not about verification, it's about being able
to allow SSLv3 connections again, which the 2.7.9 version of the
ssl module disallows completely.

There are plenty devices and applications out there which don't
talk TLS and we're cutting these off without a good way to
re-enable Python 2.7 applications talk to these again.

The problem here is that Python 2's ssl module has never had a
way to access the SSL context directly, so the only way to work
around security risks of e.g. using SSLv2 for connections was
to either use SSLv3 (only) or TLSv1 (only).

This is due to the fact that OpenSSL doesn't allow you to specify
SSLv3 and later. You have to pin down the version or set up
a range that starts at SSLv2 and then disable protocols using
context options (which Python 2 has so far never exposed).

More conservative Python applications will have chosen SSLv3 as
a way to disable the broken SSLv2 support. I know that we did
in one of our applications.

Fortunately, the _ssl module itself doesn't have OP_NO_SSLv3
enabled per default, so custom protocol implementations are
probably not affected. Only the stdlib uses of SSL are.

--

___
Python tracker 

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



[issue22858] unittest.__init__:main shadows unittest.main

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Numba subclasses unittest.main in order to add custom CLI options.
I agree the current unittest scheme is horrible, just we should find a way 
that's backwards-compatible.

--
nosy: +pitrou

___
Python tracker 

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



[issue22864] Add filter to multiprocessing.Pool

2014-11-13 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +sbt

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-13 Thread koobs

koobs added the comment:

Builds failing on koobs-freebsd9 buildbot for:

3.x: since revision b2c17681404f80edae2ee4846db701104d942cc4
3.4: since revision 246c9570a75798a4757001620cf92cc8d2eba684

Attaching both initial build failure test logs.

--
nosy: +koobs
Added file: 
http://bugs.python.org/file37192/koobs-freebsd9.python3x-build2357.log

___
Python tracker 

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



[issue2636] Adding a new regex module (compatible with re)

2014-11-13 Thread Matthew Barnett

Matthew Barnett added the comment:

@Mateon1: "I hope it's fixed"? Did you report it?

--

___
Python tracker 

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



[issue22823] Use set literals instead of creating a set from a list

2014-11-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Serhiy, go ahead and apply the clinic.py patch. Can you also make a separate 
mock patch and assign it to Michael Foord for review?

--
assignee: larry -> serhiy.storchaka

___
Python tracker 

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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread Benjamin Peterson

Benjamin Peterson added the comment:

But you can reenable SSLv3 by alerting the context and monkeypatching as 
described in the PEP.

--

___
Python tracker 

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



[issue19777] Provide a home() classmethod on Path objects

2014-11-13 Thread Martin Panter

Changes by Martin Panter :


--
nosy: +vadmium

___
Python tracker 

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2014-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> What I usually do in cases like this is to add the tests but mark
> them with comments saying that the tests test current behavior but
> are not testing parts of the (currently defined) API.  That way
> you know if a change changes behavior and then can decide if that is
> a problem or not, as opposed to inadvertently changing behavior
> and only finding out when the bug reports roll in :)

That's a good idea!

--

___
Python tracker 

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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 14.11.2014 01:29, Benjamin Peterson wrote:
> 
> But you can reenable SSLv3 by alerting the context and monkeypatching as 
> described in the PEP.

Well, I can monkeypatch the ssl module of course, but that's
not really the point here. I'm not talking about whether I can fix this
for myself or not.

The point here is that PEP 476 only addresses certificate validation, not
disabling of SSLv3 support.

AFAIK, there has been no discussion about this removal on python-dev or
in a PEP. The only place I found some discussion was on
http://bugs.python.org/issue22638, but that's targeting Python 3.5, not
a patch level release of Python or existing software.

Also note that all of the browsers mentioned in that ticket discussion
only disable the feature, but keep an option to reenable it. As it
stands, there's no simple option to do this for the ssl default
context short of monkeypatching ssl.OP_NO_SSLv3 = 0.

It would be better to add e.g. a global to the ssl module, so that
you can override the default context options easily and without
having to monkeypatch anything:

ssl.py:
DEFAULT_CONTEXT_OPTIONS = OP_NO_SSLv2 | OP_NO_SSLv3 | ...

myapp.py:
import ssl
# Reenable SSLv3 for myapp:
ssl.DEFAULT_CONTEXT_OPTIONS = ssl.DEFAULT_CONTEXT_OPTIONS & ~ssl.OP_NO_SSLv3

--

___
Python tracker 

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



[issue22866] ssl module in 2.7.9 should provide a way to configure default context options

2014-11-13 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Hmm, since neither create_default_context() nor _create_stdlib_context() are 
used by any other stdlib modules, I guess the removal of SSLv3 doesn't really 
make much difference for existing Python 2.7 applications.

I was irritated by the function names implying that they are actually used in 
the Python 2.7 stdlib, which is not the case.

If they ever get used, having a way to change their defaults would be a good 
idea, though.

--
status: open -> closed

___
Python tracker 

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



[issue992389] attribute error due to circular import

2014-11-13 Thread Nick Coghlan

Nick Coghlan added the comment:

Belatedly agreeing with PJE on this one.

If concerns around circular imports continue to be raised in a post Python 3.5 
world (with the issue 17636 change), then we can look at revisiting this again, 
but in the meantime, lets just go with the sys.modules fallback.

--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue992389] attribute error due to circular import

2014-11-13 Thread Nick Coghlan

Changes by Nick Coghlan :


--
superseder:  -> Modify IMPORT_FROM to fallback on sys.modules

___
Python tracker 

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



[issue17293] uuid.getnode() MAC address on AIX

2014-11-13 Thread koobs

koobs added the comment:

koobs-freebsd10 buildbot broken on all branches since:

2.7: e80cb046e7641fb8a71dda8254d2e619cdd64480
3.4: ba4b31ed2952b65ca447f57fbd6d540ebc4b749c
3.x: 3e4f3cc4f1f9dbee8e0ed5df47f77baae2ad310c

Full (2.7) log attached.

==
ERROR: test_arp_getnode (test.test_uuid.TestUUID)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/test/test_uuid.py", 
line 312, in test_arp_getnode
node = uuid._arp_getnode()
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/uuid.py", line 
348, in _arp_getnode
ip_addr = socket.gethostbyname(socket.gethostname())
gaierror: [Errno 8] hostname nor servname provided, or not known

--
nosy: +koobs
resolution: fixed -> 
status: closed -> open
Added file: 
http://bugs.python.org/file37193/koobs-freebsd10-python27-build758.log

___
Python tracker 

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



[issue22834] Unexpected FileNotFoundError when current directory is removed

2014-11-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue22836] Broken "Exception ignored in:" message on exceptions in __repr__

2014-11-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue21724] resetwarnings doesn't reset warnings registry

2014-11-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue22831] Use "with" to avoid possible fd leaks

2014-11-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue22868] Minor error in the example of filter()

2014-11-13 Thread Yi Bai

New submission from Yi Bai:

Hi, I suppose there is a minor error in the example of the filter() function in 
5.1.3 part of the document.

--
filter(function, sequence) returns a sequence consisting of those items from 
the sequence for which function(item) is true. If sequence is a string or 
tuple, the result will be of the same type; otherwise, it is always a list. For 
example, to compute a sequence of numbers not divisible by 2 or 3:

>>>
>>> def f(x): return x % 2 != 0 and x % 3 != 0
...
>>> filter(f, range(2, 25))
[5, 7, 11, 13, 17, 19, 23]
--

I think what the example does is "to compute a sequence of numbers not 
divisible by 2 and 3", not "2 or 3".

--
assignee: docs@python
components: Documentation
messages: 231149
nosy: docs@python, enchyisle
priority: normal
severity: normal
status: open
title: Minor error in the example of filter()
type: resource usage

___
Python tracker 

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



[issue22868] Minor error in the example of filter()

2014-11-13 Thread Georg Brandl

Georg Brandl added the comment:

For me the text is correct.  However, it depends on parsing the English 
sentence in the right way, which can be confusing.  The prose means "not 
(divisible by 2 or 3)" which is equivalent to "not divisible by 2 and not 
divisible by 3", therefore the Python code has an "and" operator.

It would probably be best to remove the negation, which also removes the 
ambiguity: "compute a sequence of numbers divisible by 2 or 3" or such.

--
nosy: +georg.brandl

___
Python tracker 

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