[issue16470] Backport set and dictionary comprehensions in tutorial to 2.7

2012-11-13 Thread Ezio Melotti

Changes by Ezio Melotti :


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

___
Python tracker 

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



[issue16470] Backport set and dictionary comprehensions in tutorial to 2.7

2012-11-13 Thread Yongzhi Pan

New submission from Yongzhi Pan:

Dictionary and set comprehensions are backported to 2.7 in issue #2333. The are 
not documented in the tutorial of 2.7, though they are in the language 
reference. Is it OK to add these to the tutorial? I've uploaded a patch.

--
assignee: docs@python
components: Documentation
files: set_and_dict_comprehensions.diff
keywords: patch
messages: 175547
nosy: docs@python, fossilet
priority: normal
severity: normal
status: open
title: Backport set and dictionary comprehensions in tutorial to 2.7
type: enhancement
versions: Python 2.7
Added file: http://bugs.python.org/file27982/set_and_dict_comprehensions.diff

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> > Does this regression impact any real-world program?
> 
> That is a blow-off response.  A huge swath of the language is affected
> by dictionary performance (keyword args, module lookups, attribute
> lookup, etc).

I was merely suggesting to report actual (non-micro) benchmark numbers.
This issue is about dict creation, not dict lookups.

--

___
Python tracker 

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



[issue14373] C implementation of functools.lru_cache

2012-11-13 Thread Ezio Melotti

Ezio Melotti added the comment:

See also #12428.

--

___
Python tracker 

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



[issue16157] Irrelevant references to Misc/News

2012-11-13 Thread Ezio Melotti

Ezio Melotti added the comment:

Even better would be to link to the changelog page instead, but that's only 
available for Python 3.3/3.4 (does this issue affect 2.7/3.2?).

http://docs.python.org/3.3/whatsnew/changelog.html

--
nosy: +ezio.melotti, georg.brandl
stage:  -> needs patch

___
Python tracker 

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



[issue12428] functools test coverage

2012-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> > Possibly reduce could be handled in a similar way with a fallback python
> > implementation? Otherwise your suggestion of conditionally adding it to 
> > __all__
> > makes sense to me.
> 
> In the meantime I'd expect the import of _functools.reduce to not be
> wrapped in a try block.  Does that have an impact on coverage?

I tried to remove the try block, but when making the import
unconditional the tests fail with an ImportError (because reduce doesn't
have a pure Python implementation). I haven't investigated further,
since the try block doesn't look like a real issue to me.

--

___
Python tracker 

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



[issue16469] Exceptions raised by Fraction() from those raised by int()

2012-11-13 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti, mark.dickinson, rhettinger, skrah
type:  -> behavior

___
Python tracker 

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



[issue16460] Strange results for floor division ("//") with non-integer divisors

2012-11-13 Thread Tom Pohl

Tom Pohl added the comment:

This is "a fact-of-life for anyone using binary floating point":
x = 0.0
while x != 1.0: print(x); x += 0.1  # so long


This is not: 1 // 0.1 = 9.0 because math.floor(1/0.1) is able to come up with 
the result that is expected from an operator called "floor division".

Aynway, I'm curios, what's your use case for FD? Since all of you are so 
strongly in favor of the current behavior you must be using it all the time.

--

___
Python tracker 

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



[issue2333] Backport set and dict comprehensions

2012-11-13 Thread Ezio Melotti

Ezio Melotti added the comment:

> Is it OK to add these to the tutorial? I've uploaded a patch.

Yes, but please create a new issue.

> How about fixing set.__repr__ ?

Is it broken?

--

___
Python tracker 

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



[issue14373] C implementation of functools.lru_cache

2012-11-13 Thread Ezio Melotti

Ezio Melotti added the comment:

I wonder if we should keep the original Python implementation alongside the new 
C version.  If we do, it would be nice to see a 100% coverage of the Python 
version and have the tests check both the implementations.

--

___
Python tracker 

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



[issue2333] Backport set and dict comprehensions

2012-11-13 Thread Yongzhi Pan

Yongzhi Pan added the comment:

Great they are backported to 2.7.  Dictionary and set comprehensions are not 
documented in the tutorial of 2.7, though they are in the language reference. 
Is it OK to add these to the tutorial? I've uploaded a patch.

--
nosy: +fossilet
Added file: http://bugs.python.org/file27981/set_and_dict_comprehensions.diff

___
Python tracker 

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



[issue16460] Strange results for floor division ("//") with non-integer divisors

2012-11-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, I agree with this being closed.  The current behavior is a fact-of-life 
for anyone using binary floating point.   

The decimal module is provided people who want more intuitive behaviors when 
dividing by numbers like 0.1 which are exactly representable as a decimal 
fraction but not as a binary fraction.

--
nosy: +rhettinger

___
Python tracker 

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



[issue16460] Strange results for floor division ("//") with non-integer divisors

2012-11-13 Thread Tom Pohl

Tom Pohl added the comment:

You still get me wrong. Thanks to your explanations and to my personal 
knowledge about this topic (programming for 28 years now; PhD in 
CS/numerics/HPC) I now fully understand the technical details about the current 
implementation of FD. The problem I see is that the average Python user does 
and should not care about such details.

I talked to a bunch of people (n=7) here at the company where I also give 
Python courses from time to time. I asked them two questions:
1. Is this behavior of FD what you would expect?
2. Given the current behavior of FD, what use cases do you see?

The answers were always the same (and I tend to agree):
1. No.
2. No idea.

All of you seem to answer the first questions with yes, but what's your answer 
to the second question? What would you recommend your 10-year-old son or your 
62-year-old mother to do with the current FD operator?

--

___
Python tracker 

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



[issue16469] Exceptions raised by Fraction() from those raised by int()

2012-11-13 Thread Case Van Horsen

New submission from Case Van Horsen:

When attempting to convert a float("nan"), float("inf"), or float("-inf"), 
fractions.Fraction() raises different exceptions than int()

>>> int(float("nan"))
Traceback (most recent call last):
  File "", line 1, in 
ValueError: cannot convert float NaN to integer
>>> fractions.Fraction(float("nan"))
Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/local/lib/python3.2/fractions.py", line 114, in __new__
value = Fraction.from_float(numerator)
  File "/opt/local/lib/python3.2/fractions.py", line 186, in from_float
raise TypeError("Cannot convert %r to %s." % (f, cls.__name__))
TypeError: Cannot convert nan to Fraction.
>>> int(float("inf"))
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: cannot convert float infinity to integer
>>> fractions.Fraction(float("inf"))
Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/local/lib/python3.2/fractions.py", line 114, in __new__
value = Fraction.from_float(numerator)
  File "/opt/local/lib/python3.2/fractions.py", line 186, in from_float
raise TypeError("Cannot convert %r to %s." % (f, cls.__name__))
TypeError: Cannot convert inf to Fraction.
>>> int(float("-inf"))
Traceback (most recent call last):
  File "", line 1, in 
OverflowError: cannot convert float infinity to integer
>>> fractions.Fraction(float("-inf"))
Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/local/lib/python3.2/fractions.py", line 114, in __new__
value = Fraction.from_float(numerator)
  File "/opt/local/lib/python3.2/fractions.py", line 186, in from_float
raise TypeError("Cannot convert %r to %s." % (f, cls.__name__))
TypeError: Cannot convert -inf to Fraction.

Should the exceptions be changed to ValueError and OverflowError?

--
components: Library (Lib)
messages: 175536
nosy: casevh
priority: normal
severity: normal
status: open
title: Exceptions raised by Fraction() from those raised by int()
versions: Python 3.3

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread Anthony Tuininga

Anthony Tuininga added the comment:

Thanks to Amaury for his suggestion. It resolves the problem completely and 
answers the question I had about how to proceed. For others who may come across 
this, the key was to generate the importlib._bootstrap module (which is what is 
found in importlib.h) directly, rather than by including the private generated 
file.

--
status: open -> closed

___
Python tracker 

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



[issue16468] argparse only supports iterable choices

2012-11-13 Thread Chris Jerdonek

New submission from Chris Jerdonek:

This issue is to ensure that argparse.ArgumentParser() accepts objects that 
support the "in" operator for the "choices" argument to 
ArgumentParser.add_argument().

As observed by Terry in the comments to issue 16418:

http://bugs.python.org/issue16418#msg175520

the argparse module does not in general support "choices" values that support 
the "in" operator, even though the argparse documentation says it does:

"Any object that supports the in operator can be passed as the choices value, 
so dict objects, set objects, custom containers, etc. are all supported."

(from http://docs.python.org/2/library/argparse.html#choices )

For example, passing a user-defined type that implements only 
self.__contains__() yields the following error message when calling 
ArgumentParser.parse_args():

File ".../Lib/argparse.py", line 1293, in add_argument
  raise ValueError("length of metavar tuple does not match nargs")

(The error message also gives the wrong reason for failure.  The swallowed 
exception is "TypeError: '' object is not iterable.")

--
components: Library (Lib)
messages: 175534
nosy: chris.jerdonek, terry.reedy
priority: normal
severity: normal
status: open
title: argparse only supports iterable choices
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue14373] C implementation of functools.lru_cache

2012-11-13 Thread Matt Joiner

Matt Joiner added the comment:

I look forward to your feedback Ezio.

--

___
Python tracker 

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



[issue12428] functools test coverage

2012-11-13 Thread Eric Snow

Eric Snow added the comment:

> Possibly reduce could be handled in a similar way with a fallback python
> implementation? Otherwise your suggestion of conditionally adding it to 
> __all__
> makes sense to me.

In the meantime I'd expect the import of _functools.reduce to not be wrapped in 
a try block.  Does that have an impact on coverage?

>> * Should the pure Python partial only be used if _functools.partial is not 
>> available?
>> * Should _functools.partial be removed?
>
> What are the main considerations to properly answer these last questions? 
> Performance
> comparison between the implementations, maintainability?

Sorry, the first time through I missed the part of the patch that tries to 
import _functools.partial _after_ the pure Python version is defined.

--

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> Does this regression impact any real-world program?

That is a blow-off response.  A huge swath of the language is affected by 
dictionary performance (keyword args, module lookups, attribute lookup, etc).  
Most programs will be affected to some degree -- computationally bound programs 
will notice more and i/o bound programs won't notice at all.

--
nosy: +rhettinger
priority: normal -> high

___
Python tracker 

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



[issue12428] functools test coverage

2012-11-13 Thread Brian Thorne

Brian Thorne added the comment:

> * Why the try block when there wasn't one before?
> * Should reduce be added to __all__ only conditionally?

My mistake, the try block should have just covered the import of partial - that 
is after all the exceptional circumstance we can deal with by using the pure 
python implementation.

Possibly reduce could be handled in a similar way with a fallback python 
implementation? Otherwise your suggestion of conditionally adding it to __all__ 
makes sense to me.

> * Should the pure Python partial only be used if _functools.partial is not 
> available?
> * Should _functools.partial be removed?

What are the main considerations to properly answer these last questions? 
Performance comparison between the implementations, maintainability?

--

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread Eric Snow

Changes by Eric Snow :


--
nosy: +brett.cannon, eric.snow

___
Python tracker 

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



[issue8400] zipimporter find_module fullname mis-documented

2012-11-13 Thread Eric Snow

Changes by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue12428] functools test coverage

2012-11-13 Thread Eric Snow

Eric Snow added the comment:

The following from the changeset left me with questions:

-from _functools import partial, reduce
+try:
+from _functools import reduce
+except ImportError:
+pass

* Why the try block when there wasn't one before?
* Should reduce be added to __all__ only conditionally?
* Should the pure Python partial only be used if _functools.partial is not 
available?
* Should _functools.partial be removed?

--
nosy: +eric.snow

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Does this regression impact any real-world program?

--

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread Thomas Kluyver

Changes by Thomas Kluyver :


--
nosy: +takluyver

___
Python tracker 

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



[issue14260] re.groupindex is available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread py.user

Changes by py.user :


--
title: re.groupindex available for modification and continues to work, having 
incorrect data inside it -> re.groupindex is available for modification and 
continues to work, having incorrect data inside it

___
Python tracker 

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



[issue15478] UnicodeDecodeError on OSError on Windows with undecodable (bytes) filename

2012-11-13 Thread STINNER Victor

Changes by STINNER Victor :


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

___
Python tracker 

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



[issue8400] zipimporter find_module fullname mis-documented

2012-11-13 Thread Te-jé Rodgers

Te-jé Rodgers added the comment:

I have also just been bitten by this. Is there anyway that this can be updated 
to support the dotted notation?

--
nosy: +tjd.rodgers

___
Python tracker 

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



[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

2012-11-13 Thread Karthk Rajagopalan

Karthk Rajagopalan added the comment:

Hi Tim,

Thanks for your reply.

I added test case using perl and python since it was easy to reproduce using 
perl socket module and show the issue happening with python's subprocess.py. 
There is definitely an action required in subprocess.py to catch 'invalid 
handle error' and my attached patch handle this situation.

I can come up with a test case like perl does to create a listening socket and 
map the socket handle to a file descriptor. You will see this issue *only* when 
the open_osfhandle(..) is used to map the handle to a file descriptor.

-Karthik

--

___
Python tracker 

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



[issue8865] select.poll is not thread safe

2012-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> > Would you please submit a PSF contributor agreement form?
> 
> FYI: did that yesterday 9:43 UTC, no reaction (yet)

Don't worry, it can take some time to process. We can still apply your
patch, though, since you said you sent a contributor agreement.

--

___
Python tracker 

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



[issue12428] functools test coverage

2012-11-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Sorry for the delay. I have now committed the patch to 3.4 (default). Thank you!

--
resolution:  -> fixed
stage: commit review -> committed/rejected
status: open -> closed
versions: +Python 3.4 -Python 3.3

___
Python tracker 

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



[issue12428] functools test coverage

2012-11-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fcfaca024160 by Antoine Pitrou in branch 'default':
Issue #12428: Add a pure Python implementation of functools.partial().
http://hg.python.org/cpython/rev/fcfaca024160

--
nosy: +python-dev

___
Python tracker 

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



[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

2012-11-13 Thread Tim Golden

Tim Golden added the comment:

I'm sorry, but I genuinely can't see what you're trying to say here. If you 
believe that there's a bug in Python's standard library, can you show a 
reproducible *Python* testcase for it, please (using the pywin32 modules if 
that helps) and state clearly what you think is wrong.

--
nosy: +tim.golden

___
Python tracker 

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



[issue16298] httplib.HTTPResponse.read could potentially leave the socket opened forever

2012-11-13 Thread Shivaram Lingamneni

Changes by Shivaram Lingamneni :


--
nosy: +slingamn

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

I tried to remove all references to "#include importlib.h" and 
_Py_M__importlib, and added the lines in _AddBaseModules():

self.AddAlias("_frozen_importlib", "importlib._bootstrap")
self.IncludeModule("_frozen_importlib")

Even if it's not optimal (the content importlib.h is recomputed by cx_Freeze), 
it's much better...  The resulting binary I made fails with:
  Fatal Python error: Py_Initialize: Unable to get the locale encoding
  ImportError: No module named 'encodings'
But it's probably because my Python3 is not "installed" properly.

--
nosy: +amaury.forgeotdarc

___
Python tracker 

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



[issue13615] setup.py register fails with -r argument

2012-11-13 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy:  -terry.reedy

___
Python tracker 

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



[issue16418] argparse with many choices can generate absurdly long usage message

2012-11-13 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I do not agree with the patch. A summary of my view: Range objects support the 
'in' operator and they are an intended option for choices, and, as I said 
before, are exactly the right option for arithmetic sequences with more than a 
few items. The problem is that they are now, in effect, special-cased relative 
to other builtins by having their compact representation replaced by an 
expanded tuple display. Moreover, the iteration required to do this introduces 
a discrepancy relative to the doc. This bug might be better fixed by a code 
change.

(The OP did not pass a (x)range object but a list. That was unnecessary and 
easily fixed in itself. But such a fix leaves the issue above. Condensing long 
sequences is a somewhat separate issue.)

As to intent:

"The choices keyword argument may be more convenient for type checkers that 
simply check against a range of values:
>>>

>>> parser = argparse.ArgumentParser(prog='PROG')
>>> parser.add_argument('foo', type=int, choices=range(5, 10))
>>> parser.parse_args('7'.split())
Namespace(foo=7)
>>> parser.parse_args('11'.split())
usage: PROG [-h] {5,6,7,8,9}
PROG: error: argument foo: invalid choice: 11 (choose from 5, 6, 7, 8, 9)"

Note the expansion instead of the normal representation. It is not a big deal 
here, but obviously can be.

">>> parser.add_argument(
... 'integers', metavar='int', type=int, choices=range(10),
...  nargs='+', help='an integer in the range 0..9')"

As to tuple display expansion: the link points to

2284 def _check_value(self, action, value):
2285   # converted value must be one of the choices (if specified)
2286   if action.choices is not None and value not in action.choices:
2287 args = {'value': value,
2288 'choices': ', '.join(map(repr, action.choices))}
2289 msg = _('invalid choice: %(value)r (choose from %(choices)s)')
2290 raise ArgumentError(action, msg % args)

In 2288 "', '.join(map(repr, action.choices))" produces a tuple display without 
parentheses. It essentially reproduced str/repr for tuples, lists, frozensets, 
sets, dicts, dict views, etc., leaving off the irrelevant fence characters. In 
doing so, by iteration, it introduces a bug --see below.

For range objects, the tuple representation is a drastic change from the normal 
representation. In that sense, it special cases range among built-ins, and in a 
bad way when the range represents many values. (Help messages apparently do the 
same.) I consider this to be something of a bug. So the code as it is would 
have to special case range objects to avoid special-casing them in the sense 
above.

The same would apply to any custom objects that have a succinct description for 
a large, possible infinite set. Here are two examples: "a word containing no 
'e's" and "a 'word' containing only the letters a, b, c, d, e". Objects 
representing such infinite sets of strings could easily have a __contains__ 
method but not an __iter__ method.

The code above requires the choices object to be iterable as well as supporting 
'in'. This contradicts the doc statement "Any object that supports the in 
operator can be passed as the choices value,". That discrepancy is a bug. It 
should be fixed by either adding the restriction to the doc or removing it from 
the code. I recommend the latter.

The code could simply use the str or repr of the choice object without trying 
to be fancy with a custom, fence-stripped, representation that does not work 
correctly or at all for all possible choice objects. In other words

if action.choices is not None and value not in action.choices:
  msg = "invalid choice: %r (choose from %r)" % (value, action.choices)
  raise ArgumentError(action, msg)

If the custom representation for non-range builtins is desired, then they are 
the ones that should be special-cased to not use their default representation.

--
assignee: docs@python -> 
keywords:  -easy

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread Anthony Tuininga

Anthony Tuininga added the comment:

The file importlib.h is used when building the Python interpreter but it is 
*not* available in a standard (non-source) distribution of Python. I have 
copied the file from a source distribution of Python and that does in fact 
work, but I don`t want to make use of what is intended to be a private 
implementation detail. I am the author of cx_Freeze and trying to make it work 
correctly with Python 3.3. What I am looking for here is what I should be doing 
instead or asking for API that I can use. I hope that explains things better.

--

___
Python tracker 

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



[issue16466] register command forgets password if no config file is created

2012-11-13 Thread Éric Araujo

Éric Araujo added the comment:

Thanks.  I remember previous discussion about this (mailing list or bug), I’ll 
look for it before applying.

--
stage:  -> patch review
type:  -> behavior
versions: +Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue11473] upload command no longer accepts repository by section name

2012-11-13 Thread Éric Araujo

Éric Araujo added the comment:

If you read the first message again, or the docs, you can see that -r repo-name 
was indeed supported.

--
title: upload command no longer accepts repository by section   name -> upload 
command no longer accepts repository by section name
versions: +Python 3.4

___
Python tracker 

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



[issue16157] Irrelevant references to Misc/News

2012-11-13 Thread Chris Jerdonek

Changes by Chris Jerdonek :


--
nosy: +chris.jerdonek

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread R. David Murray

R. David Murray added the comment:

The file certainly exists, since Python requires it to run.  It sounds like 
cx_Freeze just doesn't support Python3.3 yet.  I don't see that this is a 
Python bug.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue16467] frozen importlib required for extending Python interpreter not public

2012-11-13 Thread Anthony Tuininga

New submission from Anthony Tuininga:

With Python 3.3, the ability to create a Python interpreter independent of a 
Python installation (as is done with cx_Freeze and other such freezing tools) 
has become more difficult to accomplish. Py_Initialize() requires the presence 
of a frozen importlib module which is found in importlib.h, but that include 
file is not available in the public include files section of a Python 
distribution. I have copied it for my use but that seems wrong. Please advise 
on how this should take place now. Thanks.

--
components: None
messages: 175515
nosy: atuining
priority: normal
severity: normal
status: open
title: frozen importlib required for extending Python interpreter not public
type: behavior
versions: Python 3.3

___
Python tracker 

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



[issue11473] upload command no longer accepts repository by section name

2012-11-13 Thread anatoly techtonik

anatoly techtonik added the comment:

So, if upload command never accepted repository by section name I am +1 for 
closing this issue (and opening a new one if symlink workaround is required).

--
nosy: +techtonik

___
Python tracker 

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



[issue16466] register command forgets password if no config file is created

2012-11-13 Thread anatoly techtonik

anatoly techtonik added the comment:

Fix is attached.

--
Added file: http://bugs.python.org/file27980/register.py.2.diff

___
Python tracker 

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



[issue16466] register command forgets password if no config file is created

2012-11-13 Thread anatoly techtonik

New submission from anatoly techtonik:

Given:

1. there is no .pypirc
2. users enters credentials to register command
3. user refuses to create .pypirc

Outcome:

password is not being stored and subsequent (upload) command doesn't get it.

Attached is the test case.

--
assignee: eric.araujo
components: Distutils
files: test_register.py.2.diff
keywords: patch
messages: 175512
nosy: eric.araujo, tarek, techtonik
priority: normal
severity: normal
status: open
title: register command forgets password if no config file is created
versions: Python 2.7
Added file: http://bugs.python.org/file27979/test_register.py.2.diff

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

May be using the free list for keys will restore performance.

--
nosy: +benjamin.peterson, pitrou

___
Python tracker 

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



[issue13615] setup.py register fails with -r argument

2012-11-13 Thread anatoly techtonik

anatoly techtonik added the comment:

Fix.

--
Added file: http://bugs.python.org/file27978/register.py.diff

___
Python tracker 

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



[issue13615] setup.py register fails with -r argument

2012-11-13 Thread anatoly techtonik

anatoly techtonik added the comment:

Better test case.

--
Added file: http://bugs.python.org/file27977/test_register.py.diff

___
Python tracker 

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



[issue13615] setup.py register fails with -r argument

2012-11-13 Thread Éric Araujo

Éric Araujo added the comment:

Thanks, this helps.

--
stage: test needed -> needs patch
versions: +Python 3.4

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah, this is an effect of PEP 412.  The difference exists only for creating 
dicts up to 5 items (inclusive).

--

___
Python tracker 

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



[issue13615] setup.py register fails with -r argument

2012-11-13 Thread anatoly techtonik

anatoly techtonik added the comment:

Tested on Windows. Test is attached.

--
keywords: +patch
Added file: http://bugs.python.org/file27976/test_register.py.diff

___
Python tracker 

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



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Copy or proxy may affect performance.  We will need to make benchmarks to see 
how much.

--

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I confirm that.

$ ./python -m timeit -n 100 '{};{};{};{};{};{};{};{};{};{}'

2.6: 0.62 usec
2.7: 0.57 usec
3.1: 0.55 usec
3.2: 0.48 usec
3.3: 1.5 usec

Randomization is not affecting it.

--
keywords: +3.3regression
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue16465] dict creation performance regression

2012-11-13 Thread Philipp Hagemeister

New submission from Philipp Hagemeister:

On my system, {}  has become significantly slower in 3.3:

$ python3.2 -m timeit -n 100 '{}'
100 loops, best of 3: 0.0314 usec per loop
$ python3.3 -m timeit -n 100 '{}'
100 loops, best of 3: 0.0892 usec per loop
$ hg id -i
ee7b713fec71+
$ ./python -m timeit -n 100 '{}'
100 loops, best of 3: 0.0976 usec per loop

Is this because of the dict randomization?

--
components: Interpreter Core
messages: 175503
nosy: phihag
priority: normal
severity: normal
status: open
title: dict creation performance regression
type: performance
versions: Python 3.3, Python 3.4

___
Python tracker 

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



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Éric Araujo

Éric Araujo added the comment:

I propose using a MappingProxy type in 3.4 and add an example to the docs for 
stable versions.

--
resolution: invalid -> 
stage:  -> needs patch
versions: +Python 2.7, Python 3.3, Python 3.4

___
Python tracker 

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



[issue8865] select.poll is not thread safe

2012-11-13 Thread Christian Schubert

Christian Schubert added the comment:

> Would you please submit a PSF contributor agreement form?

FYI: did that yesterday 9:43 UTC, no reaction (yet)

--

___
Python tracker 

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



[issue16457] Allow operator 'getter' methods to take a list and return a tuple

2012-11-13 Thread R. David Murray

R. David Murray added the comment:

Given Nick's point about itemgetter, I agree this isn't worth doing.  I 
wouldn't want the signatures of attrgetter and itemgetter to no longer be 
parallel.

Min isn't a problem, by the way, since it accepts an iterator as a single 
argument.

--
resolution:  -> rejected
stage: needs patch -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue16418] argparse with many choices can generate absurdly long usage message

2012-11-13 Thread Chris Jerdonek

Chris Jerdonek added the comment:

> Does argparse actually convert (x)range objects to a list or set (the help 
> indicates the latter) for internal use?

No, it leaves the provided choices argument as is.

Here is what the documentation says argparse accepts: "Any object that supports 
the *in* operator can be passed as the choices value, so dict objects, set 
objects, custom containers, etc. are all supported."  And here is the code for 
testing containment:

http://hg.python.org/cpython/file/ee7b713fec71/Lib/argparse.py#l2284

Terry, are you okay with the proposed documentation patch?

Special-casing the display of range values seems like an enhancement request to 
me rather than a bug.  I would suggest that be handled as an enhancement 
request targeted initially for Python 3.4.  I would be happy to create a new 
issue for that.  Alternatively, it could be considered as a second patch on 
this issue.

--

___
Python tracker 

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



[issue7083] locals() behaviour differs when tracing is in effect

2012-11-13 Thread Ned Batchelder

Ned Batchelder added the comment:

ITSM this could use more clarification.  It is subtle and baffling.  I'm 
struggling to come up with sentences to make it clearer, though.

--
nosy: +nedbat

___
Python tracker 

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



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Stefan Krah

Changes by Stefan Krah :


--
title: re.grupindex available for modification and continues to work, having 
incorrect data inside it -> re.groupindex available for modification and 
continues to work, having incorrect data inside it

___
Python tracker 

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



[issue14260] re.grupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Abel Farias

Changes by Abel Farias :


--
nosy: +Abel.Farias

___
Python tracker 

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



[issue14260] re.grupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Abel Farias

Changes by Abel Farias :


--
title: re.groupindex available for modification and continues to work, having 
incorrect data inside it -> re.grupindex available for modification and 
continues to work, having incorrect data inside it

___
Python tracker 

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



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Stefan Krah

Stefan Krah added the comment:

I'm not so sure. If dicts or classes are used for configuration
or informational purposes, I prefer them to be locked down.

An example of the first is the decimal context, where it was possible
to write context.emax = 9 instead of context.Emax = 9 without getting
an error. This is an easy mistake to make and can be hard to track
down in a large program.

The mistake here is maybe less likely, but I agree with Georg that
it's a case for a read-only dict/dictproxy.

--
nosy: +skrah
status: pending -> open

___
Python tracker 

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



[issue15599] test_circular_imports() of test_threaded_import fails on FreeBSD 9.0

2012-11-13 Thread Stefan Krah

Stefan Krah added the comment:

Well, there was a test_circular_imports() failure on (I think) the
Windows-amd64 bot last week, but I can't access it any more.

--
status: pending -> open

___
Python tracker 

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



[issue16460] Strange results for floor division ("//") with non-integer divisors

2012-11-13 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Am 12.11.12 14:53, schrieb Tom Pohl:
> What do I expect from FD (x//y):
> 1. Perform a division (I don't care about the details here).
> 2. Return an integer value q (even if it's stored in a float).
> 3. The absolute difference between the mathematical division q'=x/y and the 
> returned result q is less than 1, since it's just a floor operation, right?
>
> 1//0.1 = 9.0 violates my personal last expectation and I guess I'm not the 
> only one.

However, it matches *precisely* your description of what you expect:

1. 1 divided-by 0.1 gives
9.99944488848768742176060306327615036178207623262235371852234374499248...

Please understand that the correct result of 1 divided-by 0.1 is *not* 
10, because 0.1 is *not* 1/10.

2. returned is then the integer 9

3. the difference is
.99944488848768742176060306327615036178207623262235371852234374499248...
which is indeed smaller than 1.

P.S. In case you want to get a more exact result of 1 divided-by 0.1, 
get the digits from

int(1/fractions.Fraction(0.1)*10**180)

--

___
Python tracker 

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



[issue14260] re.groupindex available for modification and continues to work, having incorrect data inside it

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I fully agree with Éric.  Just don't do this.

--
nosy: +serhiy.storchaka
resolution:  -> invalid
status: open -> pending

___
Python tracker 

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



[issue10395] new os.path function to extract common prefix based on path components

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Some conclusions of discussion at Python-ideas 
(http://comments.gmane.org/gmane.comp.python.ideas/17719):

1. commonpath() should eat double slashes in input (['/usr/bin', '/usr//bin'] 
-> '/usr/bin').  In any case the current implementation eats slashes on output 
(['/usr//bin', '/usr//bin'] -> '/usr/bin', not '/usr//bin').

2. commonpath() should raise an exception instead of returning None on 
incompatible input.

3. May be commonpath() should eat also '.' components and return '.' instead of 
'' when relative paths have no common prefix. I am not sure.

In general the current patch looks good enough.

--

___
Python tracker 

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



[issue16047] Tools/freeze no longer works in Python 3

2012-11-13 Thread Andreas Stührk

Andreas Stührk added the comment:

See also issue #11824 for the ABI tags changes.

--
nosy: +Trundle

___
Python tracker 

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



[issue16339] Document "exec(stmt, global_dict, local_dict)" form in Python 2?

2012-11-13 Thread Mark Dickinson

Changes by Mark Dickinson :


--
assignee: docs@python -> mark.dickinson

___
Python tracker 

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



[issue13349] Non-informative error message in index() and remove() functions

2012-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also my comments to previous patch about repr() and error message checking.

--

___
Python tracker 

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



[issue15478] UnicodeDecodeError on OSError on Windows with undecodable (bytes) filename

2012-11-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ee7b713fec71 by Victor Stinner in branch 'default':
Issue #15478: os.lchflags() is not always available when os.chflags() is 
available
http://hg.python.org/cpython/rev/ee7b713fec71

--

___
Python tracker 

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