[issue22695] open() declared deprecated in python 3 docs

2014-11-03 Thread Georg Brandl

Georg Brandl added the comment:

LGTM.

--

___
Python tracker 

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



[issue22775] SimpleCookie not unpicklable with protocol 2+

2014-11-03 Thread Georg Brandl

Georg Brandl added the comment:

Thanks!

--

___
Python tracker 

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



[issue22758] Regression in Python 3.2 cookie parsing

2014-11-03 Thread Georg Brandl

Georg Brandl added the comment:

That seems like the best course of action.

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Georg Brandl

Georg Brandl added the comment:

You add a label before that section and then reference it with :ref:.

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

How about:

Special value which should be returned by the binary special methods
(e.g. :meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, :meth:`__rsub__`,
etc.) to indicate that the operation is not implemented with respect to
the other type; may be returned by the in-place binary special methods
(e.g. :meth:`__imul__`, :meth:`__iand__`, etc.) for the same purpose.
Its truth value is true.

Note::
When NotImplemented is returned, the interpreter will then try the
reflected operation on the other type, or some other fallback, depending
on the operator.  If all attempted operations return NotImplemented, the
interpreter will raise an appropriate exception.


I have no idea how to create a link to the 'Implementing the arithmetic 
operations' section.  Any clues?

--

___
Python tracker 

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



[issue21931] Nonsense errors reported by msilib.FCICreate for bad argument

2014-11-03 Thread Martin v . Löwis

Martin v. Löwis added the comment:

I haven't had any time to work on Python in the last year, so it may take some 
more time for me to look into this.

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

Thank you, Raymond, both for your concern and your discretion.

My interest in changing the "can" or "may" to "should" is that, whatever the 
original intent of the PEP, the way Python works /now/ is that any class that 
doesn't return NotImplemented when it /should/ is not going to interoperate 
well with other compatible classes.

At the heart of the issue is what happens when

  def bin_op(self, other):
 ...

is called, but the left-hand operand doesn't know how to work with the 
right-hand operand?

We have three choices:

  - do nothing, letting any exceptions boil up or errors propagate

  - do a check on 'other' to determine if it's usable, and raise an exception
if it is not

  - do a check on 'other' to determine if it's usable, and return NotImplemented
if it is not

Only the last choice allows 'other' to also try the operation.  Except for the 
special-case of in-place bin-ops, why would we not want choice three?

--

___
Python tracker 

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



[issue22789] Compress the marshalled data in PYC files

2014-11-03 Thread Raymond Hettinger

Changes by Raymond Hettinger :


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

___
Python tracker 

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



[issue22789] Compress the marshalled data in PYC files

2014-11-03 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Looking into this further, I suspect that the cleanest way to implement this 
would be to add a zlib compression and decompression using to the marshal.c 
(bumping the version number to 5).

--

___
Python tracker 

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



[issue22789] Compress the marshalled data in PYC files

2014-11-03 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Looking into this further, I suspect that the cleanest way to implement this 
would be to add a marshal version 4 that compresses and decompresses using zlib.

--
components: +Interpreter Core
nosy: +brett.cannon, pitrou

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Raymond Hettinger

Changes by Raymond Hettinger :


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

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, I think doc changes like this need to be made by the people most familiar 
with the implementation details and with the original design intent (i.e. the 
authors of PEP 207).

The knowledge here is fragile and it would be easy to accidentally make-up new 
normative rules that aren't actually true or necessary, or to subtly 
misrepresent what was trying to be accomplished originally.  The risk is 
greatest when the OP is just now learning the ins and outs of NotImplemented 
(i.e. whether in-place operations can or should return NotImplemeted or whether 
those operations can be duck typed).

Changing "can be returned" to "should be returned" is normative (making-up a 
new rule without sufficient discussion).  This doesn't add explanation; 
instead, instead, it make a rule change about how a feature should be used.
https://hg.python.org/cpython/rev/26d0a17affb5

--
nosy: +gvanrossum, rhettinger, tim.peters

___
Python tracker 

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-03 Thread Raymond Hettinger

Raymond Hettinger added the comment:

static PyObject *
> Why do you say that 'sequence' is a keyword?

It is a keyword argument to enumerate().  Here's the relevant section of code:

enum_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
enumobject *en;
PyObject *seq = NULL;
PyObject *start = NULL;
static char *kwlist[] = {"sequence", "start", 0};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:enumerate", kwlist,
 &seq, &start))
return NULL

--

___
Python tracker 

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



[issue22719] os.path.isfile & os.path.exists bug in while loop

2014-11-03 Thread Zachary Ware

Zachary Ware added the comment:

Aaron, what version of Python are you using on what version of Windows?  Also, 
32 or 64 bit on both?

I can't reproduce this with any Python 3.3.6 or newer on 64-bit Windows 8.1.

--

___
Python tracker 

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



[issue22789] Compress the marshalled data in PYC files

2014-11-03 Thread Raymond Hettinger

New submission from Raymond Hettinger:

Save space and reduce I/O time (reading and writing) by compressing the 
marshaled code in  files.

In my code tree for Python 3, there was a nice space savings 19M to 7M.  Here's 
some of the output from my test:

8792 -> 4629 ./Tools/scripts/__pycache__/reindent.cpython-35.pyc
1660 -> 1063 ./Tools/scripts/__pycache__/rgrep.cpython-35.pyc
1995 -> 1129 ./Tools/scripts/__pycache__/run_tests.cpython-35.pyc
1439 ->  973 ./Tools/scripts/__pycache__/serve.cpython-35.pyc
 727 ->  498 ./Tools/scripts/__pycache__/suff.cpython-35.pyc
3240 -> 1808 ./Tools/scripts/__pycache__/svneol.cpython-35.pyc
   74866 ->23611 ./Tools/scripts/__pycache__/texi2html.cpython-35.pyc
5562 -> 2870 ./Tools/scripts/__pycache__/treesync.cpython-35.pyc
1492 ->  970 ./Tools/scripts/__pycache__/untabify.cpython-35.pyc
1414 ->  891 ./Tools/scripts/__pycache__/which.cpython-35.pyc
19627963 ->  6976410 Total

I haven't measured it yet, but I believe this will improve Python's start-up 
time (because fewer bytes get transferred from disk).

--
files: compress_pyc.py
messages: 230576
nosy: rhettinger
priority: normal
severity: normal
stage: needs patch
status: open
title: Compress the marshalled data in PYC files
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file37125/compress_pyc.py

___
Python tracker 

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-03 Thread Tshepang Lekhonkhobe

Tshepang Lekhonkhobe added the comment:

@raymond

Why do you say that 'sequence' is a keyword?

>>> enumerate()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Required argument 'sequence' (pos 1) not found

That means that 'sequence' can be changed to 'iterable' without worrying about 
backwards compatibility.

--
nosy: +tshepang

___
Python tracker 

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



[issue17896] Move Windows external libs from \..\ to \externals

2014-11-03 Thread Zachary Ware

Zachary Ware added the comment:

Good point, David.  Jeremy, Trent, you're the only other Windows buildbot 
operators as far as I know; feel free to clean up the old externals locations 
as you like.

Also, sorry to make it a bit hairier to operate, but I think this is a big 
enough improvement for day-to-day development that I definitely don't want to 
change back.  For the record, it is fairly easy to just move out the externals 
folder, do whatever you need to with the repository, and move it back in 
without having to rebuild OpenSSL or Tcl/Tk/Tix.

--
nosy: +jeremy.kloth

___
Python tracker 

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



[issue20160] broken ctypes calling convention on MSVC / 64-bit Windows (large structs)

2014-11-03 Thread Steve Dower

Steve Dower added the comment:

Patch looks good to me, but given this issue, #11835, #22733, and probably 
more, should we be integrating from libffi (which apparently has fixes for some 
of these) more often? I know nothing about how we move code between that and 
ctypes.

--
nosy: +steve.dower

___
Python tracker 

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



[issue22758] Regression in Python 3.2 cookie parsing

2014-11-03 Thread Tim Graham

Tim Graham added the comment:

Georg, how do want to proceed with this issue? Should we backport #16611 
(support for parsing secure/httponly flag) to 3.2 to fix this regression and 
then create a separate issue to fix the lax parsing issue on all versions?

--

___
Python tracker 

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



[issue22787] ssl.SSLContext.load_cert_chain() backport regression with None as keyfile

2014-11-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e54d0b197c82 by Benjamin Peterson in branch '2.7':
allow keyfile argument to be None (closes #22787)
https://hg.python.org/cpython/rev/e54d0b197c82

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue826897] Proto 2 pickle vs dict subclass

2014-11-03 Thread Tim Graham

Tim Graham added the comment:

Cookie pickling issue should be fixed in #22775.

--
nosy: +Tim.Graham

___
Python tracker 

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



[issue22650] set up and use VM for net access in the test suite

2014-11-03 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Not to mention possible cookie tests, I suppose.
(I would personally have preferred something like "comfychair.net", but I guess 
pythontest.net is ok too :-))

--
nosy: +pitrou

___
Python tracker 

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



[issue22788] allow logging.handlers.HTTPHandler to take an SSLContext

2014-11-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-03 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Somehow the Windows bots are failing to verify python.org 
http://buildbot.python.org/all/builders/x86%20XP-4%203.x/builds/11179/steps/test/logs/stdio

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread R. David Murray

R. David Murray added the comment:

I was actually thinking of the Implementing the arithmetic operations section.  
Maybe we should copy the parenthetical from the datamodel description into the 
text you are modifying, and then link to the implementing section.

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

I found these items:

Doc/c-api/object.rst

.. c:var:: PyObject* Py_NotImplemented

   The ``NotImplemented`` singleton, used to signal that an operation is
   not implemented for the given type combination.


Doc/extending/newtypes.rst
---
where the operator is one of ``Py_EQ``, ``Py_NE``, ``Py_LE``, ``Py_GT``,
``Py_LT`` or ``Py_GT``.  It should compare the two objects with respect to the
specified operator and return ``Py_True`` or ``Py_False`` if the comparison is
successful, ``Py_NotImplemented`` to indicate that comparison is not
implemented and the other object's comparison method should be tried, or *NULL*
if an exception was set.


Doc/Library/numbers.rst
---
Implementing the arithmetic operations
~~

We want to implement the arithmetic operations so that mixed-mode
operations either call an implementation whose author knew about the
types of both arguments, or convert both to the nearest built in type
and do the operation there. For subtypes of :class:`Integral`, this
means that :meth:`__add__` and :meth:`__radd__` should be defined as::

class MyIntegral(Integral):

def __add__(self, other):
if isinstance(other, MyIntegral):
return do_my_adding_stuff(self, other)
elif isinstance(other, OtherTypeIKnowAbout):
return do_my_other_adding_stuff(self, other)
else:
return NotImplemented

def __radd__(self, other):
if isinstance(other, MyIntegral):
return do_my_adding_stuff(other, self)
elif isinstance(other, OtherTypeIKnowAbout):
return do_my_other_adding_stuff(other, self)
elif isinstance(other, Integral):
return int(other) + int(self)
elif isinstance(other, Real):
return float(other) + float(self)
elif isinstance(other, Complex):
return complex(other) + complex(self)
else:
return NotImplemented


There are 5 different cases for a mixed-type operation on subclasses
of :class:`Complex`. I'll refer to all of the above code that doesn't
refer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as
"boilerplate". ``a`` will be an instance of ``A``, which is a subtype
of :class:`Complex` (``a : A <: Complex``), and ``b : B <:
Complex``. I'll consider ``a + b``:

1. If ``A`` defines an :meth:`__add__` which accepts ``b``, all is
   well.
2. If ``A`` falls back to the boilerplate code, and it were to
   return a value from :meth:`__add__`, we'd miss the possibility
   that ``B`` defines a more intelligent :meth:`__radd__`, so the
   boilerplate should return :const:`NotImplemented` from
   :meth:`__add__`. (Or ``A`` may not implement :meth:`__add__` at
   all.)
3. Then ``B``'s :meth:`__radd__` gets a chance. If it accepts
   ``a``, all is well.
4. If it falls back to the boilerplate, there are no more possible
   methods to try, so this is where the default implementation
   should live.
5. If ``B <: A``, Python tries ``B.__radd__`` before
   ``A.__add__``. This is ok, because it was implemented with
   knowledge of ``A``, so it can handle those instances before
   delegating to :class:`Complex`.


Doc/library/datetime.rst

   In other words, ``date1 < date2`` if and only if ``date1.toordinal() <
   date2.toordinal()``. In order to stop comparison from falling back to the
   default scheme of comparing object addresses, date comparison normally raises
   :exc:`TypeError` if the other comparand isn't also a :class:`date` object.
   However, ``NotImplemented`` is returned instead if the other comparand has a
   :meth:`timetuple` attribute.  This hook gives other kinds of date objects a
   chance at implementing mixed-type comparison. If not, when a :class:`date`
   object is compared to an object of a different type, :exc:`TypeError` is 
raised
   unless the comparison is ``==`` or ``!=``.  The latter cases return
   :const:`False` or :const:`True`, respectively.


Doc/reference/expressions.rst
-
Comparisions

...
Comparison of objects of differing types depends on whether either of the
types provide explicit support for the comparison.  Most numeric types can be
compared with one another.  When cross-type comparison is not supported, the
comparison method returns ``NotImplemented``.


Ahha!  I think I found it (nearly at the end, of course):

Doc/reference/datamodel.rst
---
The standard type hierarchy
===
...
NotImplemented
   .. index:: object: NotImplemented

   This type has a single value.  There is a single object with this value. This
   object is accessed through the built-in name ``NotImplemented``. Numeric 
methods
   and rich compari

[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-11-03 Thread R. David Murray

R. David Murray added the comment:

I would love that, but I think the fix depends on a feature.  Robert will know 
for sure.

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread R. David Murray

R. David Murray added the comment:

Sounds OK to me.  There should already be a discussion of the consequences of 
returning it (I don't remember where, though), and it would be nice to link to 
that discussion.

Note that any doc change should be applied to 3.4 first, and then merged to 3.5.

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



[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM.

--
stage: patch review -> commit review

___
Python tracker 

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



[issue22366] urllib.request.urlopen should take a "context" (SSLContext) argument

2014-11-03 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

Please update versionchanged to 3.4.3 on default branch.

--

___
Python tracker 

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



[issue22780] NotImplemented doc section needs update

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

+   Special value which should be returned by the special methods
+   (:meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, etc.) to indicate
+   that the operation is not implemented with respect to the other type.

After a discussion on python-dev, I think this wording could be even clearer.  
How about:

Special value which should be returned by the binary special methods
(e.g. :meth:`__eq__`, :meth:`__lt__`, :meth:`__add__`, :meth:`__rsub__`,
etc.) to indicate that the operation is not implemented with respect to
the other type; may be returned by the in-place binary special methods
(e.g. :meth:`__imul__`, :meth:`__iand__`, etc.) for the same purpose.

--
status: closed -> open

___
Python tracker 

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



[issue22735] Fix various crashes exposed through mro() customization

2014-11-03 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Thank you for the patchset. I wonder if we should just forbid most reentrancy 
i.e. set a flag on the type when it's being constructed and not let 
type_set_bases be called then. Setting __bases__ from within mro() doesn't seem 
very useful outside of producing pathologies.

--

___
Python tracker 

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



[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

Okay, the python-dev ruling is in, and raising an exception in the __ixxx__ 
methods is allowed, and even a good idea in the cases of mutable containers.

However, doing the check on 'other' and raising a TypeError with an appropriate 
message would still be better for a couple reasons:

  - all the non-inplace operations raise TypeError when 'other' is not a 
correct type
  - __iand__ is currently buggy because it does not do the check

If backwards compatibility is a concern in this case, a custom "TypeError" that 
was a subclass of both TypeError and AttributeError could address that.

--

___
Python tracker 

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



[issue22788] allow logging.handlers.HTTPHandler to take an SSLContext

2014-11-03 Thread Alex Gaynor

Alex Gaynor added the comment:

Quick pass at a patch. No docs, and it should proabbly be an error to pass 
context with secure=False.

--
keywords: +needs review, patch
Added file: http://bugs.python.org/file37124/issue22788.diff

___
Python tracker 

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



[issue7559] TestLoader.loadTestsFromName swallows import errors

2014-11-03 Thread Domen Kožar

Domen Kožar added the comment:

Could we backport this one to 3.x and 2.7? It's leads to really bad UX.

--

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-03 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Okay, 3.4/3.5 have been dealt with. I had to hack up test_logging a bit. 
(#22788 would make that better). 2.7 now needs a backport.

--

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2afe5413d7af by Benjamin Peterson in branch '3.4':
PEP 476: enable HTTPS certificate verification by default (#22417)
https://hg.python.org/cpython/rev/2afe5413d7af

New changeset 731375f83406 by Benjamin Peterson in branch 'default':
merge 3.4 (#22417)
https://hg.python.org/cpython/rev/731375f83406

--
nosy: +python-dev

___
Python tracker 

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



[issue22788] allow logging.handlers.HTTPHandler to take an SSLContext

2014-11-03 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Right then...

--
title: allow HTTPHandler to take an SSLContext -> allow 
logging.handlers.HTTPHandler to take an SSLContext

___
Python tracker 

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



[issue22788] allow HTTPHandler to take an SSLContext

2014-11-03 Thread Alex Gaynor

Alex Gaynor added the comment:

Hah! I didn't realize you meant *logging.handlers.HTTPHandler*, I thought you 
meant *urllib.request.HTTPHandler*.

--

___
Python tracker 

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



[issue22788] allow HTTPHandler to take an SSLContext

2014-11-03 Thread Benjamin Peterson

Benjamin Peterson added the comment:

emit()

On Mon, Nov 3, 2014, at 15:33, Alex Gaynor wrote:
> 
> Alex Gaynor added the comment:
> 
> I'm not sure I follow, where does HTTPHandler ever construct an
> HTTPSConnection?
> 
> --
> nosy: +alex
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue22788] allow HTTPHandler to take an SSLContext

2014-11-03 Thread Alex Gaynor

Alex Gaynor added the comment:

I'm not sure I follow, where does HTTPHandler ever construct an HTTPSConnection?

--
nosy: +alex

___
Python tracker 

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



[issue1539381] Add readinto method to StringIO and cStringIO

2014-11-03 Thread Silvio Ricardo Cordeiro

Silvio Ricardo Cordeiro added the comment:

BufferedReader assumes that readinto is defined, but that's not the case for 
StringIO's. In the end, this cripples StringIO objects, because their data can 
never be peek()'ed as with all other file objects.

--
components: +IO -Library (Lib)
nosy: +silvioricardoc
type:  -> behavior
versions: +Python 2.7, Python 3.2 -Python 2.6

___
Python tracker 

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



[issue22788] allow HTTPHandler to take an SSLContext

2014-11-03 Thread Benjamin Peterson

New submission from Benjamin Peterson:

It would be nice if HTTPHandler could take an SSLContext as a parameter, which 
would be passed to HTTPSConnection to configure the security of the connection.

--
components: Library (Lib)
messages: 230549
nosy: benjamin.peterson, vinay.sajip
priority: normal
severity: normal
stage: needs patch
status: open
title: allow HTTPHandler to take an SSLContext
type: enhancement
versions: Python 3.5

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-03 Thread Alex Gaynor

Alex Gaynor added the comment:

Fix for the failing test_ssl testes.

--
Added file: http://bugs.python.org/file37123/issue22417.diff

___
Python tracker 

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



[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

Ethan stated:
>> The only problem with the design is that it does not play well with others.  
>> For
>> duck-typeable just do a check on 'other' to see if it has an .items() 
>> method, and
>> return NotImplemented if it does not.  Oh, and check that 'self' is Counter, 
>> and
>> also return NotImplemented if that fails.

R. David Murray replied:
> No, that doesn't support duck typing.  Duck typing is not putting arbitrary
> restrictions on what objects you accept, but only essential restrictions.

__iadd__ will raise an AttributeError if 'other' doesn't have an 'items' method 
-- how is that an arbitrary restriction?

If 'other' doesn't have an 'items' but does know how to add itself to Counter, 
it won't matter because Counter is raising an exception instead of returning 
NotImplemented.  

What other types return NotImplemented when 'other' is not the expected 
(sub)type?  bytes, bytearray, int, float, string, dict, list, tuple, Enum, 
deque, defaultdict, OrderedDict, Decimal, Fraction, and Counter itself for 
every binary method /except/ the four inplace ops it supplies itself.

> And as noted above, if you return NotImplemented, then you get an error 
> message
> that essentially says "this is impossible" instead of "this is what didn't 
> work".

Correct implementation should not be sacrificed for a nicer error message.

>> Here's proof of subclass trouble -- the idea is to make an immutable Counter:
>> [snip example]

> Your subclass doesn't override __iadd__ or any of the other mutation methods. 
>  Why
> would you expect it to be immutable if it doesn't?

You're right, that was a bad example.  A subclass would need to override any 
method whose behavior it wants to change.

What does not seem correct to me is raising an exception because the type of 
'other' is not correct, instead of returning NotImplemented, and in 14 other 
core datatypes it does work that way, and even in Counter it works that way for 
any in-place method that Counter itself doesn't override, and it does work that 
way /in/ Counter for the normal binary ops that it /does/ override.

> For subclassing to work, the fix is:
> 
> if not hasattr(other, 'items') or type(self) is not Counter:
> return NotImplemented

>> I've never seen a type check like that in a Python class, and I hope I never 
>> do.  *That*
>> breaks subclassing.

Explanations and examples go a lot further than bare statements.

[Jim Jewitt posts an explanation.]

Ah, I see.  Thank you, Jim.

Okay, I agree that the check against the base class is ill-advised (and I 
modified some of the above reply to match that understanding).

However, I am still unconvinced that 'other' should not be checked.  Hopefully 
the python-dev thread will shed more light on this.

--

___
Python tracker 

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



[issue22676] _pickle's whichmodule() is slow

2014-11-03 Thread Steve Dower

Steve Dower added the comment:

(Looks like I was outsmarted by the tracker when trying to put line numbers in 
my links... is there a way to do that?)

--

___
Python tracker 

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



[issue22676] _pickle's whichmodule() is slow

2014-11-03 Thread Steve Dower

Steve Dower added the comment:

The fix for this now uses module without initializing it, which could lead to a 
crash if get_dotted_path() tries to raise an exception (it puts module into the 
error string with %R). See Modules/_pickle.c#l1656 and Modules/_pickle.c#l1538.

I think the fix is to initialize module with Py_None and currently there's no 
need to bump the refcount (though I'm always wary of doing that in case things 
change in the future). If that sounds right I'm happy to put the fix in, else 
Antoine can do it :)

--
nosy: +steve.dower

___
Python tracker 

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



[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types

2014-11-03 Thread Jim Jewett

Jim Jewett added the comment:

If I know that a Counter (or any class X) can be updated in place, I will be 
surprised to find out that I'm using a different instance after a successful 
in-place operation.

I would even consider that (replacement of the original instance) a security 
risk, though it is mitigated by the fact that I don't see how to exploit it 
without already being able to create arbitrary subclasses.

> For subclassing to work, the fix is:
> 
> if not hasattr(other, 'items') or type(self) is not Counter:
> return NotImplemented

That breaks for Counter subclasses on the left hand side -- even a trivial 
subclass to change the repr would fail unless the _i* methods were all 
re-implemented, either by the otherwise-trivial Counter subclass or by the 
right-hand objects.  If you start making it work for the obvious cases, you 
just make the failure conditions more obscure.

--
nosy: +Jim.Jewett

___
Python tracker 

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



[issue22784] test_asyncio fails without the ssl module

2014-11-03 Thread Guido van Rossum

Guido van Rossum added the comment:

OK, them LGTM.

--

___
Python tracker 

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



[issue22787] ssl.SSLContext.load_cert_chain() backport regression with None as keyfile

2014-11-03 Thread Alex Gaynor

Changes by Alex Gaynor :


--
keywords: +needs review

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-03 Thread Alex Gaynor

Alex Gaynor added the comment:

Latest patch fixes the urllib2_localnet tests.

--
Added file: http://bugs.python.org/file37122/issue22417.diff

___
Python tracker 

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



[issue22787] ssl.SSLContext.load_cert_chain() backport regression with None as keyfile

2014-11-03 Thread Alex Gaynor

Changes by Alex Gaynor :


--
keywords: +patch
Added file: http://bugs.python.org/file37121/issue22787.diff

___
Python tracker 

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-11-03 Thread Benjamin Peterson

Benjamin Peterson added the comment:

% ./python Lib/test/regrtest.py -v test_urllib2_localnet
== CPython 3.4.2+ (3.4:7be6ef737aaf+, Nov 3 2014, 10:03:11) [GCC 4.8.3]
==   
Linux-3.16.5-gentoo-x86_64-Intel-R-_Core-TM-_i7-2860QM_CPU_@_2.50GHz-with-gentoo-2.2
 little-endian
==   hash algorithm: siphash24 64bit
==   /home/benjamin/dev/python/3.4/build/test_python_28724
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
[1/1] test_urllib2_localnet
test_basic_auth_httperror (test.test_urllib2_localnet.BasicAuthTests) ... ok
test_basic_auth_success (test.test_urllib2_localnet.BasicAuthTests) ... ok
test_proxy_qop_auth_int_works_or_throws_urlerror 
(test.test_urllib2_localnet.ProxyAuthTests) ... ok
test_proxy_qop_auth_works (test.test_urllib2_localnet.ProxyAuthTests) ... ok
test_proxy_with_bad_password_raises_httperror 
(test.test_urllib2_localnet.ProxyAuthTests) ... ok
test_proxy_with_no_password_raises_httperror 
(test.test_urllib2_localnet.ProxyAuthTests) ... ok
test_200 (test.test_urllib2_localnet.TestUrlopen) ... ok
test_200_with_parameters (test.test_urllib2_localnet.TestUrlopen) ... ok
test_404 (test.test_urllib2_localnet.TestUrlopen) ... ok
test_bad_address (test.test_urllib2_localnet.TestUrlopen) ... skipped "Use of 
the 'network' resource not enabled"
test_basic (test.test_urllib2_localnet.TestUrlopen) ... ok
test_chunked (test.test_urllib2_localnet.TestUrlopen) ... ok
test_geturl (test.test_urllib2_localnet.TestUrlopen) ... ok
test_https (test.test_urllib2_localnet.TestUrlopen) ... Got an error:
[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:600)
stopping HTTPS server
joining HTTPS thread
ERROR
test_https_sni (test.test_urllib2_localnet.TestUrlopen) ... Got an error:
[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:600)
stopping HTTPS server
joining HTTPS thread
ERROR
test_https_with_cadefault (test.test_urllib2_localnet.TestUrlopen) ... stopping 
HTTPS server
Got an error:
[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:600)
joining HTTPS thread
ok
test_https_with_cafile (test.test_urllib2_localnet.TestUrlopen) ... Got an 
error:
[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:600)
stopping HTTPS server
joining HTTPS thread
stopping HTTPS server
joining HTTPS thread
ok
test_info (test.test_urllib2_localnet.TestUrlopen) ... ok
test_iteration (test.test_urllib2_localnet.TestUrlopen) ... ok
test_line_iteration (test.test_urllib2_localnet.TestUrlopen) ... ok
test_redirection (test.test_urllib2_localnet.TestUrlopen) ... ok
test_sending_headers (test.test_urllib2_localnet.TestUrlopen) ... ok

==
ERROR: test_https (test.test_urllib2_localnet.TestUrlopen)
--
Traceback (most recent call last):
  File "/home/benjamin/dev/python/3.4/Lib/urllib/request.py", line 1182, in 
do_open
h.request(req.get_method(), req.selector, req.data, headers)
  File "/home/benjamin/dev/python/3.4/Lib/http/client.py", line 1090, in request
self._send_request(method, url, body, headers)
  File "/home/benjamin/dev/python/3.4/Lib/http/client.py", line 1128, in 
_send_request
self.endheaders(body)
  File "/home/benjamin/dev/python/3.4/Lib/http/client.py", line 1086, in 
endheaders
self._send_output(message_body)
  File "/home/benjamin/dev/python/3.4/Lib/http/client.py", line 924, in 
_send_output
self.send(msg)
  File "/home/benjamin/dev/python/3.4/Lib/http/client.py", line 859, in send
self.connect()
  File "/home/benjamin/dev/python/3.4/Lib/http/client.py", line 1230, in connect
server_hostname=sni_hostname)
  File "/home/benjamin/dev/python/3.4/Lib/ssl.py", line 364, in wrap_socket
_context=self)
  File "/home/benjamin/dev/python/3.4/Lib/ssl.py", line 584, in __init__
self.do_handshake()
  File "/home/benjamin/dev/python/3.4/Lib/ssl.py", line 811, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
(_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/benjamin/dev/python/3.4/Lib/test/test_urllib2_localnet.py", line 
548, in test_https
data = self.urlopen("https://localhost:%s/bizarre"; % handler.port)
  File "/home/benjamin/dev/python/3.4/Lib/test/test_urllib2_localnet.py", line 
455, in urlopen
f = urllib.request.urlopen(url, data, **kwargs)
  File "/home/benjamin/dev/python/3.4/Lib/urllib/request.py", line 161, in 
urlopen
return opener.open(url, data, timeout)
  File "/home/benjamin/dev/python/3.4/Lib/urllib/request.py", line 463, in open
response = self._open(req, data)
  File "/home/benjamin/dev/python/3.4/Lib/urllib/request.py", line 481, in _open
'_open', req)
  File "/home/

[issue22787] ssl.SSLContext.load_cert_chain() backport regression with None as keyfile

2014-11-03 Thread Alex Gaynor

Changes by Alex Gaynor :


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

___
Python tracker 

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



[issue22787] ssl.SSLContext.load_cert_chain() backport regression with None as keyfile

2014-11-03 Thread Till Maas

Till Maas added the comment:

sorry, it should be:
requests.get("https://example.com";, cert="keycert.pem")

--

___
Python tracker 

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



[issue22787] ssl.SSLContext.load_cert_chain() backport regression with None as keyfile

2014-11-03 Thread Till Maas

New submission from Till Maas:

https://github.com/python/cpython/commit/71a4ee3ea2c6847b9fc4b33cbc8d565a7bf2424a

introduces a regression in ssl.SSLContext.load_cert_chain()

https://github.com/python/cpython/blob/2.7/Modules/_ssl.c#L2462

With this change it is not possible to specify None as keyfile which can 
be triggered on Debian Testing? (there the change is backported) in 
requests.get("https://example.com";, cerf="keycert.pem"). It can also be 
triggered with the sample code in the attached file. It is fixed in recent 
python 3.

--
components: Library (Lib)
files: poc.txt
messages: 230539
nosy: till
priority: normal
severity: normal
status: open
title: ssl.SSLContext.load_cert_chain() backport regression with None as keyfile
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file37120/poc.txt

___
Python tracker 

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



[issue22650] set up and use VM for net access in the test suite

2014-11-03 Thread Donald Stufft

Donald Stufft added the comment:

It is configured using salt, see 
https://github.com/python/psf-salt/blob/master/salt/pythontest/init.sls.

A separate domain just makes it easier to do whatever we need with it without 
needing to worry about getting confused between live sites and test sites.

--

___
Python tracker 

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



[issue2504] Add gettext.pgettext() and variants support

2014-11-03 Thread Éric Araujo

Changes by Éric Araujo :


--
stage: patch review -> needs patch
versions:  -Python 3.2, Python 3.3, Python 3.4, Python 3.6

___
Python tracker 

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



[issue2504] Add gettext.pgettext() and variants support

2014-11-03 Thread Wichert Akkerman

Wichert Akkerman added the comment:

Bump.

Python 3 is still not on my radar, but I'll happily do a backport for Py2 and 
drop that on PyPI once this gets resolved.

--
versions: +Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types

2014-11-03 Thread R. David Murray

R. David Murray added the comment:

On Mon, 03 Nov 2014 10:53:09 +, Ethan Furman  wrote:
> 
> Ethan Furman added the comment:
> 
> > I don't want to change the kind of exception being raised (an API change 
> > from
> > AttributeError to TypeError) without a really good reason.
> 
> Subclasses cannot work with the current implementation.

I don't understand this statement.

> > Also, I prefer the current AttributeError with its clear indication that an 
> > items()
> > method is needed for duck-typing.  These kind of error messages are very 
> > helpful
> > when you're trying to figure-out how to duck-type on-purpose
> 
> That's what the docs are for.

That's not the way it works in real life.  You implement something, it
doesn't work, and if the solution isn't obvious from the error message
*then* you look at the docs or google.  But if the error message says
"you can't do this", then like as not you don't even look at the docs.

> > (for example, {}.update(1) and {}.update([[]]) both provide the information 
> > about
> > what you would need to do to get update() to work).
> 
> update is not a binary operation, so has more leeway in how it handles 
> problems.

As Raymond pointed out, the augmented assignment operator is a
*shortcut* for update.

> > The current duck-typeable behavior was an intended part of the design and 
> > is no
> > different from a number of other methods that update in-place.
> 
> The only problem with the design is that it does not play well with others.  
> For duck-typeable just do a check on 'other' to see if it has an .items() 
> method, and return NotImplemented if it does not.  Oh, and check that 'self' 
> is Counter, and also return NotImplemented if that fails.

No, that doesn't support duck typing.  Duck typing is not putting
arbitrary restrictions on what objects you accept, but only essential
restrictions.  And as noted above, if you return NotImplemented, then
you get an error message that essentially says "this is impossible"
instead of "this is what didn't work".

> Here's proof of subclass trouble -- the idea is to make an immutable Counter:

Your subclass doesn't override __iadd__ or any of the other mutation
methods.  Why would you expect it to be immutable if it doesn't?

> For subclassing to work, the fix is:
> 
> if not hasattr(other, 'items') or type(self) is not Counter:
> return NotImplemented

I've never seen a type check like that in a Python class, and I hope
I never do.  *That* breaks subclassing.

--

___
Python tracker 

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



[issue22650] set up and use VM for net access in the test suite

2014-11-03 Thread R. David Murray

R. David Murray added the comment:

Why a separate domain rather than a subdomain?  I'm not objecting, but I am 
curious.

--

___
Python tracker 

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



[issue22753] urllib2 localnet Changed test to lookup IP-address of localhost

2014-11-03 Thread Håkan Lövdahl

Håkan Lövdahl added the comment:

Yes, I can confirm that changing 'URL' to be 'http://127.0.0.1' works. I think 
that would be a solution to this.

--

___
Python tracker 

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



[issue6721] Locks in the standard library should be sanitized on fork

2014-11-03 Thread Nir Soffer

Changes by Nir Soffer :


--
nosy: +nirs

___
Python tracker 

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



[issue22766] collections.Counter's in-place operators should return NotImplemented for unsupported types

2014-11-03 Thread Ethan Furman

Ethan Furman added the comment:

> I don't want to change the kind of exception being raised (an API change from
> AttributeError to TypeError) without a really good reason.

Subclasses cannot work with the current implementation.

> In general, in-place methods are not required to return NotImplemented (for
> example, (3).__iadd__(4.5) raises an AttributeError).

AttributeError is being raised because int does not have an __iadd__ method, 
not because of a problem with the float operand.

> Also, I prefer the current AttributeError with its clear indication that an 
> items()
> method is needed for duck-typing.  These kind of error messages are very 
> helpful
> when you're trying to figure-out how to duck-type on-purpose

That's what the docs are for.

> (for example, {}.update(1) and {}.update([[]]) both provide the information 
> about
> what you would need to do to get update() to work).

update is not a binary operation, so has more leeway in how it handles problems.

> The current duck-typeable behavior was an intended part of the design and is 
> no
> different from a number of other methods that update in-place.

The only problem with the design is that it does not play well with others.  
For duck-typeable just do a check on 'other' to see if it has an .items() 
method, and return NotImplemented if it does not.  Oh, and check that 'self' is 
Counter, and also return NotImplemented if that fails.

> At any rate, I want to avoid unnecessary API churn (and avoid contributing to
> what Guido has called "a death by a thousand cuts" for the growing list of 
> tiny
> semantic differences between Python 2 and Python 3).

Not an issue in this case, as the 2.7 Counter does not have the in-place 
methods.

Here's proof of subclass trouble -- the idea is to make an immutable Counter:
-
from collections import Counter

class FrozenCounter(Counter):
"""
immutable after definition
"""
def __add__(self, other):
new_counter = self.__class__()
for elem, count in self.items():
new_counter[elem] = count
for elem, count in other.items():
new_counter[elem] += count
return new_counter._keep_positive()

fc = FrozenCounter("abbc")
sc = FrozenCounter("bubba")
original = fc
fc += sc
assert fc == FrozenCounter("aabcu")
assert fc is not original
-

and the results:
-
Traceback (most recent call last):
  File "blah.py", line 20, in 
assert fc is not original
AssertionError
-

For subclassing to work, the fix is:

if not hasattr(other, 'items') or type(self) is not Counter:
return NotImplemented

--

___
Python tracker 

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



[issue21650] add json.tool option to avoid alphabetic sort of fields

2014-11-03 Thread Berker Peksag

Changes by Berker Peksag :


Added file: http://bugs.python.org/file37119/issue21650_v4.diff

___
Python tracker 

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



[issue8350] Document lack of support for keyword arguments in C functions

2014-11-03 Thread Yongzhi Pan

Changes by Yongzhi Pan :


--
nosy: +fossilet

___
Python tracker 

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



[issue22650] set up and use VM for net access in the test suite

2014-11-03 Thread Georg Brandl

Georg Brandl added the comment:

Nice! How do you plan to organize its setup?

--

___
Python tracker 

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



[issue22784] test_asyncio fails without the ssl module

2014-11-03 Thread Antoine Pitrou

Antoine Pitrou added the comment:

The problem is the default value for `purpose` in the function declaration (the 
signature mocks the ssl.create_default_context() function, so I don't think 
it's ok to change the default parameter value here).

--

___
Python tracker 

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



[issue22457] load_tests not invoked in root __init__.py when start=package root

2014-11-03 Thread Robert Collins

Changes by Robert Collins :


Added file: http://bugs.python.org/file37118/issue22457.patch

___
Python tracker 

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