[issue19092] ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ callbacks of inner context managers

2013-09-26 Thread Hrvoje Nikšić

Hrvoje Nikšić added the comment:

Nick, thanks for the review. Do you need me to write the patch for the test 
suite along with the original patch?

--

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



[issue19092] ExitStack.__exit__ incorrectly suppresses exceptions in __exit__ callbacks of inner context managers

2013-09-26 Thread Nick Coghlan

Nick Coghlan added the comment:

That would be very helpful!

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-26 Thread STINNER Victor

STINNER Victor added the comment:

 Mercurial has another implementation strategy for a similar thing:
 http://selenic.com/repo/hg/file/50d721553198/mercurial/util.py#l935

I found an interesting comment in the following issue:

I think the trouble we get into is chunkbuffer() creates new large strings by 
concatenation and causes memory fragmentation. Keeping a list of chunks might 
be more efficient.

http://bz.selenic.com/show_bug.cgi?id=1842#c17

@Antoine: Do you know if your patch may reduce the memory fragmentation on 
bytearray front-slicing?

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-26 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 @Antoine: Do you know if your patch may reduce the memory
 fragmentation on bytearray front-slicing?

It reduces the number of allocations so, yes, it can reduce memory
fragmentation.
We cannot really use a list of chunks for bytearray since it is
supposed to be usable as a contiguous buffer (using the buffer API).

--

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



[issue19094] urljoin should raise a TypeError if URL is not a string

2013-09-26 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berker.peksag

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



[issue19095] Document SSLSocket.getpeercert always returns None without do_handshake

2013-09-26 Thread Antoine Pitrou

Antoine Pitrou added the comment:

To be honest I'd rather have it raise an exception in that case. None isn't 
helpful as it could mean other things.

--
nosy: +christian.heimes, giampaolo.rodola, janssen, pitrou

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



[issue19083] IDNA prefix should be case insensitive

2013-09-26 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +haypo, loewis

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



[issue19096] multiprocessing.Pool._terminate_pool restarts workers during shutdown

2013-09-26 Thread Edward Catmur

New submission from Edward Catmur:

There is a race condition in multiprocessing.Pool._terminate_pool that can 
result in workers being restarted during shutdown (process shutdown or 
pool.terminate()).

worker_handler._state = TERMINATE#  race from here
task_handler._state = TERMINATE

debug('helping task handler/workers to finish')
cls._help_stuff_finish(inqueue, task_handler, len(pool))

assert result_handler.is_alive() or len(cache) == 0

result_handler._state = TERMINATE
outqueue.put(None)  # sentinel

# We must wait for the worker handler to exit before terminating
# workers because we don't want workers to be restarted behind our back.
debug('joining worker handler')
worker_handler.join()# ~ race to here

At any point between setting worker_handler._state = TERMINATE and joining the 
worker handler, if the intervening code causes a worker to exit then it is 
possible for the worker handler to fail to notice that it has been shutdown and 
so attempt to restart the worker:

@staticmethod
def _handle_workers(pool):
thread = threading.current_thread()

# Keep maintaining workers until the cache gets drained, unless the pool
# is terminated.
while thread._state == RUN or (pool._cache and thread._state != 
TERMINATE):
# ~~ race here
pool._maintain_pool()
time.sleep(0.1)
# send sentinel to stop workers
pool._taskqueue.put(None)
util.debug('worker handler exiting')

We noticed this initially because in the absence of the fix to #14881 a 
ThreadPool trying to restart a worker fails and hangs the process.  In the 
presence of the fix to #14881 there is no immediate issue, but trying to 
restart a worker process/thread on pool shutdown is clearly unwanted and could 
result in bad things happening e.g. at process shutdown.

To trigger the race with ThreadPool, it is enough just to pause the 
_handle_workers thread after checking its state and before calling 
_maintain_pool:

import multiprocessing.pool
import time
class ThreadPool(multiprocessing.pool.ThreadPool):
def _maintain_pool(self):
time.sleep(1)
super(ThreadPool, self)._maintain_pool()
def _repopulate_pool(self):
assert self._state == multiprocessing.pool.RUN
super(ThreadPool, self)._repopulate_pool()
pool = ThreadPool(4)
pool.map(lambda x: x, range(5))
pool.terminate()
pool.join()

Exception in thread Thread-5:
Traceback (most recent call last):
  File .../cpython/Lib/threading.py, line 657, in _bootstrap_inner
self.run()
  File .../cpython/Lib/threading.py, line 605, in run
self._target(*self._args, **self._kwargs)
  File .../cpython/Lib/multiprocessing/pool.py, line 358, in _handle_workers
pool._maintain_pool()
  File .../bug.py, line 6, in _maintain_pool
super(ThreadPool, self)._maintain_pool()
  File .../cpython/Lib/multiprocessing/pool.py, line 232, in _maintain_pool
self._repopulate_pool()
  File .../bug.py, line 8, in _repopulate_pool
assert self._state == multiprocessing.pool.RUN
AssertionError

In this case, the race occurs when ThreadPool._help_stuff_finish puts sentinels 
on inqueue to make the workers finish.

It is also possible to trigger the bug with multiprocessing.pool.Pool:

import multiprocessing.pool
import time
class Pool(multiprocessing.pool.Pool):
def _maintain_pool(self):
time.sleep(2)
super(Pool, self)._maintain_pool()
def _repopulate_pool(self):
assert self._state == multiprocessing.pool.RUN
super(Pool, self)._repopulate_pool()
@staticmethod
def _handle_tasks(taskqueue, put, outqueue, pool):
time.sleep(1)
_real_handle_tasks(taskqueue, put, outqueue, pool)
_real_handle_tasks = multiprocessing.pool.Pool._handle_tasks
multiprocessing.pool.Pool._handle_tasks = Pool._handle_tasks
pool = Pool(4)
pool.map(str, range(10))
pool.map_async(str, range(10))
pool.terminate()
pool.join()

In this case, the race occurs when _handle_tasks checks thread._state, breaks 
out of its first loop, and sends sentinels to the workers.

The terminate/join can be omitted, in which case the bug will occur at gc or 
process shutdown when the pool's atexit handler runs.  The bug is avoided if 
terminate is replaced with close, and we are using this workaround.

--
components: Library (Lib)
messages: 198432
nosy: ecatmur
priority: normal
severity: normal
status: open
title: multiprocessing.Pool._terminate_pool restarts workers during shutdown
type: behavior
versions: Python 2.7, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19096
___
___
Python-bugs-list mailing list
Unsubscribe: 

[issue19096] multiprocessing.Pool._terminate_pool restarts workers during shutdown

2013-09-26 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +sbt

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



[issue19016] autospecced namedtuples should be truthy by default

2013-09-26 Thread Shawn Krisman

Shawn Krisman added the comment:

This fix is actually backwards compatible. This is a more powerful patch too 
because not only does it provide a better default for truthiness, but it also 
provides a better default for length. I also fixed a spelling mistake involving 
the word calculate.

--
Added file: http://bugs.python.org/file31875/namedtuple_truthiness_2.patch

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



[issue19096] multiprocessing.Pool._terminate_pool restarts workers during shutdown

2013-09-26 Thread Edward Catmur

Edward Catmur added the comment:

Suggested patch: 
https://bitbucket.org/ecatmur/cpython/compare/19096-multiprocessing-race..#diff

Move the worker_handler.join() to immediately after setting the worker handler 
thread state to TERMINATE.  This is a safe change as nothing in the moved-over 
code affects the worker handler thread, except by terminating workers which is 
precisely what we don't want to happen.  In addition, this is near-equivalent 
behaviour to current close() + join(), which is well-tested.

Also: write tests; and modify Pool.__init__ to refer to its static methods 
using self rather than class name, to make them overridable for testing 
purposes.

--
hgrepos: +211

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



[issue19094] urljoin should raise a TypeError if URL is not a string

2013-09-26 Thread Vajrasky Kok

Vajrasky Kok added the comment:

This is the preliminary patch to raise TypeError in that situation.

--
keywords: +patch
nosy: +vajrasky
Added file: http://bugs.python.org/file31876/urljoin_throws_type_error.patch

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



[issue19095] Document SSLSocket.getpeercert always returns None without do_handshake

2013-09-26 Thread Dariusz Suchojad

Dariusz Suchojad added the comment:

 None isn't helpful as it could mean other things.

This is another story but yes, it's true. API-wise, None should be returned in 
one situation only - we're on server side, ca_certs is non-CERT_NONE, 
do_handshake has been called yet there is no client certificate. And no other 
checks should be applied.

But the current behavior of returning None is documented and people depend on 
it so straightening it out would break backward compatibility - it's up to you 
to decide. I wouldn't mind it personally. 

But as far as this ticket goes - I'm on 2.7 and it's set in stone so for 2.7 - 
can you please change copy only? If you decide that for 3.x an exception will 
be raised then such a caveat would be included in 2.7 docs as well.

Thanks again.

--

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



[issue19083] IDNA prefix should be case insensitive

2013-09-26 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Pepijn: Can you please submit the contributor form?

http://www.python.org/psf/contrib/contrib-form/

--

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



[issue19083] IDNA prefix should be case insensitive

2013-09-26 Thread STINNER Victor

STINNER Victor added the comment:

Could you also add a test using a IDNA domain not starting with XN--, but with 
XN-- in the middle? Example:

self.assertEqual(str(bbugs.XN--pythn-mua.org., idna), bugs.pyth\xf6n.org.)

And maybe also with mixed cases: Xn-- and xN-- prefixes.

--

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



[issue1185124] pydoc doesn't find all module doc strings

2013-09-26 Thread Sunny

Sunny added the comment:

Added patch for 2.7. Please review.

--
Added file: http://bugs.python.org/file31877/pydoc_2.7.patch

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



[issue19087] bytearray front-slicing not optimized

2013-09-26 Thread STINNER Victor

STINNER Victor added the comment:

Could you please add unit tests for check that ob_start is used instead of 
memmove()?

I didn't find a function for that in _testcapi. I tried to test it using 
sys.getsizeof(), but the size is not reliable (the bytearray buffer is not 
always shrinked, it depends on the new size).

The best is probably to add a new function in _testcapi to get private 
attributes: ob_exports, ob_alloc, ob_start, ob_bytes. Using these attributes, 
it becomes easy to check that fast-path are correctly optimized (eg. increases 
ob_start instead of getting a new ob_bytes buffer).

--

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



[issue19095] Document SSLSocket.getpeercert always returns None without do_handshake

2013-09-26 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 But the current behavior of returning None is documented and people
 depend on it so straightening it out would break backward
 compatibility - it's up to you to decide. I wouldn't mind it
 personally.

I'm not sure people depend on getpeercert() returning None before the
handshake is done, or perhaps by accident?

 But as far as this ticket goes - I'm on 2.7 and it's set in stone so
 for 2.7 - can you please change copy only? If you decide that for
 3.x an exception will be raised then such a caveat would be included
 in 2.7 docs as well.

Yes, if we change behaviour it will only be in 3.4.

--

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



[issue19087] bytearray front-slicing not optimized

2013-09-26 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Could you please add unit tests for check that ob_start is used
 instead of memmove()?

How would I do that? Most of the time we don't unit-test performance
improvements (i.e. there are no tests that list.append() is O(1), for
example).

--

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



[issue19095] Document SSLSocket.getpeercert always returns None without do_handshake

2013-09-26 Thread Dariusz Suchojad

Dariusz Suchojad added the comment:

 I'm not sure people depend on getpeercert() returning None before the
 handshake is done, or perhaps by accident?

Ah, no, I meant that people may depend on the documented behaviour of 
.getpeercert's returning an empty dict (which I mixed up with returning None) 
if the certificate was not validated.

That this dictionary's contents depends on the validation is a bit quirky but 
it's documented so changing that one would surely break existing code.

--

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



[issue19082] Lib/xmlrpc/client.py demo code points to the dead server

2013-09-26 Thread Vajrasky Kok

Vajrasky Kok added the comment:

What test_xmlrpc_net tests (especially the one with time.xmlrpc.com) have been 
tested in test_xmlrpc except for connecting to server with dotted_attribute 
feature and receiving datetime instance over the network.

That test is not that hard to be migrated to test_xmlrpc. But should we chuck 
it in this ticket or create a new ticket?

There is also a reference to time.xmlrpc.com in Doc/library/xmlrpc.client.rst.

--

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



[issue19082] Lib/xmlrpc/client.py demo code points to the dead server

2013-09-26 Thread R. David Murray

R. David Murray added the comment:

Yeah, a new issue is probably a good idea.  If the dotted attribute feature is 
not tested by test_xmlrpc, then the test is probably worth migrating.

I'm not sure what to do about the docs, and that should be a separate issue as 
well.

--

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



[issue19009] Enhance HTTPResponse.readline() performance

2013-09-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Kristján, did you notice my comments on Rietveld?

--

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



[issue19009] Enhance HTTPResponse.readline() performance

2013-09-26 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Ah no actually.  Thanks . I'll respond soon.

--

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



[issue19083] IDNA prefix should be case insensitive

2013-09-26 Thread Pepijn de Vos

Pepijn de Vos added the comment:

Ok, I signed the agreement and included a few more tests.

--
Added file: http://bugs.python.org/file31878/upper-idna.patch

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



[issue15964] SyntaxError in asdl when building 2.7 with system Python 3

2013-09-26 Thread Eli Bendersky

Eli Bendersky added the comment:

Did anyone ended up updating the devguide about this? I can't find anything 
related in there.

--
nosy: +eli.bendersky

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



[issue13477] tarfile module should have a command line

2013-09-26 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the rebase, Antoine.

Here is an updated patch:

- Adressed Serhiy's comments. I didn't add a directory parameter to the
  create command to keep the CLI simple.
- Added a test for dotless files
- Returned proper exit codes

--
components: +Library (Lib)
Added file: http://bugs.python.org/file31879/issue13477_v5.diff

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



[issue17473] -m is not universally applicable

2013-09-26 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berker.peksag

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



[issue17473] -m is not universally applicable

2013-09-26 Thread Claudiu.Popa

Changes by Claudiu.Popa pcmantic...@gmail.com:


--
nosy: +Claudiu.Popa

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



[issue15869] IDLE: Include .desktop file and icon

2013-09-26 Thread Hendrik Knackstedt

Hendrik Knackstedt added the comment:

For the correct icon to appear you have to copy the provided .xpm file to the 
given location: /usr/share/pixmaps/python.xpm

This is still an issue for the current version of python 3.3.

This is really easy to fix. Simply include the files already provided. I can 
confirm they work on Archlinux in XFCE.

--
nosy: +hennekn

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



[issue17473] -m is not universally applicable

2013-09-26 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +ncoghlan

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



[issue17473] -m is not universally applicable

2013-09-26 Thread Nick Coghlan

Nick Coghlan added the comment:

runpy needs to be refactored at least a bit before this will be practical. 
Issue 9325 is an existing issue for the same idea that discusses some of the 
problems to be resolved (it's a good idea, just a fair bit of work).

--
resolution:  - duplicate
status: open - closed
superseder:  - Add an option to pdb/trace/profile to run library module as a 
script

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



[issue9325] Add an option to pdb/trace/profile to run library module as a script

2013-09-26 Thread Nick Coghlan

Nick Coghlan added the comment:

Issue 17473 had a longer list of relevant modules:

pdb profile doctest trace modulefinder tabnanny pyclbr dis

--

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



[issue9325] Add an option to pdb/trace/profile to run library module as a script

2013-09-26 Thread Nick Coghlan

Nick Coghlan added the comment:

Also, the ModuleSpec PEP (PEP 451)should make the proposed refactoring much 
simpler, since the code runner could just expose data from the module spec.

--

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



[issue19094] urljoin should raise a TypeError if URL is not a string

2013-09-26 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Thanks Vajraski for the patch (especially the tests).

A colleague reminded me of an aphorism by Raymond Hettinger from the recent 
PyCon paraphrased: duck typing is superior to isinstance.

Maybe instead consider something like this:

diff -r 7f13d5ecf71f Lib/urllib/parse.py
--- a/Lib/urllib/parse.py   Sun Sep 22 09:33:45 2013 -0400
+++ b/Lib/urllib/parse.py   Thu Sep 26 18:52:18 2013 -0400
@@ -405,10 +405,9 @@
 def urljoin(base, url, allow_fragments=True):
 Join a base URL and a possibly relative URL to form an absolute
 interpretation of the latter.
-if not base:
-return url
-if not url:
-return base
+if not base or not url:
+# one of the inputs is empty, so simply concatenate
+return base + url
 base, url, _coerce_result = _coerce_args(base, url)
 bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
 urlparse(base, '', allow_fragments)

This implementation is not only shorter and raises TypeErrors if the types 
aren't compatible, but those errors are triggered by the underlying 
implementation. Furthermore, if either the url or base were to be a duck-type 
that met the necessary interface, it need not be a string subclass.

I don't feel strongly either way, but I'm slightly more inclined to accept the 
simpler implementation. I'm interested in the everyone's thoughts on either 
approach.

--

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



[issue14365] argparse: subparsers, argument abbreviations and ambiguous option

2013-09-26 Thread paul j3

paul j3 added the comment:

Steven's patch (subparse_optionals.diff) run with jakub's test case 
(argparse_subparses_ambiguous_bug.py) works.  But if the input string is 

print(parser.parse_args('--foo baz'.split()))

produces

Namespace(cmd=None, foo='baz', foo1=None, foo2=None)

(I added the 'cmd' subparse 'dest').  

Two things seem to be going on now: 

1) '--foo' is being parsed even though its subparser is not invoked, 

2) and the subparser is not required.

The issue of whether subparsers are required or not is another issue.  They 
used to be required, but the testing for 'required' was changed, and subparsers 
fell through the crack.

I suspect that if the missing subparser error were raised, the first issue 
wouldn't be apparent.

--

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



[issue19097] bool(cgi.FieldStorage(...)) may be False unexpectedly

2013-09-26 Thread Guido van Rossum

New submission from Guido van Rossum:

Check out 
http://stackoverflow.com/questions/9327597/python-get-does-not-evaluate-to-true-even-though-there-is-an-object
 

It turns out a cgi.FieldStorage object may consider itself False even when it 
has data.  This happens when the initialization decided to use read_single() 
instead of one of the other ways of reading the field value (read_urlencoded() 
or read_multi()).  Then self.list remains None, and __nonzero__ returns False 
no matter what the contents of self.file is.

To make things worse -- or better? -- the Python 3 version still defines 
__nonzero__() instead of __bool__().

--
messages: 198457
nosy: gvanrossum
priority: normal
severity: normal
status: open
title: bool(cgi.FieldStorage(...)) may be False unexpectedly
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5

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



[issue19097] bool(cgi.FieldStorage(...)) may be False unexpectedly

2013-09-26 Thread Guido van Rossum

Guido van Rossum added the comment:

PS. Simple repro:

import cgi; bool(cgi.FieldStorage('logo', u'tux.png'))

This reveals it's been fixed in Python 3 -- it raises TypeError there as it 
should.  (But __nonzero__ should be deleted, and if someone adds __bool__ they 
should make sure it raises the same TypeError if self.list is None.)

--
versions:  -Python 2.6, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 
3.5

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



[issue9325] Add an option to pdb/trace/profile to run library module as a script

2013-09-26 Thread Eric Snow

Eric Snow added the comment:

Soon, my precious, soon...

--

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



[issue3982] support .format for bytes

2013-09-26 Thread nlev...@gmail.com

Changes by nlev...@gmail.com nlev...@gmail.com:


--
nosy: +nlev...@gmail.com

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



[issue19097] bool(cgi.FieldStorage(...)) may be False unexpectedly

2013-09-26 Thread Guido van Rossum

Changes by Guido van Rossum gu...@python.org:


--
versions: +Python 2.6

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



[issue19098] sys.setrecursionlimit(2**30) breaks interactive shell

2013-09-26 Thread Arfrever Frehtes Taifersar Arahesis

New submission from Arfrever Frehtes Taifersar Arahesis:

sys.setrecursionlimit(2**30) breaks interactive shell in Python =3.3.
This bug does not occur during non-interactive execution of scripts / modules.
This bug does not occur in versions of Python older than 3.3.

This bug occurs only for some range of values of recursion limit. There are 
higher values, which do not cause this bug.
sys.setrecursionlimit(2**31), as expected, raises OverflowError.
Values like 2**31-1 (i.e. 2147483647) cause no problem:

$ python3.4 -q
 import sys
 sys.setrecursionlimit(2**31)
Traceback (most recent call last):
  File stdin, line 1, in module
OverflowError: signed integer is greater than maximum
 sys.setrecursionlimit(2**31-1)
 sys.getrecursionlimit()
2147483647
 0
0
 

Lower limit of values of recursion limit, which cause this bug: 715827883 == 
2**29 + 2**27 + 2**25 + 2**23 + 2**21 + 2**19 + 2**17 + 2**15 + 2**13 + 2**11 + 
2**9 + 2**7 + 2**5 + 2**3 + 2**1 + 1
Upper limit of values of recursion limit, which cause this bug: 1431655765 == 
2**30 + 2**28 + 2**26 + 2**24 + 2**22 + 2**20 + 2**18 + 2**16 + 2**14 + 2**12 + 
2**10 + 2**8 + 2**6 + 2**4 + 2**2 + 1

Example of this bug:

$ python3.4 -q
 import sys
 sys.setrecursionlimit(2**30)
 0
RuntimeError: maximum recursion depth exceeded during compilation
 a
RuntimeError: maximum recursion depth exceeded during compilation
 
RuntimeError: maximum recursion depth exceeded during compilation


RuntimeError occurs for each line (even empty). Ctrl+D still works.

I use 64-bit GNU/Linux.

--
components: Interpreter Core
keywords: 3.3regression
messages: 198460
nosy: Arfrever
priority: normal
severity: normal
status: open
title: sys.setrecursionlimit(2**30) breaks interactive shell
versions: Python 3.3, Python 3.4

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



[issue19098] sys.setrecursionlimit(2**30) breaks interactive shell

2013-09-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c3df31cbcd0a by Benjamin Peterson in branch '3.3':
don't scale compiler stack frames if the recursion limit is huge (closes #19098)
http://hg.python.org/cpython/rev/c3df31cbcd0a

New changeset 9a7ec433bf59 by Benjamin Peterson in branch 'default':
merge 3.3 (#19098)
http://hg.python.org/cpython/rev/9a7ec433bf59

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue19094] urljoin should raise a TypeError if URL is not a string

2013-09-26 Thread Vajrasky Kok

Vajrasky Kok added the comment:

What about this one?

 urljoin(['a'], [])
['a']
 urljoin(['a'], ['b'])
. omitted ..
AttributeError: 'list' object has no attribute 'decode'

Is this desirable? Both patches missed this case. Should we only accept str and 
bytes?

--

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



[issue18990] Return root element from ElementTree.XMLPullParser.close() to match ElementTree.XMLParser

2013-09-26 Thread Stefan Behnel

Stefan Behnel added the comment:

Here's the obvious minimal patch that removes the non-public 'root' attribute. 
Please apply it for Py3.4 and then set the version tag of this ticket to Py3.5 
(instead of closing it, because it's not resolved yet).

As I said, the expected thing to do (and what lxml.etree will do in its next 
release) is to behave like XMLParser. Reverting the new patch for Py3.5 and 
applying the old one will achieve that nicely, including the proper test 
adaptations.

--
Added file: 
http://bugs.python.org/file31880/xmlpullparser_remove_public_root_attr.patch

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