[issue13248] deprecated in 3.2/3.3, should be removed in 3.5 or ???

2015-01-04 Thread Berker Peksag

Berker Peksag added the comment:

Here is a follow-up list:

* formatter module (will be removed in Python 3.6)
* asynchat.fifo() (will be removed in Python 3.6)
* buffering argument of bz2.BZ2File() (deprecated in 2011)
* tarfile.filemode() (deprecated in 2012)
* SO config var (sysconfig.get_config_var()) (deprecated in 2013)
* platform.popen() (deprecated in 2011)
* ntpath.splitunc() (deprecated in 2009)
* inspect.getmoduleinfo() (deprecated in 2012)

--

___
Python tracker 

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



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2015-01-04 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patch, Vajrasky.

--
components: +Library (Lib) -Tests
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
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



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2015-01-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f859a61f5853 by Berker Peksag in branch '3.4':
Issue #18644: Fix a ResourceWarning in formatter.test().
https://hg.python.org/cpython/rev/f859a61f5853

New changeset f374e4e6d04b by Berker Peksag in branch 'default':
Issue #18644: Fix a ResourceWarning in formatter.test().
https://hg.python.org/cpython/rev/f374e4e6d04b

--
nosy: +python-dev

___
Python tracker 

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



[issue23166] urllib2 ignores opener configuration under certain circumstances

2015-01-04 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report. Could you provide an example to reproduce the issue you 
described?

--
nosy: +berker.peksag, orsenthil

___
Python tracker 

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



[issue23132] Faster total_ordering

2015-01-04 Thread Raymond Hettinger

Changes by Raymond Hettinger :


Added file: http://bugs.python.org/file37599/total_ordering2.diff

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Devin Jeanpierre

Devin Jeanpierre added the comment:

I think that such a thing is meaningless, as I don't own copyright to the 
patches, my employer (Google) does. But, it can't hurt, so, done.

--

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Can you submit a contributor agreement as well?

--

___
Python tracker 

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



[issue23001] Accept mutable bytes-like objects

2015-01-04 Thread Martin Panter

Martin Panter added the comment:

If this goes ahead, it would be nice adding notes to the documentation saying 
that bytearray() or whatever was previously not supported. There are APIs in 
Python 2.6 that had similar treatment with no documentation updates, and I keep 
being bitten by it.

--

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Devin Jeanpierre

Devin Jeanpierre added the comment:

Since both patches will clobber each other (same test method), complicating the 
review process, I've written the patch for issue23086 first. It's currently 
waiting on committee review from my employer. Will upload to other issue, and 
once it's submitted or rejected, I'll add a test patch to this issue too.

--

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Devin, you're welcome to whip-up a patch for the tests for this one.  I don't 
know if it will go forward though.  I'm leaving it open for a while to see if 
anyone has objections.

If you want to work another straight-forward ABC patch, have a look at 
http://bugs.python.org/issue23086

--

___
Python tracker 

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Right, but there's still no danger of overflow.

On Sun, Jan 4, 2015, at 16:50, STINNER Victor wrote:
> 
> STINNER Victor added the comment:
> 
> PY_SSIZE_T_MAX is usually smaller than SIZE_T_MAX ;-)
> 
> (strlen result is not signed.)
> 
> --
> 
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue13248] deprecated in 3.2/3.3, should be removed in 3.5 or ???

2015-01-04 Thread Martin Panter

Martin Panter added the comment:

Another one to deal with one way or the other: html.parser.HTMLParser.unescape()

It is apparently due to be removed in 3.5. It was meant to be an undocumented 
internal function, and there is now an public alternative. However I would be 
inclined to leave it around a little longer, because it seems to have been 
widely recommended for decoding HTML entities in the past (e.g. 
), and keeping it would simplify 
maintaining Python 2 compatible code.

--

___
Python tracker 

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread STINNER Victor

STINNER Victor added the comment:

PY_SSIZE_T_MAX is usually smaller than SIZE_T_MAX ;-)

(strlen result is not signed.)

--

___
Python tracker 

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



[issue23167] Marshal docs say format version is 3; actual format version is 4

2015-01-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8ac23d3242b4 by Benjamin Peterson in branch '3.4':
the current marshal version is 4 (closes #23167)
https://hg.python.org/cpython/rev/8ac23d3242b4

New changeset 826831a9a376 by Benjamin Peterson in branch 'default':
merge 3.4 (#23167)
https://hg.python.org/cpython/rev/826831a9a376

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Presumably strlen can't return SIZE_T_MAX because the trailing '\0' has to have 
been allocated somewhere.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread STINNER Victor

STINNER Victor added the comment:

+size_t argsize = strlen(arg) + 1; 
+if (argsize > PY_SSIZE_T_MAX/sizeof(wchar_t))
+return NULL;
+res = PyMem_Malloc(argsize*sizeof(wchar_t));

The code doesn't check for integer overflow on "+1". I suggest instead:

+size_t arglen = strlen(arg); 
+if (arglen > PY_SSIZE_T_MAX / sizeof(wchar_t) - 1)
+return NULL;
+res = PyMem_Malloc((arglen + 1) * sizeof(wchar_t));

--

___
Python tracker 

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



[issue20606] Operator Documentation Example doesn't work

2015-01-04 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
status: open -> closed

___
Python tracker 

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



[issue23167] Marshal docs say format version is 3; actual format version is 4

2015-01-04 Thread Dmitry Kazakov

New submission from Dmitry Kazakov:

Documentation on marshal module says that format version is 3, but 
Py_MARSHAL_VERSION is set to 4. Search for marshal-related issues gave me an 
idea that this is a documentation bug.

--
assignee: docs@python
components: Documentation
files: marshal_doc.diff
keywords: patch
messages: 233429
nosy: docs@python, vlth
priority: normal
severity: normal
status: open
title: Marshal docs say format version is 3; actual format version is 4
versions: Python 3.4
Added file: http://bugs.python.org/file37598/marshal_doc.diff

___
Python tracker 

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1ce98e85929d by Benjamin Peterson in branch '3.2':
add some overflow checks before multiplying (closes #23165)
https://hg.python.org/cpython/rev/1ce98e85929d

New changeset d1af6f3a8ce3 by Benjamin Peterson in branch '3.3':
merge 3.2 (closes #23165)
https://hg.python.org/cpython/rev/d1af6f3a8ce3

New changeset d45e16b1ed86 by Benjamin Peterson in branch '3.4':
merge 3.3 (closes #23165)
https://hg.python.org/cpython/rev/d45e16b1ed86

New changeset 8c4fb312e15d by Benjamin Peterson in branch 'default':
merge 3.4 (#23165)
https://hg.python.org/cpython/rev/8c4fb312e15d

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



[issue23163] pdb docs need to contain a statement on threads/multithreaded debugging

2015-01-04 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +georg.brandl

___
Python tracker 

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



[issue23166] urllib2 ignores opener configuration under certain circumstances

2015-01-04 Thread Jurijs Vorotilovs

New submission from Jurijs Vorotilovs:

Python 2.7.9 has a bug in urllib2.py:urlopen().
It creates HTTPSHandler instances by its own when it should not.
One may have assigned custom openers with subclassed HTTPSHandler or 
HTTPSHandler instance with debug enabled or etc.

--
components: Library (Lib)
messages: 233427
nosy: crazyjurich
priority: normal
severity: normal
status: open
title: urllib2 ignores opener configuration under certain circumstances
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



[issue23156] Update tix install information in tkinter tix chapter of doc

2015-01-04 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I found tix8.4.3.dll and pkgIndex.tcl inside tcl/tix8.4.3, which is not where 
the doc currently says to look.

Christian Gollwitzer posted a response on the python-list thread "Python Tk Tix 
GUI documentation & builder overview and tips" (which helped inspire this issue 
in addition to the SO post).  He basically agrees with Ned's ending comment 
that "we should be strongly discouraging use of Tix in favor of Ttk."

"Note that Tix is LEGACY. There are much better options for its widgets 
available that are based on ttk. ... Not to mention that the Tix widgets are 
extremely ugly, while the widgets from ttk have a near-native look and feel."

So I agree that the opening paragraph of the (T)tkinter.tix section 
https://docs.python.org/3/library/tkinter.tix.html#module-tkinter.tix
should identify it as a legacy python interface to the old, optional, tcl/tk 
tix extension that has been mostly superceded by widgets added either directly 
to tk or by ttk.

Cristian also listed the ttk replacements.
'''
* Hierarchical Listbox use ttk::treeview, tablelist_tile or tkTreeCtrl, with 
increasing order of capabilities and install complexity

* TList: I think tkTreeCtrl can do it, never have used this layout

* CheckList: tablelist can be used with an editable field

* Grid widget: use tkTable

* NoteBook, PanedWindow, ComboBox, LabelFrame -> ttk::notebook, 
ttk::panedwindow, ttk::combobox, ttk::labelframe

* Balloon: tcllib::tooltip
'''

The tkinter and tkinter.ttk replacements could similarly be added to the tix 
widget listing in the doc.

--

___
Python tracker 

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



[issue23155] unittest: object has no attribute '_removed_tests'

2015-01-04 Thread Ian Cordasco

Ian Cordasco added the comment:

Keep in mind, this could also be a problem with NetBSD's distribution of python.

--

___
Python tracker 

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



[issue23155] unittest: object has no attribute '_removed_tests'

2015-01-04 Thread Ian Cordasco

Changes by Ian Cordasco :


--
nosy: +icordasc

___
Python tracker 

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



[issue23165] Heap overwrite in Python/fileutils.c:_Py_char2wchar() on 32 bit systems due to malloc parameter overflow

2015-01-04 Thread Guido Vranken

New submission from Guido Vranken:

The vulnerability described here is exceedingly difficult to exploit, since 
there is no straight-forward way an "attacker" (someone who controls a Python 
script contents but not other values such as system environment variables), can 
control a relevant parameter to the vulnerable function (_Py_char2wchar in 
Python/fileutils.c). It is, however, important that it is remediated since 
unawareness of this vulnerability may cause an unsuspecting author to establish 
a link between user and the function parameter in future versions of Python.

Like I said, the vulnerability is caused by code in the _Py_char2wchar 
function. Indirectly this function is accessed through 
Objects/unicodeobject.c:PyUnicode_DecodeLocaleAndSize(), 
PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_DecodeLocale, and some other 
functions.

As far as I know this can only be exploited on 32-bit architectures (whose 
overflow threshold of its registers is  2**32). The following description sets 
out from the latest Python 3.4 code retrieved from 
https://hg.python.org/cpython .

The problem lies in the computation of size of the buffer that will hold the 
wide char version of the input string:

--
Python/fileutils.c
--
 296 #ifdef HAVE_BROKEN_MBSTOWCS
 297 /* Some platforms have a broken implementation of
 298  * mbstowcs which does not count the characters that
 299  * would result from conversion.  Use an upper bound.
 300  */
 301 argsize = strlen(arg);
 302 #else
 303 argsize = mbstowcs(NULL, arg, 0);
 304 #endif
 ...
 ...
 306 res = (wchar_t *)PyMem_RawMalloc((argsize+1)*sizeof(wchar_t));

 and:

 331 argsize = strlen(arg) + 1;
 332 res = (wchar_t*)PyMem_RawMalloc(argsize*sizeof(wchar_t));

Both invocations to PyMem_RawMalloc are not preceded by code that asserts no 
overflow will occur as a result of multiplication of the length of 'arg' by 
sizeof(wchar_t), which is typically 4 bytes. It follows that on a 32-bit 
architecture, it is possible cause an internal overflow to occur through the 
supplication of a string whose size is >= ((2**32)-1) / 4, which is 1 gigabyte. 
The supplication of a 1 GB (minus one byte) string will therefore result in a 
value of 0 being passed to PyMem_RawMalloc, because:

argsize = 1024*1024*1024-1
malloc_argument = ((argsize+1) * 4
print malloc_argument & 0x
# prints '0'

Effectively this will result in an allocation of exactly 1 byte, since a 
parameter of 0 is automatically adjusted to 1 by the underlying 
_PyMem_RawMalloc():

--
Objects/obmalloc.c
--
  51 static void *
  52 _PyMem_RawMalloc(void *ctx, size_t size)
  53 {
  54 /* PyMem_Malloc(0) means malloc(1). Some systems would return NULL
  55for malloc(0), which would be treated as an error. Some platforms 
would
  56return a pointer with no memory behind it, which would break 
pymalloc.
  57To solve these problems, allocate an extra byte. */
  58 if (size == 0)
  59 size = 1;
  60 return malloc(size);
  61 }


Once the memory has been allocated, mbstowcs() is invoked:

--
Python/fileutils.c
--

 306 res = (wchar_t *)PyMem_RawMalloc((argsize+1)*sizeof(wchar_t));
 307 if (!res)
 308 goto oom;
 309 count = mbstowcs(res, arg, argsize+1);

In my test setup (latest 32 bit Debian), mbstowcs returns '0', meaning no bytes 
were written to 'res'.

Then, 'res' is iterated over and the iteration is halted as soon as a 
null-wchar or a wchar which is a surrogate:

--
Python/fileutils.c
--

 310 if (count != (size_t)-1) {
 311 wchar_t *tmp;
 312 /* Only use the result if it contains no
 313surrogate characters. */
 314 for (tmp = res; *tmp != 0 &&
 315  !Py_UNICODE_IS_SURROGATE(*tmp); tmp++)
 316 ;
 317 if (*tmp == 0) {
 318 if (size != NULL)
 319 *size = count;
 320 return res;
 321 }
 322 }
 323 PyMem_RawFree(res);


Py_UNICODE_IS_SURROGATE is defined as follows:

--
Include/unicodeobject.h
--
 183 #define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF)

In the iteration over 'res', control is transferred back to the invoker of 
_Py_char2wchar() if a null-wchar is encountered first. If, however, a wchar 
that does satisfies the expression in Py_UNICODE_IS_SURROGATE() is encountered 
first, *tmp is not null and thus the conditional code on lines 318-320 is 
skipped.
The space that 'res' points to is unintialized. Uninitialized, however, does 
not not entail randomness in this case. If an attacker has sufficient freedom 
to manipulate the contents of the process memory prior to calling 
_Py_char2wchar() in order to scatter it with values that satisfy 
Py_UNICODE_IS_SURROGATE(), this could increase their odds of having 
_Py_char2wchar() encounter such a va

[issue23111] ftplib.FTP_TLS's default constructor does not work with TLSv1.1 or TLSv1.2

2015-01-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 98ee845a139a by Benjamin Peterson in branch '2.7':
make SSLv23 the default version in ftplib (closes #23111)
https://hg.python.org/cpython/rev/98ee845a139a

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



[issue20606] Operator Documentation Example doesn't work

2015-01-04 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Closed

--
nosy: +asvetlov
resolution:  -> duplicate
stage:  -> resolved
superseder:  -> operator.setitem example no longer works in Python 3 due to 
lazy map

___
Python tracker 

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



[issue23111] ftplib.FTP_TLS's default constructor does not work with TLSv1.1 or TLSv1.2

2015-01-04 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

I think that this fix should be applied also in 2.7 branch.

--
nosy: +Arfrever, benjamin.peterson
resolution: fixed -> 
stage: resolved -> 
status: closed -> open
versions: +Python 2.7, Python 3.4

___
Python tracker 

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



[issue22956] Improved support for prepared SQL statements

2015-01-04 Thread mike bayer

mike bayer added the comment:

prepared statements are, in proportion to the typical speed issues in Python 
(see my comparison benchmark at 
https://mail.python.org/pipermail/db-sig/2014-December/006147.html) a fairly 
small optimization that the DBAPI already allows for in an implicit sense, via 
an internal statement cache - the execute() method of DBAPI (see 
https://www.python.org/dev/peps/pep-0249/#id14) allows for this optimization.   

Therefore an application that wishes to use this optimization with a 
participating DBAPI only need to maintain a reference to the cursor, and 
continue to use that same cursor for the same statement - pretty much 
identically to how it would be used in the explicit prepare step. 

An explicit prepare step should be no more intrusive than an optional flag sent 
along to cursor(), as MySQL-connector does, see 
http://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlconnection-cursor.html.
  

The DBAPI does not use objects to represent statements.   In JDBC, there is a 
Statement and PreparedStatement object, but because JDBC has no explicit sense 
of a "cursor", these are in fact just cursor objects (see 
https://mail.python.org/pipermail/db-sig/2014-December/006168.html for my 
description of this).

Therefore we are really just talking about a potentially modified cursor class, 
and in Python we can just use a flag, there's no need for heavy-handed 
Java-esque concepts like new classes. 

If one really wishes there were a PreparedStatement class, using the flag 
approach one can have it with very simple code that IMO does not belong in the 
DBAPI:

class PreparedStatement(object):
def __init__(self, connection, statement):
self.cursor = connection.cursor(prepared=True)
self.statement = statement

def execute(self, params):
self.cursor.execute(self.statement, params)

def fetchall(self):
return self.cursor.fetchall()

# ... etc

--

___
Python tracker 

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



[issue23132] Faster total_ordering

2015-01-04 Thread Nick Coghlan

Nick Coghlan added the comment:

The metadata adjustments in Serhiy's patch had me thinking in terms of 
functools.wraps, but that rationale doesn't actually apply here (since the 
functions are only used in one place, and have a distinctive name rather than a 
generic one).

I'd also missed that the conversion to standalone module level functions 
inherently provides the same pickle compatibility benefit that Serhiy's patch 
did.

Accordingly, I agree that my suggested factory functions would make the code 
more complex for no benefit.

--

___
Python tracker 

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



[issue20606] Operator Documentation Example doesn't work

2015-01-04 Thread Gareth Rees

Gareth Rees added the comment:

This is a duplicate of #22180, which was fixed in changeset 9c250f34bfa3 by 
Raymond Hettinger in branch '3.4'. The fix just removes the bad example, as in 
my patch. So I suggest that this issue be closed as a duplicate.

--

___
Python tracker 

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



[issue23132] Faster total_ordering

2015-01-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The convert mapping is redundant, function name can be calculated from root and 
opname. __name__ and __doc__ can be assigned at import time.

--

___
Python tracker 

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



[issue23164] "pydoc filter" documentation restrictive

2015-01-04 Thread Eric O. LEBIGOT

New submission from Eric O. LEBIGOT:

The pydoc documentation for filter reads:

filter(function or None, sequence) -> list, tuple, or string

Return those items of sequence for which function(item) is true.  If
function is None, return the items that are true.  If sequence is a tuple
or string, return the same type, else return a list.

It would be nicer to know (e.g. when offline and with no local access to the 
HTML documentation) that filter() can actually be used more generally with an 
iterable:

filter(function or None, **iterable**) -> list, tuple, or string

Return those items of **iterable** for which…

--
assignee: docs@python
components: Documentation
messages: 233416
nosy: docs@python, lebigot
priority: normal
severity: normal
status: open
title: "pydoc filter" documentation restrictive
type: enhancement
versions: Python 2.7

___
Python tracker 

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



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Martin Panter

Martin Panter added the comment:

For what it’s worth, every now and then I have to stop and remember that I 
can’t do this sort of thing:

unsupported_keys = config_dict.keys().difference(supported_list)

though it is not a big problem to rewrite it as

unsupported_keys = config_dict.keys() - set(supported_list)

Also it looks like one can already effectively do x.copy() using the existing 
immutable Set operators, so that worm can is already opened:

>>> ListBasedSet("abc") & ListBasedSet("abc")
<__main__.ListBasedSet object at 0x7f419951b860>

On the other hand, a matching almost equivalent operator does exist for 
a.issubset(b): a <= b, or a.__le__(b).

--

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Devin Jeanpierre

Devin Jeanpierre added the comment:

Thanks for the patch! I was secretly hoping to write it though. :P

Not sure how the code review tool works. The patch looks good to me, except it 
needs tests IMO. I can write them if you think this is not worth the effort.

--

___
Python tracker 

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



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Devin Jeanpierre

Devin Jeanpierre added the comment:

copy() should not be implemented magically, no.

I understand the argument in favor of not implementing redundant methods, but 
if the redundancy was this big a concern, they should not have been added to 
sets in the first place. The current ABCs are inconsistent and confusing. For 
example: MutableSequence implements += and .extend, but on MutableSet, the 
analogous methods |= and .update are only half there. (Moreover, it's the wrong 
half, in my experience.) Plus not all of the named methods have operator 
equivalents, so e.g. is_subset is not supported, but is_disjoint is.

This also means every subclass, in order to actually implement the set API, 
needs to write this code itself. It is very common to call the named methods, 
especially ones like update, and compatibility with set is desirable -- 
otherwise, we wouldn't bother inheriting from the relevant ABC.

--

___
Python tracker 

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



[issue23132] Faster total_ordering

2015-01-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I don't see "creating new functions" as an advantage.  ABCs don't do this, nor 
does any other subclassing.   It seems like an attempt to create a false 
illusion about where the code resides.  This feels like feature creep with no 
real advantage that anyone cares about.  

In the non-templating version, the code is simple and it is clear where it 
came-from (i.e. a code inspector can find it).

IMO, the factory functions just make it harder to grok this code.  Please 
resist the urge invent new magic and stick with the simplest Python that gets 
the job done.

--
assignee:  -> rhettinger

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

While this hasn't proven to be an issue to date (non-reflexive objects don't 
arise much in practice), the proposed change would make it easier to use the 
Sequence ABC to create classes that are interoperable with other sequences and 
that have the clean invariant, "anything added to the sequence will be "in" the 
sequence".

That said, I don't know if this is really needed.

--
keywords: +patch
nosy: +rhettinger
priority: normal -> low
type:  -> behavior
Added file: http://bugs.python.org/file37596/sequence_identity.diff

___
Python tracker 

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



[issue23143] Remove some conditional code in _ssl.c

2015-01-04 Thread Ned Deily

Ned Deily added the comment:

Note that this change causes _ssl.so builds to fail on at least one buildbot, 
the OS X Tiger one, where the system OpenSSL version is 0.9.7.  I've asked the 
buildbot owner to consider installing a local copy of a current OpenSSL.  There 
may be other buildbots affected.

--
nosy: +ned.deily

___
Python tracker 

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



[issue23163] pdb docs need to contain a statement on threads/multithreaded debugging

2015-01-04 Thread Karl Richter

New submission from Karl Richter:

Due to the fact that `pdb` currently simply ignores breakpoints which are set 
and hit in another than the main thread the docs need to contain a statement on 
behavior in a multithreaded environment.

--
components: Library (Lib)
messages: 233409
nosy: krichter
priority: normal
severity: normal
status: open
title: pdb docs need to contain a statement on threads/multithreaded debugging
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



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The r-methods have already been implemented.  Here's the difference as of 
Python 3.4.2:

>>> set(dir(set)) - set(dir(collections.abc.MutableSet))
{'update', 'difference_update', 'symmetric_difference', 'intersection_update', 
'intersection', 'issubset', 'issuperset', 'difference', 'copy', 
'symmetric_difference_update', 'union'}

Guido intentionally omitted the named set-to-set operations in favor of the 
operator versions (__ior__, __lt__, etc).  It was not the intention of the ABC 
to implement the full API (see Guido's PEP 3119 for more of his rationale.

The copy() method was also omitted on purpose. It is a bit of a can-of-worms 
for abstract class to know everything it needs to copy the the concrete set.  
This work is best left to the subclass which has the required knowledge.

I'm closing this one because I'm channeling Guido and thinking he really didn't 
want those methods as part of the ABC.

--
nosy: +rhettinger
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Devin Jeanpierre

Devin Jeanpierre added the comment:

See Raymond Hettinger's comments in http://bugs.python.org/issue4296 for 
details on why the usual sequence behavior is deliberate.

--

___
Python tracker 

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



[issue23161] collections.abc.MutableSet missing methods

2015-01-04 Thread Martin Panter

Changes by Martin Panter :


--
nosy: +vadmium

___
Python tracker 

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



[issue23132] Faster total_ordering

2015-01-04 Thread Nick Coghlan

Nick Coghlan added the comment:

Oops, at least one error in my example: the return tuple should be "__gt__, 
__le__, __ge__".

--

___
Python tracker 

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



[issue23156] Update tix install information in tkinter tix chapter of doc

2015-01-04 Thread Ned Deily

Ned Deily added the comment:

I'm no expert on Tk but, as best I can tell, Tix is a very old third-party set 
of Tk extension widgets that has been made obsolete by the Ttk widget set 
integrated into standard Tk 8.5. See, for example, Kevin Walzer's comments 
here: 
http://www.thecodingforums.com/threads/state-of-the-art-tkinter-tk-8-5-tix.651741/.

Unlike Ttk, Tix is not part of the core Tk distribution so whether or not Tix 
is available depends on the Tcl/Tk distribution in use.  For the Python Windows 
installer, we ship our own version of Tcl/Tk and include a version of Tix.

For the Python OS X installer, we currently do not ship our own version of 
Tcl/Tk, rather we depend on the user installing a third-party version of Tcl/Tk 
(we currently recommend ActiveState's ActiveTcl if the use is compatible with 
ActiveState's license) or falling back to an (old) Apple-supplied version of 
Tcl/Tk.  Neither Apple nor ActiveState include Tix by default.  However, 
ActiveTcl does include Tix in the Tcl Extension Archive 
(http://wiki.tcl.tk/17340) it maintains and provides a command-line program, 
teacup, to download, install, and manage TEA extensions, analogous to Python's 
pip.  So it's straightforward to install Tix if you are using ActiveTcl:

sudo teacup install Tix

Unfortunately, A/S's OS X version of Tix currently downloadable via teacup is 
built as a 32-bit binary only.  The vast majority of users, running on 
up-to-date OS X systems, will run into another failure since their Python will 
likely be running in 64-bit mode:

>>> root = Tix.Tk()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tix.py",
 line 221, in __init__
self.tk.eval('package require Tix')
_tkinter.TclError: 
dlopen(/Library/Tcl/teapot/package/macosx10.5-i386-x86_64/lib/Tix8.4.3/libTix8.4.3.dylib,
 6): no suitable image found.  Did find:

/Library/Tcl/teapot/package/macosx10.5-i386-x86_64/lib/Tix8.4.3/libTix8.4.3.dylib:
 mach-o, but wrong architecture

Depending on the Python instance in use, running a universal Python in 32-bit 
mode may be an option or installing a 32-bit-only Python can be done.  Either 
way, it's an unexpected hack.  I don't know whether there is a fundamental 
problem in building Tix for 64-bit on OS X but I think it is telling that there 
isn't one available from A/S.

Likewise, for other platforms, how you make Tix available, if at all, varies.  
For example, Ubuntu and Debian distributions also do not install Tix by default 
but it can be installed via their standard package managers.

So, all in all, trying to document Tix installation is a major can of worms; I 
don't think we should be trying to do so in the Python documentation.  Further, 
it seems like we should be strongly discouraging use of Tix in favor of Ttk.

--

___
Python tracker 

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



[issue23132] Faster total_ordering

2015-01-04 Thread Nick Coghlan

Nick Coghlan added the comment:

While I like the readability of Raymond's version, I think the main pay-off 
we're getting from the template based version is that each decorator invocation 
is creating *new* function objects.

That creation of new function objects is what allows Serhiy's patch to set 
__module__ and __qualname__ for each method implementation based on the class 
being defined.

The two approaches could be combined by moving the explicit definitions into 
factory functions that always created new function objects and set their 
introspection attributes appropriately. For example (untested code):

def _fix_introspection(module, cls_qualname):
def update_metadata(f):
f.__qualname__ = "%s.%s" % (cls_qualname, f.__name__)
f.__module__ = module
return f
return update_metadata

def _derive_from_lt(module, cls_qualname):
_NotImplemented = NotImplemented

@_fix_introspection(module, cls_qualname)
def __gt__(self, other):
op_result = self.__lt__(other)
if op_result is _NotImplemented:
return _NotImplemented
return not op_result and self != other

@_fix_introspection(module, cls_qualname)
def __le__(self, other):
op_result = self.__lt__(other)
return op_result or self == other

@_fix_introspection(module, cls_qualname)
def __ge__(self, other):
op_result = self.__lt__(other)
if op_result is _NotImplemented:
return _NotImplemented
return not op_result

return __lt__, __gt__, __ge__

--

___
Python tracker 

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



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

2015-01-04 Thread Mayank Tripathi

Mayank Tripathi added the comment:

Added docs to mcsalgado's patch.

--
nosy: +oquanox
Added file: http://bugs.python.org/file37595/home.patch

___
Python tracker 

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



[issue23157] Lib/test/time_hashlib.py doesn't work

2015-01-04 Thread Gregory P. Smith

Gregory P. Smith added the comment:

removing it would also be fine, it's not like it gets used anymore.  the fixes 
were trivial.  done.

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



[issue23157] Lib/test/time_hashlib.py doesn't work

2015-01-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset badb7e319ed0 by Gregory P. Smith in branch '3.4':
fix issue23157 - time_hashlib hadn't been ported to Python 3.
https://hg.python.org/cpython/rev/badb7e319ed0

New changeset b96985753613 by Gregory P. Smith in branch 'default':
fix issue23157 - time_hashlib hadn't been ported to Python 3.
https://hg.python.org/cpython/rev/b96985753613

--
nosy: +python-dev

___
Python tracker 

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



[issue22256] pyvenv should display a progress indicator while creating an environment

2015-01-04 Thread Nick Coghlan

Nick Coghlan added the comment:

I have a vague recollection of originally using check_call, and then switching 
to check_output. However, that may have just been for testing related reasons, 
which could be better handled in the test suite, allowing users to see the pip 
installation output as a progress indicator.

If we add the extra output, adding a -q/--quiet option at the same time would 
be a good idea.

--

___
Python tracker 

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



[issue23162] collections.abc sequences don't check identity before equality

2015-01-04 Thread Devin Jeanpierre

New submission from Devin Jeanpierre:

For sequence __contains__ and other scenarios, identity is checked before 
equality, which I've heard is so that "for x in y: assert x in y" doesn't ever 
fail with an AssertionError (even with NaN and so on). This is not the case for 
collections.abc-based sequences, which is a jarring inconsistency.

--
components: Library (Lib)
messages: 233399
nosy: Devin Jeanpierre
priority: normal
severity: normal
status: open
title: collections.abc sequences don't check identity before equality
versions: Python 3.6

___
Python tracker 

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