[issue18301] In itertools.chain.from_iterable() there is no cls argument

2013-09-08 Thread Raymond Hettinger

Changes by Raymond Hettinger :


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

___
Python tracker 

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



[issue18301] In itertools.chain.from_iterable() there is no cls argument

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 29fa1f418796 by Raymond Hettinger in branch '3.3':
Issue 18301:  The classmethod decorator didn't fit well with the 
rough-equivalent example code.
http://hg.python.org/cpython/rev/29fa1f418796

--
nosy: +python-dev

___
Python tracker 

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



[issue18980] Docs: enum - ReST format

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0e05b07a6f84 by Ethan Furman in branch 'default':
Close #18980: Enum doc fixes.  Patch from Elazar Gershuni.
http://hg.python.org/cpython/rev/0e05b07a6f84

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/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



[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3

paul j3 added the comment:

At the very least the `is not action.default` needs to be changed.  Else where 
in argparse `is` is only used with `None` or constant like `SUPPRESS`.  So 
using it with a user defined parameter is definitely not a good idea.

Possible variations on how `is` behaves across implementations (pypy, 
ironpython) only complicates the issue.  I'm also familiar with a Javascript 
translation of argparse (that uses its `!==` in this context).

--

___
Python tracker 

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



[issue18752] Make chain.from_iterable an alias for a new chain_iterable.

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fa1fa88b685b by Raymond Hettinger in branch 'default':
Issue 18752:  Make chain.from_iterable() more visible in the documentation.
http://hg.python.org/cpython/rev/fa1fa88b685b

--
nosy: +python-dev

___
Python tracker 

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



[issue14984] netrc module allows read of non-secured .netrc file

2013-09-08 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue14984] netrc module allows read of non-secured .netrc file

2013-09-08 Thread bruno Piguet

Changes by bruno Piguet :


--
versions: +Python 3.2

___
Python tracker 

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



[issue18752] Make chain.from_iterable an alias for a new chain_iterable.

2013-09-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I'll work on improving the docs to make this classmethod more discoverable in 
docs, but the API is going to stay the same.

--
resolution:  -> rejected

___
Python tracker 

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



[issue18980] Docs: enum - ReST format

2013-09-08 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted

2013-09-08 Thread STINNER Victor

STINNER Victor added the comment:

I would prefer a clear_frames() method on the traceback object rather than
a function.

--

___
Python tracker 

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



[issue18929] inspect.classify_class_attrs ignores metaclass

2013-09-08 Thread Ethan Furman

Ethan Furman added the comment:

This is a more useful help() -- patch attached.

==
Help on class Color in module __main__:

class Color(enum.Enum)
 |  Method resolution order:
 |  Color
 |  enum.Enum
 |  builtins.object
 |  
 |  Data and other attributes defined here:
 |  
 |  blue = 
 |  
 |  green = 
 |  
 |  red = 
 |  
 |  --
 |  Data descriptors inherited from enum.EnumMeta:
 |  
 |  __members__
 |  Returns a mapping of member name->value.
 |  
 |  This mapping lists all enum members, including aliases. Note that this
 |  is a read-only view of the internal mapping.

--
keywords: +patch
Added file: http://bugs.python.org/file31693/issue18929.stoneleaf.03.patch

___
Python tracker 

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



[issue18752] Make chain.from_iterable an alias for a new chain_iterable.

2013-09-08 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +eric.araujo

___
Python tracker 

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



[issue18983] Specify time unit for timeit CLI

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

My 2 cents - I'd split timeit.main function into processing part and argument 
parsing + data printing part so that you could use Python to call the first one 
to get the actual results (timings, numbers of loops etc.) and then present the 
data to the outside world in any needed format - no text parsing needed.

--
nosy: +jstasiak

___
Python tracker 

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



[issue18800] Document Fraction's numerator and denominator properties

2013-09-08 Thread Madison May

Madison May added the comment:

Simple and to the point.  Sounds good to me...

--

___
Python tracker 

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



[issue18903] IDLE file-completion is case-sensitive in Windows

2013-09-08 Thread Westley Martínez

Westley Martínez added the comment:

My example was totally abstract and untested.  Sorry for any confusion.

After doing some research, I find that this issue is complicated further:
http://support.microsoft.com/kb/100625

I think we can assume that running into a situation where there are identical 
filenames except for case is quite rare.  The thing is, I don't even know how 
to make files like this on Windows.  Explorer doesn't work, and other Win32 
apps won't do it (they all spit up errors).  I reckon I can do it with Python 
or some other language, since I assume they does these things at a low level.

I'll start looking at the code and see if I can come up with a patch.  My aim 
is to make it similar enough to how the Windows Terminal does it, (i.e. it 
corrects the typed name to the proper case) since that is what I'd imagine most 
Windows programmers are used to.

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Tim Peters

Changes by Tim Peters :


--
Removed message: http://bugs.python.org/msg197342

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

New changeset aff959a3ba13 by Tim Peters in branch 'default':
Issue 18984:  Remove ._stopped Event from Thread internals.
http://hg.python.org/cpython/rev/aff959a3ba13

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

Thanks, Antoine!  I pushed this change, figuring that even if some buildbots 
are still unhappy about 18808, getting rid of the Event can't make them more 
unhappy, and may make them happier.

--
resolution:  -> fixed

___
Python tracker 

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



[issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted

2013-09-08 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Revised version of the patch: catches RuntimeError instead of skipping the 
first frame; adds versionadded tag; adds entry to NEWS and whatsnew files.

--
Added file: http://bugs.python.org/file31692/clear-tb-frames-2.txt

___
Python tracker 

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset aff959a3ba13 by Tim Peters in branch 'default':
Issue 18984:  Remove ._stopped Event from Thread internals.
http://hg.python.org/cpython/rev/aff959a3ba13

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset aff959a3ba13 by Tim Peters in branch 'default':
Issue 18984:  Remove ._stopped Event from Thread internals.
http://hg.python.org/cpython/rev/aff959a3ba13

--
nosy: +python-dev

___
Python tracker 

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



[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3

paul j3 added the comment:

This `argument_values` comes from `_get_values()`.  Most of the time is derived 
from the `argument_strings`.  But in a few cases it is set to `action.default`, 
specifically when the action is an optional postional with an empty 
`argument_strings`.

test_argparse.TestMutuallyExclusiveOptionalAndPositional is such a case.  
`badger` is an optional positional in a mutually exclusive group.  As such it 
can be 'present' without really being there (tricky).  Positionals are always 
processed - otherwise it raises an error.

If this is the case, what we need is a more reliable way of knowing whether 
`_get_values()` is doing this, one that isn't fooled by this small int caching.

We could rewrite the `is not` test as:

if not argument_strings and action.nargs in ['*','?'] and  argument_values 
is action.default:
pass # _get_values() has set: argument_values=action.default
else:
seen_non_default_actions.add(action)
...

is a little better, but still feels like a kludge.  Having `_get_values` return 
a flag that says "I am actually returning action.default" would be clearer, 
but, I think, too big of a change.

--

___
Python tracker 

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



[issue18929] inspect.classify_class_attrs ignores metaclass

2013-09-08 Thread Ethan Furman

Ethan Furman added the comment:

Antoine, to answer all your questions at once, and using an Enum as the example:

--> dir(Color)
['__class__', '__doc__', '__members__', '__module__', 'blue', 'green', 'red']

--> Color.__members__
mappingproxy(OrderedDict([('red', ), ('green', ), 
('blue', )]))

-->help(Color)

Help on class Color in module __main__:

Color = 


Why?  Because __members__ is not in Color.__dict__

--> Color.__dict__.keys()
dict_keys(['_member_type_', '_member_names_', '__new__', '_value2member_map_', 
'__module__', '_member_map_', '__doc__'])

and inspect.classify_class_attrs doesn't look in metaclasses, instead assigning 
None as the class if it can't find it:

--> inspect.classify_class_attrs(Color) # output trimmed for brevity
Attribute(name='__members__', kind='data', defining_class=None, object= ... )

So, even though __members__ does show up in dir(Color), classify_class_attrs 
incorrectly assigns its class.

Can I use classify_class_attrs on Color.__class__? Sure, but then I get 50 
items, only one of which was listed in dir(Color).

Interestingly, getmembers(Color) does return __members__, even though it is a 
metaclass attribute and the docs warn that it won't:

--> print('\n'.join([str(i) for i in inspect.getmembers(Color)]))
('__class__', )
('__doc__', None)
('__members__', mappingproxy(OrderedDict([('red', ), ('green', 
), ('blue', )])))
('__module__', '__main__')
('blue', )
('green', )
('red', )

So if getmembers() correctly reports it because it shows up in dir(), then 
classify_class_attrs should correctly identify it as well.

--

___
Python tracker 

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



[issue12317] inspect.getabsfile() is not documented

2013-09-08 Thread Brett Cannon

Brett Cannon added the comment:

It technically doesn't need to be a dependency, but if __file__ goes absolute 
then the point of the function becomes moot and thus shouldn't get documented 
as it is then pointless (and honestly I don't trust any code that tries to 
guess at what the cwd was when a module was imported).

--

___
Python tracker 

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



[issue18983] Specify time unit for timeit CLI

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

If you want the output to be machine readable, better go the full way and add a 
--json option, IMO.

--
nosy: +pitrou, tim.peters

___
Python tracker 

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



[issue12317] inspect.getabsfile() is not documented

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

This shouldn't be a dependency. The function is already implemented, it just 
needs to be documented.

--
dependencies:  -Move to absolute file paths for module.__file__
nosy: +pitrou

___
Python tracker 

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



[issue18903] IDLE file-completion is case-sensitive in Windows

2013-09-08 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The initial difficulty I am having is that the edit menu, help file, code, and 
behavior do not seem to match up, so this whole feature set needs more review. 
For one thing, the AutoCompleteWindow (ACW) often comes up empty initially. 
Sometimes it fills in a couple of seconds later, sometimes not. Or it only 
fills in if I enter or delete a char.

However, I did manage to reproduce the issue. (Westley, your ambiguous report 
cannot be exactly correct. If you typed 3 chars (no quotes) and tab, you should 
get a list of python names, not filenames. If you typed 5 chars (two quotes) 
and tab, you should get a literal tab. You would have to type 4 chars (open 
quote only) and tab to get filenames.)

Reviewing the code, I see the following.
AutoComplete.open_completions calls .fetch_completions to get a sorted list of 
possible completions, according to the mode. It then makes an ACW and calls 
.show_window.  ACW.show_window receives the mode and stores it as self.mode. 
That is used in the logic of ACW.keypress_event for handling 'special' 
characters. It is currently not used for matching normal characters to 
completions. ACW.show_window also allocates a tk.Listbox with
self.listbox = listbox = Listbox(acw, yscrollcommand=scrollbar.set,
   exportselection=False, bg="white")
As near as I can tell, the matching of what the user types with entries in the 
ACW listbox is done in ACS._binary_search as items in the listbox seem to be 
set with
self.listbox.select_set(self._binary_search(self.start))

For this issue, we need two things.

1. .fetch_completions should sort filenames disregarding case on Windows.  
Perhaps key = str.lower will be sufficient, but I do not know what 
'case-insensitive' actually means on Windows with respect to general Unicode 
file names. 

2. A case-insensitive version of _binary_search -- perhaps an instance function 
(closure) defined in .show_window using a list of lower-cased entries. Both the 
original and replacement should probably use the bisect module, which has a C 
accelerator.

There is a third thing: tests. I am reluctant to continue patching Idle without 
tests for the issue, but writing one for this will probably be harder than the 
patch itself. My main concern is not to make things worse.

It would to easier to document that one should start with one letter and if 
there is no desired match, backspace and try the other case ;-).

--
stage:  -> needs patch

___
Python tracker 

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



[issue12317] inspect.getabsfile() is not documented

2013-09-08 Thread Brett Cannon

Changes by Brett Cannon :


--
dependencies: +Move to absolute file paths for module.__file__

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I think the fix is simply to remove the outdated tests.

I've been running test_threading in a loop with the (attached) updated patch, 
and there hasn't been a single failure.

--
type:  -> resource usage
Added file: http://bugs.python.org/file31691/remove_stopped_2.patch

___
Python tracker 

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



[issue18967] Find a less conflict prone approach to Misc/NEWS

2013-09-08 Thread Nick Coghlan

Nick Coghlan added the comment:

No, way down in Tests.

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

I agree with your diagnosis.  Unfortunately, I can't test the fork stuff.  
Well, OK, I actually think that's fortunate (for me ;-) ).

If you can see a quick way to fix these, please do.  I'm going to vanish for 
about 2 hours now.

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Looks like it's mostly the tests trying to check an implementation detail that 
doesn't exist anymore :-)

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hmm.. I'm getting the following failures:

==
FAIL: test_4_joining_across_fork_in_worker_thread 
(test.test_threading.ThreadJoinOnShutdown)
--
Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/test/test_threading.py", line 726, in 
test_4_joining_across_fork_in_worker_thread
self.assertScriptHasOutput(script, "end of main\n")
  File "/home/antoine/cpython/default/Lib/test/test_threading.py", line 651, in 
assertScriptHasOutput
rc, out, err = assert_python_ok("-c", script)
  File "/home/antoine/cpython/default/Lib/test/script_helper.py", line 55, in 
assert_python_ok
return _assert_python(True, *args, **env_vars)
  File "/home/antoine/cpython/default/Lib/test/script_helper.py", line 46, in 
_assert_python
"stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
AssertionError: Process return code is 1, stderr follows:
Traceback (most recent call last):
  File "", line 29, in 
AttributeError: 'Thread' object has no attribute '_stopped'

==
FAIL: test_5_clear_waiter_locks_to_avoid_crash 
(test.test_threading.ThreadJoinOnShutdown)
--
Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/test/test_threading.py", line 784, in 
test_5_clear_waiter_locks_to_avoid_crash
self.assertScriptHasOutput(script, output)
  File "/home/antoine/cpython/default/Lib/test/test_threading.py", line 651, in 
assertScriptHasOutput
rc, out, err = assert_python_ok("-c", script)
  File "/home/antoine/cpython/default/Lib/test/script_helper.py", line 55, in 
assert_python_ok
return _assert_python(True, *args, **env_vars)
  File "/home/antoine/cpython/default/Lib/test/script_helper.py", line 46, in 
_assert_python
"stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
AssertionError: Process return code is 1, stderr follows:
Traceback (most recent call last):
  File "", line 29, in 
AttributeError: 'Thread' object has no attribute '_stopped'

--

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Tim Peters

Changes by Tim Peters :


--
dependencies: +Thread.join returns before PyThreadState is destroyed

___
Python tracker 

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



[issue18984] Remove .stopped Event from Thread internals

2013-09-08 Thread Tim Peters

New submission from Tim Peters:

As discussed in issue 18808, now that we're checking for a tstate lock, the 
Thread._stopped Event has become an "attractive nuisance".  The attached patch 
removes it.

This simplifies .join() and .is_alive(), and restores pre-18808 .join(timeout) 
endcase behavior (i.e., if join returns before the timeout expires, .is_alive() 
will always be False).

Since this doesn't add any new locks, I hope it won't create more problems with 
fork tests - but running on Windows I wouldn't know ;-)

--
assignee: tim.peters
components: Library (Lib)
files: remove_stopped
keywords: needs review, patch
messages: 197325
nosy: pitrou, tim.peters
priority: normal
severity: normal
stage: patch review
status: open
title: Remove .stopped Event from Thread internals
versions: Python 3.4
Added file: http://bugs.python.org/file31690/remove_stopped

___
Python tracker 

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



[issue18815] DOCUMENTATION: "mmap .close()" doesn't close the underlying file

2013-09-08 Thread Anoop Thomas Mathew

Anoop Thomas Mathew added the comment:

Made it explicit that close() will close only the mmap, and file will not be 
closed. Patch attached.

--
keywords: +patch
nosy: +Anoop.Thomas.Mathew
Added file: http://bugs.python.org/file31689/mmap_close_documentation.patch

___
Python tracker 

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



[issue12704] Language Reference: Clarify behaviour of yield when generator is not resumed

2013-09-08 Thread Nikolaus Rath

Nikolaus Rath added the comment:

I've attached an updated patch.

I agree with Tim that the docs on the yield expression are already very good, 
so instead of extending the yield statement documentation I have shortened it 
to instead reduce the overlap that already exists.

In the yield expression documentation, I have replaced :keyword:`yield` with an 
un-tagged "yield" (because the former results in a link to the yield statement) 
and added '.. or yield statement' to the parts that apply to both yield 
expressions and statements.

I have also added hyperlinks to the relevant descriptions of the generator 
methods.

--
Added file: http://bugs.python.org/file31688/yield-docpatch.diff

___
Python tracker 

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



[issue18983] Specify time unit for timeit CLI

2013-09-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Just an idea. Currently the timeit module in command line automatically choice 
most appropriate time unit for human readable output. But this makes the output 
less machine readable. I propose to add new option which specifies fixed time 
unit (usec, msec, sec).

--
components: Library (Lib)
keywords: easy
messages: 197322
nosy: georg.brandl, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Specify time unit for timeit CLI
type: enhancement
versions: Python 3.4

___
Python tracker 

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



[issue18973] Use argparse in the calendar module

2013-09-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Good point. See issue18982.

--
dependencies: +Add tests for CLI of the calendar module

___
Python tracker 

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



[issue18982] Add tests for CLI of the calendar module

2013-09-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The proposed patch adds tests for command-line interface of the calendar 
module. It also makes calendar tests discoverable and makes some existing tests 
more strong.

--
components: Tests
files: test_calendar_cli.patch
keywords: patch
messages: 197320
nosy: r.david.murray, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Add tests for CLI of the calendar module
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31687/test_calendar_cli.patch

___
Python tracker 

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



[issue14984] netrc module allows read of non-secured .netrc file

2013-09-08 Thread bruno Piguet

bruno Piguet added the comment:

I missed the 3.3 window, may I re-propose the same minimal patch against 
3.4.0a1 ?
I'm not sure I follow any python standard lib coding style but the general idea 
is quite simple and easy to get.

I chose to ignore the backward compatibility concern, since I agree that the 
security aspect overrides that.

I followed your suggestion : my patch raises OSError instead of NetrcParseError.

--
versions: +Python 3.4 -Python 3.2
Added file: http://bugs.python.org/file31686/patch_netrc_3.4.0a1.txt

___
Python tracker 

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



[issue18981] Typo in the ctypes tests

2013-09-08 Thread Anoop Thomas Mathew

New submission from Anoop Thomas Mathew:

Comment in the test_number.py in ctypes test hold a typo bug. Instead of 
superseeded, it should be superseded. Patch attached.

--
assignee: docs@python
components: Documentation, Tests
files: ctypes_test_typo.patch
keywords: patch
messages: 197318
nosy: Anoop.Thomas.Mathew, docs@python
priority: normal
severity: normal
status: open
title: Typo in the ctypes tests
type: enhancement
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5
Added file: http://bugs.python.org/file31685/ctypes_test_typo.patch

___
Python tracker 

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



[issue18821] Add .lastitem attribute to takewhile instances

2013-09-08 Thread Oscar Benjamin

Oscar Benjamin added the comment:

Thank you Claudiu very much for writing a patch; I was expecting to
have to do that myself!

Serhiy, you're right groupby is a better fit for this. It does mean a
bit of reworking for the (more complicated) sum function I'm working
on but I've just checked with timeit and it performs very well using
the type function as a predicate. I think it might make the function a
few times faster than takewhile in my common cases for reasons that
are particular to this problem.

Raymond, thanks for taking the time to consider this. I agree that it
should now be closed.

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread R. David Murray

R. David Murray added the comment:

I do not find a space to be an acceptable separator, sorry.

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> So:
> 
> 1 loops, best of 3: 34.6 usec per loop (28 870 loops/s)

Looks fine to me (though having a decimal space at the right and not at
the left looks a bit weird).

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Changes by Jakub Stasiak :


Added file: http://bugs.python.org/file31684/timeit-v3-pep8.patch

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

To me the point of this patch is adding number of loops per second information 
- using thousands separators was just an addition which I'm happy to drop.

Please find attached 2 patches:
- one containing actual changes - loops per second added, fractional part is 
printed when the number is less than 100, space is used as thousands separator; 
old part of the message is not affected
- one containing PEP8 reformatting

So:

1 loops, best of 3: 34.6 usec per loop (28 870 loops/s)

--
Added file: http://bugs.python.org/file31683/timeit-v3-actual-changes.patch

___
Python tracker 

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



[issue17862] itertools.chunks(iterable, size, fill=None)

2013-09-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

If this is to go forward, it needs to be more interesting, useful, and general 
than what was has been discussed so far.  I would be open to some kind of 
reshape() itertool than can ungroup, flatten, and regroup in at least two 
dimensions.  

Ideally, it should be inspired by a successful general-purpose tool from 
another functional or data manipulation language (perhaps APL, Mathematica, 
Matlab, Numpy, or somesuch).

Ideally, the proposal will be accompanied by some non-trivial real-world use 
cases to help validate the design.

Ideally, there should be demonstrations of reshape() interacting effectively 
with the other itertools (i.e. a criterion for adding new Lego bricks is 
whether they work well with all the existing Lego bricks -- that is what makes 
a good Lego set).

--

___
Python tracker 

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



[issue18980] Docs: enum - ReST format

2013-09-08 Thread Elazar Gershuni

New submission from Elazar Gershuni:

in http://docs.python.org/3.4/library/enum.html :
"..note: Nomenclature"
and 
".:meth:__format__"

visible in the html.

--
assignee: docs@python
components: Documentation
files: enum_minor.patch
keywords: patch
messages: 197312
nosy: docs@python, elazar
priority: normal
severity: normal
status: open
title: Docs: enum - ReST format
versions: Python 3.4
Added file: http://bugs.python.org/file31682/enum_minor.patch

___
Python tracker 

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



[issue18821] Add .lastitem attribute to takewhile instances

2013-09-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Oscar, the solution proposed by Serhiy looks like a better choice.

I'm wary of increasing the API complexity of the itertools.  Right now, their 
learnability is aided by having simple signatures and no side-values.

The itertools are modeled on functional tools in other languages with mature 
APIs.  I look to those languages to provide an indication of whether proposed 
features are needed in practice.  AFAICT, there is no precedent for a 
takewhile-with-failed-value combo.

I appreciate your request (especially because it was accompanied by a use case) 
but am going to decline.  IMO, the module as a whole is better served by 
keeping the tools simple and clean. 

If an individual itertool doesn't have an exact fit to a particular use case, 
it may indicate that the programmer would be better served by a simple 
generator which can express the logic more cleanly than a tricked-out itertool 
with side-values.

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



[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Raymond Hettinger

Changes by Raymond Hettinger :


Removed file: http://bugs.python.org/file31671/merge.diff

___
Python tracker 

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



[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Raymond Hettinger

Changes by Raymond Hettinger :


Added file: http://bugs.python.org/file31681/merge2.diff

___
Python tracker 

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

> The MainThread class could override is_alive() and join(), then.

I think it will be easier than that, but we'll see ;-)

--

___
Python tracker 

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



[issue17741] event-driven XML parser

2013-09-08 Thread Stefan Behnel

Stefan Behnel added the comment:

While refactoring the iterparse() implementation in lxml to support this new 
interface, I noticed that the close() method of the XMLPullParser does not 
behave like the close() method of the XMLParser. Instead of setting some .root 
attribute on the parser instance, the method should return the root element 
that the tree builder generated.

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

-1 from me, and I'm a comma-loving American ;-)

I'm sure lots of code in the wild parses this output - Serhiy isn't the only 
one doing it.

--

___
Python tracker 

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> Without _stopped, join() can simply wait to acquire _tstate_lock (with
> or without a timeout, and skipping this if _tstate_lock is already
> None).  Etc ;-)  Of course details matter, but it's easy.  I did it
> once, but the tests joining the main thread failed and I put the code
> on hold.

Ah, of course. The main thread needs the event, since the thread state
will only be deleted at the end of Py_Finalize().
The MainThread class could override is_alive() and join(), then.

--

___
Python tracker 

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

Without _stopped, join() can simply wait to acquire _tstate_lock (with or 
without a timeout, and skipping this if _tstate_lock is already None).  Etc ;-) 
 Of course details matter, but it's easy.  I did it once, but the tests joining 
the main thread failed and I put the code on hold.  I'll dust it off when the 
buildbots are all happy with the current changes.

> (also, why is the current Event implementation based
> on Condition?

We'd have to ask Guido ;-)  Best guess is that Condition supplied all the 
machinery to make Event.wait() work correctly, including waking all waiters up 
when the Event gets set.

> isn't an Event actually simpler than a Condition?)

Events are indeed simple :-)  There are many ways to implement them, but "ain't 
broke, don't fix" seems the right approach to me here.  In effect, if we get 
rid of _stopped, the code remaining will be much like an Event implementation 
built on the plain _tstate_lock lock.

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread R. David Murray

R. David Murray added the comment:

I'm with Serhiy on this.  So if separators are added, I would say they *must* 
be optional.  Presumably if they are added they should be locale dependent :)  
All of which may well make it more complicated than it is worth.

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> join() and is_alive() are too complicated now, because of the 2-step
> dance to check whether the thread is done:  we have both an Event
> (_stopped) and a lock (_tstate_lock) to check now.  The Event doesn't
> serve a purpose anymore:  it's almost always uninteresting to know
> _just_ that the Python part of the thread has ended.

Yes, that crossed my mind too. The difficulty is that only plain lock
objects are available from C code, not Events. But if the first join()er
releases the lock just after taking it, it will be enough to make the
code correct?

(after all, it's an event that's never reset, which simplifies things)

(also, why is the current Event implementation based on Condition? isn't
an Event actually simpler than a Condition?)

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm afraid the adding any separators will make some people angry. With a comma 
or space it no more a valid number in Python and many other languages and can't 
be copy/pasted and parsed.

Actually I sometimes use small shell scripts to run "python -m timeit" and 
parsing results with grep, sed and awk. It is easer in simplest cases than 
writing it on Python (especially when different Python binaries used).

I'm -0,1.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

Ah - the test used to do t.join(NUMTASKS)!  That's just bizarre ;-)

I believe I can repair that too (well - there was never a _guarantee_ that 
waiting 10 seconds would be long enough), but I'll wait until this all settles 
down.

join() and is_alive() are too complicated now, because of the 2-step dance to 
check whether the thread is done:  we have both an Event (_stopped) and a lock 
(_tstate_lock) to check now.  The Event doesn't serve a purpose anymore:  it's 
almost always uninteresting to know _just_ that the Python part of the thread 
has ended.  The only exception I can see is the perverse case of joining the 
main thread done in some of the tests (in that case we have to claim the main 
thread is done even though its tstate is still active).

Anyway, after getting rid of the Event it should be dead easy to make join(10) 
"appear to work the same as before, despite that it never really worked ;-)".

--

___
Python tracker 

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



[issue18973] Use argparse in the calendar module

2013-09-08 Thread R. David Murray

R. David Murray added the comment:

I think it is highly inadvisable to make changes like this without also adding 
tests.  We broke compileall by doing this even though we *did* add tests.

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



[issue18606] Add statistics module to standard library

2013-09-08 Thread Guido van Rossum

Guido van Rossum added the comment:

Nice docstrings, but those aren't automatically included in the Doc tree.

--

___
Python tracker 

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



[issue18936] 2.7 distutils getopt chokes on unicode option names

2013-09-08 Thread Jason R. Coombs

Jason R. Coombs added the comment:

oh. My mistake. I didn't realize the error was in 'distutils.fancy_getopt' and 
not in the getopt module itself. Indeed, the problem doesn't exist under getopt 
itself, so is specific to distutils and fancy_getopt.

>>> from __future__ import unicode_literals
>>> import getopt
>>> getopt.getopt('-x', 'x', ('--longx',))
([], u'-x')
>>>

--

___
Python tracker 

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



[issue18606] Add statistics module to standard library

2013-09-08 Thread Guido van Rossum

Guido van Rossum added the comment:

Here's a combined patch. Hopefully it will code review properly.

--
nosy: +gvanrossum
Added file: http://bugs.python.org/file31680/statistics_combined.patch

___
Python tracker 

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



[issue18953] Typo in NEWS about fixed format specifiers for Py_ssize_t in debugging output in the _sre module

2013-09-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Vajrasky. Actually there was no need to open a new issue for such 
minor bug. You can report on the same issue which caused this bug. I'm afraid 
there are a lot of more grave syntax and grammatic errors in my Misc/NEWS 
entries.

--

___
Python tracker 

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



[issue18953] Typo in NEWS about fixed format specifiers for Py_ssize_t in debugging output in the _sre module

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c08e92529f62 by Serhiy Storchaka in branch '3.3':
Fix a typo. (closes #18953)
http://hg.python.org/cpython/rev/c08e92529f62

New changeset 9dc5bdab157e by Serhiy Storchaka in branch 'default':
Fix a typo. (closes #18953)
http://hg.python.org/cpython/rev/9dc5bdab157e

New changeset 6ecdf5de6252 by Serhiy Storchaka in branch '2.7':
Fix a typo. (closes #18953)
http://hg.python.org/cpython/rev/6ecdf5de6252

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/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



[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread Armin Rigo

Armin Rigo added the comment:

Fwiw I agree with you :-)  I'm just relaying a bug report that originates on 
PyPy (https://bugs.pypy.org/issue1595).

--

___
Python tracker 

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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le dimanche 08 septembre 2013 à 17:30 +, Tim Peters a écrit :
> Really!  In context, the test does:
> 
> t.join()
> self.assertTrue(not t.is_alive())

Ah, no, the failing test did `t.join(something)`. I removed the timeout
to remove the failure :-)

> (BTW, that would be clearer as self.assertFalse(t.is_alive()) ;-) )

Yes, old coding style.

--

___
Python tracker 

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



[issue18966] Threads within multiprocessing Process terminate early

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

That's because multiprocessing exits child processes with os._exit(), not 
sys.exit().

The fix would be trivial (call threading._shutdown() before os._exit()), but I 
don't know if that's something we want to do. After all there are many things 
in the Python shutdown procedure that we may want to similarly replicate in 
multiprocessing children, such as calling atexit handlers. This screams for a 
more general solution, IMHO.

--
nosy: +neologix, pitrou, sbt
versions: +Python 3.4

___
Python tracker 

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



[issue18964] test_tcl fails when _tkinter linked with Tcl 8.4

2013-09-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 03ee22236465 by Serhiy Storchaka in branch '3.3':
Fixed tests with Tcl/Tk <8.5 (closes #18964).
http://hg.python.org/cpython/rev/03ee22236465

New changeset 138e086e187d by Serhiy Storchaka in branch 'default':
Fixed tests with Tcl/Tk <8.5 (closes #18964).
http://hg.python.org/cpython/rev/138e086e187d

New changeset a22cfd0bdc9a by Serhiy Storchaka in branch '2.7':
Fixed tests with Tcl/Tk <8.5 (closes #18964).
http://hg.python.org/cpython/rev/a22cfd0bdc9a

--
nosy: +python-dev
resolution:  -> fixed
stage: patch review -> committed/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



[issue18808] Thread.join returns before PyThreadState is destroyed

2013-09-08 Thread Tim Peters

Tim Peters added the comment:

[Antoine]
> Oh, I also get the following sporadic failure
> which is triggered by slight change in semantics
> with Thread.join(timeout) :-)
> ==
> FAIL: test_various_ops (test.test_threading.ThreadTests)
> --
> Traceback (most recent call last):
>  File "/home/antoine/cpython/default/Lib/test/test_threading.py", line 113, 
> in test_various_ops
>self.assertTrue(not t.is_alive())
> AssertionError: False is not true

Really!  In context, the test does:

t.join()
self.assertTrue(not t.is_alive())

(BTW, that would be clearer as self.assertFalse(t.is_alive()) ;-) )

It was the intent that this continue to work - the only intended change in 
Python-visible semantics had to do with join'ing with a timeout.

Without a timeout, I confess I don't see how this can fail.  join() is 
join(timeout=None), which does:

self._stopped.wait(timeout)
if self._stopped.is_set():
self._wait_for_tstate_lock(timeout is None)

which is

self._stopped.wait(None)
if self._stopped.is_set():
self._wait_for_tstate_lock(True)

which should be the same as

self._stopped.wait()
self._wait_for_tstate_lock(True)

after which _stopped should be set and _tstate_lock should be None.  The 
subsequent is_alive() should then return False, via its

return self._tstate_lock is not None

What's going wrong?

--

___
Python tracker 

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



[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3

paul j3 added the comment:

I should add that defaults with required arguments (or groups?) doesn't make 
much sense.  Still there's nothing in the code that prevents it.

--

___
Python tracker 

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



[issue18979] Use argparse in the uu module

2013-09-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Here is a patch which replaces optparse to argparse in the uu module.

--
components: Demos and Tools, Library (Lib)
files: uu_argparse.patch
keywords: patch
messages: 197289
nosy: bethard, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Use argparse in the uu module
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31679/uu_argparse.patch

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've added tests to capture the new behavior.

--

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Changes by Jason R. Coombs :


Added file: http://bugs.python.org/file31678/061eb75339e2.diff

___
Python tracker 

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



[issue12317] inspect.getabsfile() is not documented

2013-09-08 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +brett.cannon
versions: +Python 3.4 -Python 3.2

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> I personally dislike the "," as thousands separator, and if a
> separator is added at all I would prefer a space as defined in the SI 
> standard[0].

Then you really want a non-breaking space ;-)

(as a French person who's used to commas as decimal points, count me in the 
"commas as thousands separators are confusing" camp ;-))

> * whether it should always include the fractional part (in this
> example it doesn't make any sense)

Indeed, it probably doesn't make sense unless the number is < 100.
I would also put that information inside parentheses, as it is redundant with 
the per-loop timing.

> * maybe it should say "loops/s" rather than just "/s"

Yeah.

--
nosy: +pitrou

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Changes by Jason R. Coombs :


Added file: http://bugs.python.org/file31677/2b2744cfb08f.diff

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

I agree with both notes. Splitting the patch won't be a problem.

As much as I don't fancy "," as thousands separator either - I just used what's 
in the standard library but I'll think about the best way of putting spaces 
there.

--

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Changes by Jason R. Coombs :


--
keywords: +patch
Added file: http://bugs.python.org/file31676/6d6d68c068ad.diff

___
Python tracker 

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



[issue18929] inspect.classify_class_attrs ignores metaclass

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> It seems that currently inspect is geared towards instances and
> classes, not metaclasses.  Consequently, so is help.

I'm afraid I don't really understand what you're talking about. A
metaclass is just a slightly different kind of class :-)

> def classify_class_attrs(cls):
> """Return list of attribute-descriptor tuples.
> 
> For each name in dir(cls), the return list contains a 4-tuple
> with these elements:
[...]
> We could add additional 'kind' of 'hidden class method', and 'hidden
> class attributes' and then have classify_class_attrs explicitly search
> metaclasses.

The docstring is clear: "For each name in dir(cls)". If you want stuff
that hidden's in the cls.__class__ (and, consequently, not in dir(cls)),
then you are not looking for the right function, I think.

I can understand wanting to better automate lookup of methods on
classes, rather than on instances, but it would probably deserve another
function.

But I have another question first: doesn't calling
classify_class_attrs() on the metaclass already do what you want?

--

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've created a clone in which to draft this work.

--
hgrepos: +208

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Hi Jason, 

Agree with you. This design change could be valuable in extending 
urllib.request.Request

Thanks!

--
nosy: +orsenthil

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Ezio Melotti

Ezio Melotti added the comment:

I personally dislike the "," as thousands separator, and if a separator is 
added at all I would prefer a space as defined in the SI standard[0].

The PEP8 changes should also me moved to a separate patch IMHO; the other 
changes are OK grouped together.

[0]: http://en.wikipedia.org/wiki/ISO_31-0#Numbers

--
nosy: +ezio.melotti
stage:  -> patch review

___
Python tracker 

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



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

New submission from Jason R. Coombs:

In Python 2.x and 3.2, I used to use a Request subclass I created for 
overriding the method used:

class MethodRequest(request.Request):
def __init__(self, *args, **kwargs):
"""
Construct a MethodRequest. Usage is the same as for
`urllib.request.Request` except it also takes an optional 
`method`
keyword argument. If supplied, `method` will be used instead of
the default.
"""
if 'method' in kwargs:
self.method = kwargs.pop('method')
return request.Request.__init__(self, *args, **kwargs)

def get_method(self):
return getattr(self, 'method', request.Request.get_method(self))

In Python 3.3, which now supports a method parameter, it broke this paradigm 
(because the method is stored in the instance and is always set to None in 
__init__ if not specified).

I believe a paradigm where the method is stored as a class attribute and 
possibly overridden in an instance would be much better, allowing for 
subclasses to simply and directly override the method. For example:

class HeadRequest(MethodRequest):
method = 'HEAD'

That straightforward example works very well if method is allowed to be a class 
attribute, but won't work at all if 'method' is always set as an instance 
attribute in __init__.

And while it's possible for HeadRequest to override __init__, that requires 
HeadRequest to override that entire signature, which is less elegant than 
simply setting a class attribute.

For Python 3.4, I'd like to adapt the Request class to allow the Method to be 
defined at the class level (while still honoring customization at the instance 
level).

--
components: Library (Lib)
messages: 197281
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: Allow urllib.request.Request subclasses to override method
versions: Python 3.4

___
Python tracker 

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



[issue18929] inspect.classify_class_attrs ignores metaclass

2013-09-08 Thread Ethan Furman

Ethan Furman added the comment:

Okay, taking a step back.

It seems that currently inspect is geared towards instances and classes, not 
metaclasses.  Consequently, so is help.

So, how do we enhance inspect so that help can be metaclass aware?

classify_class_attrs seems like an obvious choice, and it's docstring currently 
says this:

def classify_class_attrs(cls):
"""Return list of attribute-descriptor tuples.

For each name in dir(cls), the return list contains a 4-tuple
with these elements:

0. The name (a string).

1. The kind of attribute this is, one of these strings:
   'class method'created via classmethod()
   'static method'   created via staticmethod()
   'property'created via property()
   'method'  any other flavor of method
   'data'not a method

2. The class which defined this attribute (a class).

3. The object as obtained directly from the defining class's
   __dict__, not via getattr.  This is especially important for
   data attributes:  C.data is just a data object, but
   C.__dict__['data'] may be a data descriptor with additional
   info, like a __doc__ string.
"""

We could add additional 'kind' of 'hidden class method', and 'hidden class 
attributes' and then have classify_class_attrs explicitly search metaclasses.

Or, since we have to make a new getmembers (getmetaclassmembers?), we could 
also make a new classify_metaclass_attrs that handled both class and metaclass.

--

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +tim.peters

___
Python tracker 

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



[issue18977] The -t option has no effect in for uu command-line

2013-09-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The uu module can be run as command-line tool. In Python 2, "uu -t infile 
outfile" opens input file in text mode, i.e. convert '\r\n' to '\n' on Windows 
and '\r' to '\n' on Mac Classic, and "uu -d -t infile outfile" opens output 
file in text mode, i.e. convert '\n' to '\r\n' on Windows and '\n' to '\r' on 
Mac Classic. In Python 3 this option has no effect.

The proposed patch restores former behavior and extends it. Encoding with -t 
option now uses universal newlines for reading, and decoding with -t option now 
converts '\n' to os.linesep for writing. In additional text mode now works with 
standard input/output.

This change perhaps is too large for the fix of such  insignificant bug and 
that is why I propose it as a new feature.

--
assignee: serhiy.storchaka
components: Demos and Tools, Library (Lib)
files: uu_text_mode.patch
keywords: patch
messages: 197279
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: The -t option has no effect in for uu command-line
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31675/uu_text_mode.patch

___
Python tracker 

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



[issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted

2013-09-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> One more substantial question: the top frame of the traceback is
> possibly still running.  Currently the code skips it by doing an
> initial 'tb = tb.tb_next'.  Would it be better to catch and ignore the
> RuntimeError 
> from frame.clear()?

Yes, I think it would be better.
Other than that, the doc lacks a "versionadded" tag.
Thanks!

--

___
Python tracker 

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



[issue18976] distutils/command/build_ext passes wrong linker flags

2013-09-08 Thread Benedikt Morbach

New submission from Benedikt Morbach:

At 
http://hg.python.org/cpython/file/1043cc2cb0ff/Lib/distutils/command/build_ext.py#l247
build_ext.py compares sys.executable against sys.exec_prefix.

When cross compiling cpython, it notices that the interpreter running the build 
is located at exec_prefix and concludes that it is building a third-party 
module.
Thus, it passes '-L{HOST_LIBDIR}', instead of '-L.', which breaks the build.

The attached patch reverses the logic, checking if sys.executable resides in 
${PWD} and assuming a third-party module otherwise.

This should also fix http://bugs.python.org/issue16326

--
assignee: eric.araujo
components: Cross-Build, Distutils, Extension Modules, Library (Lib)
files: 0001-make-sure-to-pass-L.-when-building-standard-extensio.patch
keywords: patch
messages: 197277
nosy: Benedikt.Morbach, eric.araujo, tarek
priority: normal
severity: normal
status: open
title: distutils/command/build_ext passes wrong linker flags
type: compile error
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5
Added file: 
http://bugs.python.org/file31674/0001-make-sure-to-pass-L.-when-building-standard-extensio.patch

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

Jakub Stasiak added the comment:

Oops, forgot to patch the tests, please find correct patch attached.

--
Added file: http://bugs.python.org/file31673/timeit-v2.patch

___
Python tracker 

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



[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3

paul j3 added the comment:

A possibly unintended consequence to this `seen_non_default_actions` testing is 
that default values do not qualify as 'present' when testing for a required 
mutually exclusive group.

p=argparse.ArgumentParser()
g=p.add_mutually_exclusive_group(required=True)
g.add_argument('--foo',default='test')
g.add_argument('--bar',type=int,default=42)
p.parse_args('--bar 42'.split())

raises an `error: one of the arguments --foo --bar is required`

In the original code

p.parse_args('--foo test'.split())

does not raise an error because 'test' does not qualify as default.  But with 
the change I proposed, it does raise the error.

This issue may require adding a `failures_when_required` category to the 
test_argparse.py MEMixin class.  Currently nothing in test_argparse.py tests 
for this issue.

Note that this contrasts with the handling of ordinarily required arguments.

p.add_argument('--baz',type=int,default=42,required=True)

'--baz 42' does not raise an error.  It is 'present' regardless of whether its 
value matches the default or not.

This argues against tightening the `seen_non_default_actions` test.  Because 
the current testing only catches a few defaults (None and small ints) it is 
likely that no user has come across the required group issue.  There might 
actually be fewer compatibility issues if we simply drop the default test (or 
limit it to the case where the default=None).

--

___
Python tracker 

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



[issue12317] inspect.getabsfile() is not documented

2013-09-08 Thread Akira Kitada

Changes by Akira Kitada :


--
nosy: +akitada

___
Python tracker 

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



[issue18975] timeit: Use thousands separators and print number of loops per second

2013-09-08 Thread Jakub Stasiak

New submission from Jakub Stasiak:

This patch includes:
* making code more PEP8-compatible and refactoring it a bit
* printing number of loops per second when using command line interface
* using thousands separators when printing numbers of loops (also in command 
line interface)
* changing examples in the module documentation

The output is changed from this:

1 loops, best of 3: 40.3 usec per loop

to that:

10,000 loops, best of 3: 34.6 usec per loop, 28,870.783/s

I'm still not sure about details of "28,870.783/s" part:
* whether it should always include the fractional part (in this example it 
doesn't make any sense)
* maybe it should say "loops/s" rather than just "/s"

--
components: Library (Lib)
files: timeit.patch
keywords: patch
messages: 197274
nosy: jstasiak
priority: normal
severity: normal
status: open
title: timeit: Use thousands separators and print number of loops per second
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31672/timeit.patch

___
Python tracker 

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



[issue18829] csv produces confusing error message when passed a non-string delimiter

2013-09-08 Thread R. David Murray

R. David Murray added the comment:

Parsing a csv file with no delimiter would seem to be meaningless, unless I'm 
misunderstanding what 'delimeter' controls.  So the error messages for 
delimiter and quotechar are necessarily different.

--

___
Python tracker 

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



[issue18962] Add special case for single iterator in heapq.merge function

2013-09-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Try this patch.

--
Added file: http://bugs.python.org/file31671/merge.diff

___
Python tracker 

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



[issue18829] csv produces confusing error message when passed a non-string delimiter

2013-09-08 Thread Vajrasky Kok

Vajrasky Kok added the comment:

After contemplating for a while, I am not sure that we should treat empty 
string for delimiter with error message: '"delimiter" must be an 1-character 
string'.

The reason is to keep consistency with quotechar keyword.

[sky@localhost cpython]$ ./python -c 'import csv; reader = csv.reader("foo", 
quotechar="")'
Traceback (most recent call last):
  File "", line 1, in 
TypeError: quotechar must be set if quoting enabled

[sky@localhost cpython]$ ./python -c 'import csv; reader = csv.reader("foo", 
quotechar="", quoting=csv.QUOTE_NONE)'
# No error, so implicitly quotechar is not set, but it is okay since we use 
"quote none" quoting.
# In other word, quotechar is not set by giving empty string to quotechar.

We could not change the behaviour of csv module, which is unsetting quotechar 
by giving empty string to quotechar and let it be if we use "quote none" 
quoting, to preserve backward compatibility.

So the error message should be, "The delimiter must be set" for empty string 
for delimiter, I suppose.

--

___
Python tracker 

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



[issue18973] Use argparse in the calendar module

2013-09-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> You forgot to upload the patch?

Again.

--
keywords: +patch
Added file: http://bugs.python.org/file31670/calendar_argparse.patch

___
Python tracker 

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



[issue18974] Use argparse in the diff script

2013-09-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +bethard

___
Python tracker 

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



  1   2   >