[issue23865] Fix possible leaks in close methods

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fe340c2a220e by Serhiy Storchaka in branch '2.7':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/fe340c2a220e

New changeset 7f8cd879687b by Serhiy Storchaka in branch '3.4':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/7f8cd879687b

New changeset 1fb83fa2cdef by Serhiy Storchaka in branch 'default':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/1fb83fa2cdef

--

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



[issue24125] Fix for #23865 breaks docutils

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fe340c2a220e by Serhiy Storchaka in branch '2.7':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/fe340c2a220e

New changeset 7f8cd879687b by Serhiy Storchaka in branch '3.4':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/7f8cd879687b

New changeset 1fb83fa2cdef by Serhiy Storchaka in branch 'default':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/1fb83fa2cdef

--
nosy: +python-dev

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



[issue24009] Get rid of rare format units in PyArg_Parse*

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d65233f630e1 by Serhiy Storchaka in branch 'default':
Issue #24009: Got rid of using rare y# format unit in TextIOWrapper.tell().
https://hg.python.org/cpython/rev/d65233f630e1

--
nosy: +python-dev

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



[issue1104] msilib.SummaryInfo.GetProperty() truncates the string by one character

2015-05-06 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
versions: +Python 3.4, Python 3.5 -Python 3.1, Python 3.2

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

One issue with your code - what would you expect str(test) to produce? 
dir/test.txt or dir\test.txt? That's the point of the flavour - is it a 
Windows path or a Unix path?

Agreed that an easier method of creating Path subclasses that handle this type 
of thing would be useful, but any solution needs to make sure that developers 
don't overlook the Windows vs Unix implications.

Can you give an actual use case (as opposed to the toy example)?

--
nosy: +paul.moore

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



[issue24009] Get rid of rare format units in PyArg_Parse*

2015-05-06 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Note that these format characters can also be used outside of CPython.

--
nosy: +ronaldoussoren

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



[issue24133] Add 'composable' decorator to functools (with @ matrix multiplication syntax)

2015-05-06 Thread levkivskyi

New submission from levkivskyi:

The matrix multiplication operator @ is going to be introduced in Python 3.5 
and I am thinking about the following idea:

The semantics of matrix multiplication is the composition of the corresponding 
linear transformations.
A linear transformation is a particular example of a more general concept - 
functions.
The latter are frequently composed with (wrap) each other. For example:

plot(real(sqrt(data)))

However, it is not very readable in case of many wrapping layers. Therefore, it 
could be useful to employ
the matrix multiplication operator @ for indication of function composition. 
This could be done by such (simplified) decorator:

class composable:

def __init__(self, func):
self.func = func

def __call__(self, arg):
return self.func(arg)

def __matmul__(self, other):
def composition(*args, **kwargs):
return self.func(other(*args, **kwargs))
return composable(composition)

I think using such decorator with functions that are going to be deeply wrapped
could improve readability.
You could compare (note that only the outermost function should be decorated):

plot(sorted(sqrt(real(data_array vs. (plot @ sorted @ sqrt @ real) 
(data_array)

I think the latter is more readable, also compare

def sunique(lst):
return sorted(list(set(lst)))

vs.

sunique = sorted @ list @ set

Apart from readability, there are following pros of the proposed decorator:

1. Similar semantics as for matrix multiplication.
2. Same symbol for composition as for decorators.
3. The symbol @ resembles mathematical notation for function composition: ∘

I think it could be a good idea to add such a decorator to the stdlib functools 
module.

--
components: Library (Lib)
messages: 242653
nosy: levkivskyi
priority: normal
severity: normal
status: open
title: Add 'composable' decorator to functools (with @ matrix multiplication 
syntax)
type: enhancement
versions: Python 3.5

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



[issue24125] Fix for #23865 breaks docutils

2015-05-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue20178] Derby #9: Convert 52 sites to Argument Clinic across 11 files

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For Modules/_curses_panel.c there is special issue, #20171, with the patch.

issue20178-sqlite-01.patch is applied almost clearly, but due to changes to 
Argument Clinic it should be updated. Perhaps more functions can be converted 
(functions that don't use PyArg_Parse* are worth to be converted too).

--

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



[issue12202] Check status returns in msilib.SummaryInformation.GetProperty()

2015-05-06 Thread Mark Lawrence

Mark Lawrence added the comment:

The code change to _msi.c is minimal, the bulk of the patch is additional test 
code.  I think we could still use this.  Thoughts?

See also #1104.

--
components: +Windows
nosy: +BreamoreBoy, steve.dower, tim.golden, zach.ware

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Changes by Christophe BAL projet...@gmail.com:


--
title: Direct sub-classing of pathless.Path - Direct sub-classing of 
pathlib.Path

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



[issue24124] Two versions of instructions for installing Python modules

2015-05-06 Thread Nick Coghlan

Nick Coghlan added the comment:

As far as I'm aware, it's only confusing if you're poking around in the source 
tree, rather than using the built docs at docs.python.org (where the link to 
the legacy docs is now hidden away inside the distutils module docs).

The legacy docs remain in place to preserve existing deep links and because 
they're the only current documentation of various distutils details that are 
needed to *implement* tools like pip and setuptools.

In a more ideal world, we'd have a distutils expert with the time to go through 
the legacy docs, cull the outdated stuff, and lift the rest up into the 
distutils module documentation, but all the folks that might plausibly have the 
expertise to do that also have far more interesting things to do with their 
time :(

--

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



[issue21800] Implement RFC 6855 (IMAP Support for UTF-8) in imaplib.

2015-05-06 Thread Maciej Szulik

Maciej Szulik added the comment:

Yes, I can update that (that IMAP testing bug - 
http://bugs.python.org/issue22137, is taking me longer than I expected it ;)). 
I just want to make sure if I understand you correctly what's needs to be done 
is removing the utf8_enable code from init, we will enable ascii by default and 
only explicit call to enable method will enable it, am I missing something?

--

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



[issue23880] Tkinter: getint and getdouble should support Tcl_Obj

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed in the default branch only. If other issues with Tcl/Tk 8.5 or 8.6 
will be reported, we could apply general solution instead of particular 
workarounds in maintained branches too.

--
assignee:  - serhiy.storchaka
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue23880] Tkinter: getint and getdouble should support Tcl_Obj

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cb80dd82d3da by Serhiy Storchaka in branch 'default':
Issue #23880: Tkinter's getint() and getdouble() now support Tcl_Obj.
https://hg.python.org/cpython/rev/cb80dd82d3da

--
nosy: +python-dev

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Steven D'Aprano

Steven D'Aprano added the comment:

I don't think this is a bug. I think it is just a case that you have to be 
careful when calling functions, you actually do call the function. And that it 
returns what you think it does.

I think the critical point is this:

It turned our that I forgot to return the decorator and instead got the 
default None. But my tests didn't warn me about that.

The solution to that is to always have a test that your decorator actually 
returns a function. That's what I do.

--
nosy: +steven.daprano

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Magnus Carlsson

New submission from Magnus Carlsson:

Hi

I have a little issue with the current assertRaises implementation. It seems 
that it might produce a little different results depending on how you use it.

self.assertRaises(IOError, None)

will not produce the same result as:

with self.assertRaises(IOError):
None()

In the first case everything will be fine due to the fact that assertRaises 
will actually return a context if the second callable parameters is None. The 
second case will throw a TypeError 'NoneType' object is not callable.

I don't use None directly, but replace it with a variable of unknown state and 
you get a little hole where problems can creep in. In my case I was testing 
function decorators and that they should raise some exceptions on special 
cases. It turned our that I forgot to return the decorator and instead got the 
default None. But my tests didn't warn me about that.

Bottom line is that if I use the first assertRaises(Exception, callable) I 
can't rely on it to check that the callable is actually something callable.

I do see that there is a benefit of the context way, but in my opinion current 
implementation will allow problems to go undetected. 

My solution to this would be to rename the context variant into something 
different:
with self.assertRaisesContext(Exception):
do_something()

A side note on this is that reverting back to the original behavior would allow 
you to reevaluate issue9587 for returning the actual exception.

--
components: Library (Lib)
messages: 242658
nosy: magnusc
priority: normal
severity: normal
status: open
title: assertRaises can behave differently
type: behavior
versions: Python 2.7

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



[issue2292] Missing *-unpacking generalizations

2015-05-06 Thread Thomas Wouters

Thomas Wouters added the comment:

FYI, I meant last Monday, but I forgot it was May 4th (Dutch Memorial day) and 
May 5th (Dutch Liberation day), so that got in the way :P

Should we keep this bug open for docs changes, or is there a separate issue for 
that?

--

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



[issue24122] Install fails after configure sets the extending/embedding install directory to NONE

2015-05-06 Thread Matthias Klose

Matthias Klose added the comment:

fixed for 3.4 and 3.5.

--
resolution:  - fixed
status: open - closed

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Possible solution is to use special sentinel instead of None.

--
keywords: +patch
nosy: +ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
stage:  - patch review
versions: +Python 3.4, Python 3.5
Added file: http://bugs.python.org/file39305/assert_raises_sentinel.patch

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



[issue24136] document PEP 448

2015-05-06 Thread Benjamin Peterson

New submission from Benjamin Peterson:

PEP 448 has been implemented (#2292), but the documentation hasn't been 
updated. Updating the documentation will improve looking through

Doc/reference/*

and making sure the documentation (and grammar) for calls and assignments is 
updated for PEP 448's new syntax.

I'm marking this as easy because it might be a good first bug.

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 242668
nosy: benjamin.peterson, docs@python
priority: high
severity: normal
stage: needs patch
status: open
title: document PEP 448
type: enhancement
versions: Python 3.5

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



[issue2292] Missing *-unpacking generalizations

2015-05-06 Thread Benjamin Peterson

Benjamin Peterson added the comment:

On Wed, May 6, 2015, at 09:15, Thomas Wouters wrote:
 
 Thomas Wouters added the comment:
 
 FYI, I meant last Monday, but I forgot it was May 4th (Dutch Memorial
 day) and May 5th (Dutch Liberation day), so that got in the way :P
 
 Should we keep this bug open for docs changes, or is there a separate
 issue for that?

#24136

--

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

It looks like something in the QueryInformationJobObject API has changed with 
Windows 10. The code says:

ok = QueryInformationJobObject(job, JobObjectExtendedLimitInformation,
  info, sizeof(info), rc);
if (!ok || (rc != sizeof(info)) || !job)
error(RC_CREATE_PROCESS, LJob information querying failed);


This call looks right to me based on the MSDN documentation.

Two possibilities I can think of:
1. Bug in Windows 10, which should be reported to Microsoft.
2. the size of the JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure has changed 
in Windows 10, and the SDK used to build Python 2.7 doesn't have the new 
definition.

Do you get the same problem with Python 3.4? If so, that might indicate a 
VS2008 issue. (I don't think this is likely as I checked 
sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION) in VS 2008 and VS 2010 and both 
said 144...)

--

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Magnus Carlsson

Magnus Carlsson added the comment:

The solution to that is to always have a test that your decorator actually 
returns a function. That's what I do.

Yes, I agree that with more tests I would have found the problem, but sometimes 
you forget things. And to me I want the tests to fail by default or for cases 
that are unspecified.

I think the sentinel solution would come a long way of solving both the issue 
that I reported but still keep the context solution intact.

Out of curiosity, would it be a solution to have the sentinel be a real 
function?

def _sentinel():
pass

--

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



[issue23888] Fixing fractional expiry time bug in cookiejar

2015-05-06 Thread ssh

ssh added the comment:

Wouldn't int(float(expires) * 1e6) set the date much further in the future? I'm 
not sure why you'd do that unless the plan is to change the internal time unit 
to microseconds (which seems like a much bigger change, and overkill for 
handling this special case). Cookie strings operate at the second granularity, 
so I'm not sure if the sub-second precision is required.

I took a quick look at curl's code and test cases, and they use a time_t 
structure which doesn't have subsecond precision. Fractional time is not a part 
of their test cases.

https://github.com/bagder/curl/blob/6f8046f7a4bd3d6edcc53c2eec936105ec424d54/tests/libtest/lib517.c

https://github.com/bagder/curl/blob/664b9baf67c2c22ebaf3606298ca9c4ce0b382d2/lib/parsedate.c#L331

Wget also appears to do something similar:

http://bzr.savannah.gnu.org/lh/wget/trunk/annotate/head:/src/cookies.c#L387

--

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



[issue23815] Segmentation fault when create _tkinter objects

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

PyType_Ready() is called inside PyType_FromSpec().

--

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Updated patch includes tests for the function is None. There were no tests for 
assertRaises(), the patch adds them, based on tests for assertWarns().

 Why not sentinel = Object()?

Only for better repr in the case the sentinel is leaked. Other variants are to 
make it named object, such as a function or a class, as Magnus suggested.

--
Added file: http://bugs.python.org/file39306/assert_raises_sentinel_2.patch

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Steve Dower

Steve Dower added the comment:

Null is a valid value for job here (indicates the current process's job), so 
that's probably the check that's failing. When I can sit down with a VM and a 
debugger I'll check, but that won't be until next week.

--

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

Cheers. I missed a bit of code, job comes from job = CreateJobObject(NULL, 
NULL) so it shouldn't be NULL unless that call failed.

Rather than speculate though, I'll leave it with you. Shout if I can help.

--

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



[issue21800] Implement RFC 6855 (IMAP Support for UTF-8) in imaplib.

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

An explicit call to enable with an argument string that contains 'UTF8=ACCEPT'. 
 I did not go far enough through the BNF to determine if enable can be passed 
more than one capability at a time, but I suspect it can.  In which case we 
should factor out the capability parsing such that we can reuse it for parsing 
the enable argument.

--

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



[issue24133] Add 'composable' decorator to functools (with @ matrix multiplication syntax)

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

This should be taken to python-ideas (and probably pypi) first.  You can reopen 
if there is agreement that this should be done.  IMO it should not be done for 
3.5 in any case.

--
nosy: +r.david.murray
resolution:  - later
stage:  - resolved
status: open - closed
versions: +Python 3.6 -Python 3.5

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

Why not sentinel = Object()? 

+1 for the patch, once tests are added.

This may break code in maintenance releases, but presumably that will be 
finding real bugs.  It is hard to imagine someone intentionally passing None to 
get the context manager behavior, even though it is documented in the doc 
strings (but not the main docs, I note).  If anyone can find examples of that, 
though, we'd need to restrict this to 3.5.

--
nosy: +r.david.murray

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



[issue24135] Policy for altering sys.path

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

My guess, unfortunately, is give up.  There is too much code in the field that 
replaces sys.path with a regular list.  What you propose is effectively an 
impossible social engineering problem.  You may well also run into issues where 
the Python C code calls list methods directly even if sys.path is a subclass of 
list. (I don't know that that is true, but there are certainly places where the 
C code does that kind of thing).

Could you get consensus to change stdlib and pip practice?  That's at least 
conceivable.  I guess python-ideas would be the place to start for that.  I'm 
going to close the issue, since this would be a PEP level change if you are 
successful.  (Frankly, I don't think you are likely to be successful, but I 
don't hang out on python-ideas so I might be wrong :)

--
nosy: +r.david.murray
resolution:  - not a bug
stage:  - resolved
status: open - closed

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

The Path classes were not designed to be subclassable by the user.
I'm not against making subclassing easier, but someone will have to propose a 
viable approach for that.

--
versions: +Python 3.5 -Python 3.4

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

Hello.

I will give a real example in 5 hours after my job. I will try tomorrow a
solution to ease the subclassing using another dedicazted class PathPlus,
sorry for the name. The idea would be to use this new class for
customization, and also to define WindowsPath and PosixPath sub-classing
this new class. By default PathPlus would be an empty class. I do not know
if this works well. Maybe my idea is a bad one.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 13:05 GMT+02:00 Antoine Pitrou rep...@bugs.python.org:


 Antoine Pitrou added the comment:

 The Path classes were not designed to be subclassable by the user.
 I'm not against making subclassing easier, but someone will have to
 propose a viable approach for that.

 --
 versions: +Python 3.5 -Python 3.4

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue24132
 ___


--

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The patch looks like a nice improvement.

--
nosy: +rhettinger

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



[issue24135] Policy for altering sys.path

2015-05-06 Thread Thomas Güttler

New submission from Thomas Güttler:

I am missing a policy how sys.path should be altered.

We run a custom sub class of list in sys.path. We set it in sitecustomize.py

This instance get replace by a common list in lines like this:

sys.path = glob.glob(os.path.join(WHEEL_DIR, *.whl)) + sys.path

The above line is from pip, it similar things happen in a lot of packages.

Before trying to solve this with code, I think the python community should 
agree an a policy for altering sys.path.

What can I do to this done?

We use Python 2.7.

--
messages: 242664
nosy: Thomas Güttler
priority: normal
severity: normal
status: open
title: Policy for altering sys.path

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Henrik Heimbuerger

Henrik Heimbuerger added the comment:

I can confirm this issue for pip 6.1.1 on Windows 10.0.10074 for both Python 
2.7.9 as well as 3.4.3.

As a workaround, using python -m pip works fine (as suggested on 
http://stackoverflow.com/a/26428562/6278 for a different issue).

--
nosy: +hheimbuerger

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file39308/long_free_list.patch

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Larry Hastings

Larry Hastings added the comment:

10**3 doesn't show off this hack as much as other numbers would; the hack only 
operates from 257 to the max in that will fit in a single long digit (32767 
on 32-bit, 2**30 on 64-bit).

Anyway, freelist for one-digit longs seems nearly as good, and it's a lot more 
general-purpose, so I'm much more interested in that.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

Here are for example two extra methods that I have implemented.

def __sub__(cls, path):

This magic method allows to use ``onepath - anotherpath`` instead of the
long
version ``onepath.relative_to(anotherpath)`` given by ``pathlib.Path``.

return cls.relative_to(path)

def _ppath_common_with(cls, paths):

This method returns the path of the smaller common folder of the current
path
and at least one paths.

python::
from mistool import os_use

path   = os_use.PPath(/Users/projects/source/doc)
path_1 = os_use.PPath(/Users/projects/README)
path_2 = os_use.PPath(/Users/projects/source/misTool/os_use.py)

print(path.common_with((path_1, path_2)))

if not isinstance(paths, (list, tuple)):
paths = [paths]

commonparts = list(cls.parts)

for onepath in paths:
i = 0

for common, actual in zip(commonparts, onepath.parts):
if common == actual:
i += 1
else:
break

commonparts = commonparts[:i]

if not commonparts:
break

commonpath = pathlib.Path()

for part in commonparts:
commonpath /= part

return commonpath

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 14:13 GMT+02:00 Christophe BAL rep...@bugs.python.org:


 Christophe BAL added the comment:

 Hello.

 I will give a real example in 5 hours after my job. I will try tomorrow a
 solution to ease the subclassing using another dedicazted class PathPlus,
 sorry for the name. The idea would be to use this new class for
 customization, and also to define WindowsPath and PosixPath sub-classing
 this new class. By default PathPlus would be an empty class. I do not know
 if this works well. Maybe my idea is a bad one.

 *Christophe BAL*
 *Enseignant de mathématiques en Lycée **et développeur Python amateur*
 *---*
 *French math teacher in a Lycée **and **Python **amateur developer*

 2015-05-06 13:05 GMT+02:00 Antoine Pitrou rep...@bugs.python.org:

 
  Antoine Pitrou added the comment:
 
  The Path classes were not designed to be subclassable by the user.
  I'm not against making subclassing easier, but someone will have to
  propose a viable approach for that.
 
  --
  versions: +Python 3.5 -Python 3.4
 
  ___
  Python tracker rep...@bugs.python.org
  http://bugs.python.org/issue24132
  ___
 

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue24132
 ___


--

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



[issue23346] shutil.rmtree doesn't work correctly on FreeBSD.

2015-05-06 Thread sumpfralle

sumpfralle added the comment:

I experience the same issue on a virtualized server (based on Virtuozzo) with 
Linux kernel 2.6.32.

The following command fails:

 echo import os; os.listdir(os.open('/tmp', os.O_RDONLY)) | python3
 Traceback (most recent call last):
   File stdin, line 1, in module
 OSError: [Errno 22] Invalid argument

--
nosy: +sumpfralle

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



[issue1222585] C++ compilation support for distutils

2015-05-06 Thread Erik Hvatum

Erik Hvatum added the comment:

The 2012-12-31 of this patch (currently the latest) has the surprising effect 
of causing distutils CFLAGS to be dropped.  See for reference: 
https://bugs.gentoo.org/show_bug.cgi?id=548776

The issue I am experiencing is resolved by changing the section of the patch 
that reads:

+-(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, 
ar_flags) = \
+-get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+-'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 
'ARFLAGS')
++(cc, cxx, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, 
ar_flags) = \
++get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 
'LDCXXSHARED',
++'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
++
++cflags = ''
++cxxflags = ''

to:

+-(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, 
ar_flags) = \
+-get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+-'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 
'ARFLAGS')
++(cc, cxx, cflags, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, 
ar_flags) = \
++get_config_vars('CC', 'CXX', 'CFLAGS', 'CCSHARED', 'LDSHARED', 
'LDCXXSHARED',
++'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
++
++cxxflags = cflags

This change causes the CFLAGS outputted by python-config --cflags to be used 
by distutils, as they are without the patch applied.  To me, losing those 
CFLAGS, especially when building plain C python extensions, seems like a 
significant regression.

--
nosy: +ehvatum
versions: +Python 3.4 -Python 3.5

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



[issue1222585] C++ compilation support for distutils

2015-05-06 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy:  -brian.curtin

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

 What is the good way to propose a patch ?

If you have a patch, attach it here, and it will get reviewed.

--

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



[issue22906] PEP 479: Change StopIteration handling inside generators

2015-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

Hi Chris! Can I somehow help with the patch?

--
nosy: +yselivanov

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

I have no problem with that - it's a style choice certainly.

As I said, I'd like to see simpler subclassing of pathlib objects. I just think 
it'll be quite hard to do (given the complexities of classes for Windows/Unix 
as well as pure and concrete paths). So if it's just about examples like this, 
I personally would take the easier route and just go with standalone functions. 
If someone else felt strongly enough to design and implement a subclassing 
solution, that's fine though.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

Are you the author of path lib ?

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 21:01 GMT+02:00 Paul Moore rep...@bugs.python.org:


 Paul Moore added the comment:

 I have no problem with that - it's a style choice certainly.

 As I said, I'd like to see simpler subclassing of pathlib objects. I just
 think it'll be quite hard to do (given the complexities of classes for
 Windows/Unix as well as pure and concrete paths). So if it's just about
 examples like this, I personally would take the easier route and just go
 with standalone functions. If someone else felt strongly enough to design
 and implement a subclassing solution, that's fine though.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue24132
 ___


--

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This regression was just discussed in issue24076. General suggestion about free 
list for small ints was proposed. It could speed up other integer computations, 
but comprehensive benchmarking results are needed.

See also similar issue23507 for tuples. Perhaps we need general solution for 
fast specialized free lists.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

For that type of function, I'd suggest you use a standalone function rather 
than subclassing and methods or operator overloading. You don't gain enough to 
be worth the complexity of having to subclass path objects. And duck typing 
means that your function works for any subclass of (Pure)Path without change.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

I don't agree with you. I prefer to add new functionalities to the paths I
use. This is the power of OOP. It is easier and cleaner to use
*mypath.common_with(otherpath)*  than  *common_with(**mypath, **other path)*
.

Python is highly OOP, so you can't say *don't use subclassing in your
case*. As a user, I should have the possibility to use the method I want.

Another example is the use of  *onepath - anotherpath*  instead of
*onepath.relative_to(**another path)* . That's the power of the magic
method to add this kind of feature.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 20:21 GMT+02:00 Paul Moore rep...@bugs.python.org:


 Paul Moore added the comment:

 For that type of function, I'd suggest you use a standalone function
 rather than subclassing and methods or operator overloading. You don't gain
 enough to be worth the complexity of having to subclass path objects. And
 duck typing means that your function works for any subclass of (Pure)Path
 without change.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue24132
 ___


--

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Mark Lawrence

Mark Lawrence added the comment:

How does this apply where people like me scarcely if ever use range, it's 
standard for loops?  There are plenty of recipes using itertools that show that 
you don't need range, is this really needed?  No axe to grind, just curious.

--
nosy: +BreamoreBoy

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

Adding Jason Coombs and Vinay Sajip, as if this needs a fix to the launcher 
code, then the launchers used by distlib and setuptools (for exe wrappers of 
console entry points) will need to be changed as well.

It would be really useful if all 3 projects used a single codebase - having to 
duplicate fixes like this is annoying.

--
nosy: +jason.coombs

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

 Are you the author of path lib ?

Nope, that's Antoine.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

OK.
I will try to find a way to achieve an easier and cleaner way to sub class
pathlib.Path and co.

What is the good way to propose a patch ?

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 21:09 GMT+02:00 Paul Moore rep...@bugs.python.org:


 Paul Moore added the comment:

  Are you the author of path lib ?

 Nope, that's Antoine.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue24132
 ___


--

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Larry Hastings

New submission from Larry Hastings:

This probably shouldn't be checked in.  But it was an interesting experiment, 
and I did get it to work.

My brother forwarded me this question from Stack Overflow:

http://stackoverflow.com/questions/23453133/is-there-a-reason-python-3-enumerates-slower-than-python-2

The debate brought up a good point: a lot of the overhead of range() is in 
creating and destroying the long objects.  I wondered, could I get rid of that? 
 Long story short, yes.

rangeiterobject is a special-case range object for when you're iterating over 
integer values and the values all fit inside C longs.  Otherwise it has to use 
the much slower general-purpose longrangeiterobject.)  rangeiter_next is 
simple: it computes the new value then returns PyLong_FromLong of that value.

First thought: cache a reference to the previous value.  If its reference count 
is 1, we have the only reference.  Overwrite its value and return it.  But that 
doesn't help in the general case, because in for x in range(1000) x is 
holding a reference at the time __next__ is called on the iterator.

The trick: cache *two* old yielded objects.  In the general case, by the second 
iteration, everyone else has dropped their references to the older cached 
object and we can modify it safely.

The second trick: if the value you're yielding is one of the interned small 
ints, you *have* to return the interned small int.  (Otherwise you break 0 == 
0, I kid you not.)

With this patch applied all regression tests pass.  And, on my desktop machine, 
the benchmark they used in the above link:

./python -mtimeit -n 5 -r 2 -scnt = 0 for i in range(1000): cnt += 1

drops from 410ms to 318ms (5 loops, best of 2: 318 msec per loop).


This implementation requires the rangeiterobject to have intimate knowledge of 
the implementation of the PyLongObject, including copy-and-pasting some 
information that isn't otherwise exposed (max small int essentially).  At the 
very least that information would need to be exposed properly so 
rangeiterobject could use it correctly before this could be checked in.

It might be cleaner for longobject.c to expose a private set this long object 
to this value function.  It would fail if we can't do it safely: if the value 
was an interned (small) int, or if the long was of the wrong size (Py_SIZE(o) 
!= 1).


Is this interesting enough to pursue?  I'm happy to drop it.

--
assignee: larry
components: Interpreter Core
files: larry.range.hack.1.txt
messages: 242685
nosy: larry, pitrou, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Speed up range() by caching and modifying long objects
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file39307/larry.range.hack.1.txt

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Stefan Behnel

Stefan Behnel added the comment:

See issue 24076.

--
nosy: +scoder

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



[issue8372] socket: Buffer overrun while reading unterminated AF_UNIX addresses

2015-05-06 Thread David Watson

David Watson added the comment:

Attaching patches for 3.5.

--
Added file: 
http://bugs.python.org/file39309/enable-unterminated-3.5-2015-05-06.diff
Added file: http://bugs.python.org/file39310/fix-overrun-3.5-2015-05-06.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8372
___# HG changeset patch
# Parent  5f2ae82157af71456c4837ff2838d1f0f01e759e
Allow AF_UNIX pathnames up to the maximum 108 bytes on Linux,
since it does not require sun_path to be null terminated.

diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -4477,6 +4477,54 @@ class TestExceptions(unittest.TestCase):
 self.assertTrue(issubclass(socket.timeout, OSError))
 
 @unittest.skipUnless(sys.platform == 'linux', 'Linux specific test')
+class TestLinuxPathLen(unittest.TestCase):
+
+# Test AF_UNIX path length limits on Linux.
+
+UNIX_PATH_MAX = 108
+
+def setUp(self):
+self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+self.to_unlink = []
+
+def tearDown(self):
+self.sock.close()
+for name in self.to_unlink:
+support.unlink(name)
+
+def pathEncodingArgs(self):
+# Return the encoding and error handler used to encode/decode
+# pathnames.
+encoding = sys.getfilesystemencoding()
+if encoding is None:
+encoding = sys.getdefaultencoding()
+return encoding, surrogateescape
+
+def pathname(self, length):
+# Return a bytes pathname of the given length.
+path = os.path.abspath(support.TESTFN)
+path_bytes = path.encode(*self.pathEncodingArgs())
+return path_bytes + ba * (length - len(path_bytes))
+
+def testPathTooLong(self):
+# Check we can't bind to a path longer than the assumed maximum.
+path = self.pathname(self.UNIX_PATH_MAX + 1)
+with self.assertRaisesRegexp(socket.error, AF_UNIX path too long):
+self.sock.bind(path)
+self.to_unlink.append(path)
+
+def testMaxPathLen(self):
+# Test binding to a path of the maximum length and reading the
+# address back.  In this case, sun_path is not null terminated,
+# and makesockaddr() used to read past the end of it.
+path = self.pathname(self.UNIX_PATH_MAX)
+self.sock.bind(path)
+self.to_unlink.append(path)
+self.assertEqual(self.sock.getsockname(),
+ path.decode(*self.pathEncodingArgs()))
+os.stat(path)
+
+@unittest.skipUnless(sys.platform == 'linux', 'Linux specific test')
 class TestLinuxAbstractNamespace(unittest.TestCase):
 
 UNIX_PATH_MAX = 108
@@ -5303,6 +5351,7 @@ def test_main():
 ])
 tests.append(BasicSocketPairTest)
 tests.append(TestUnixDomain)
+tests.append(TestLinuxPathLen)
 tests.append(TestLinuxAbstractNamespace)
 tests.extend([TIPCTest, TIPCThreadableTest])
 tests.extend([BasicCANTest, CANTest])
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1460,27 +1460,17 @@ getsockaddrarg(PySocketSockObject *s, Py
 
 addr = (struct sockaddr_un*)addr_ret;
 #ifdef linux
-if (path.len  0  *(const char *)path.buf == 0) {
-/* Linux abstract namespace extension */
-if ((size_t)path.len  sizeof addr-sun_path) {
-PyErr_SetString(PyExc_OSError,
-AF_UNIX path too long);
-goto unix_out;
-}
-}
-else
-#endif /* linux */
-{
-/* regular NULL-terminated string */
-if ((size_t)path.len = sizeof addr-sun_path) {
-PyErr_SetString(PyExc_OSError,
-AF_UNIX path too long);
-goto unix_out;
-}
-addr-sun_path[path.len] = 0;
+if ((size_t)path.len  sizeof(addr-sun_path)) {
+#else
+if ((size_t)path.len = sizeof(addr-sun_path)) {
+#endif
+PyErr_SetString(PyExc_OSError, AF_UNIX path too long);
+goto unix_out;
 }
 addr-sun_family = s-sock_family;
 memcpy(addr-sun_path, path.buf, path.len);
+memset(addr-sun_path + path.len, 0,
+   sizeof(addr-sun_path) - path.len);
 *len_ret = path.len + offsetof(struct sockaddr_un, sun_path);
 retval = 1;
 unix_out:
# HG changeset patch
# Parent  ac51dc99c1bd722e1b24b4bfa14520082e01f1a8
When parsing addresses returned by accept(), etc., do not assume
null termination of sun_path in AF_UNIX addresses: rely instead
on the returned address length.  If this is longer then the
original buffer, ignore it and use the original length.

diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1129,13 

[issue24134] assertRaises can behave differently

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you David for your corrections.

--
assignee:  - serhiy.storchaka
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 111ec3d5bf19 by Serhiy Storchaka in branch '2.7':
Issue #24134: assertRaises() and assertRaisesRegexp() checks are not longer
https://hg.python.org/cpython/rev/111ec3d5bf19

New changeset 5418ab3e5556 by Serhiy Storchaka in branch '3.4':
Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and
https://hg.python.org/cpython/rev/5418ab3e5556

New changeset 679b5439b9a1 by Serhiy Storchaka in branch 'default':
Issue #24134: assertRaises(), assertRaisesRegex(), assertWarns() and
https://hg.python.org/cpython/rev/679b5439b9a1

--
nosy: +python-dev

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



[issue23888] Fixing fractional expiry time bug in cookiejar

2015-05-06 Thread Demian Brecht

Demian Brecht added the comment:

Thanks for the follow up on that. In light of your findings, I agree with the 
path you've taken in your patch (and yeah, you'd have to deal with conversions 
in the output if you were to take my suggestion). I've left a couple minor 
comments in Reitveld. Other than those, the patch LGTM.

--

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



[issue9517] Make test.script_helper more comprehensive, and use it in the test suite

2015-05-06 Thread Christie

Christie added the comment:

Thanks very much @berker.peksag!

--

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



[issue24070] Exceptions and arguments disappear when using argparse inside with statement

2015-05-06 Thread Roy Hyunjin Han

Roy Hyunjin Han added the comment:

The behavior may not be surprising from a technical perspective, but it is 
unintuitive.

I think exceptions inside a with statement should trigger a traceback, unless 
you are saying that it is the responsibility of the author to catch and raise 
the exception inside __exit__, which feels to me like a workaround that is 
specific to parse_args.

--

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



[issue24070] Exceptions and arguments disappear when using argparse inside with statement

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

What is happening here is that the __exit__ method gets passed the exception, 
and then instead of returning and allowing the exception to propagate and be 
printed, it raises SystemExit (via parse_args), which causes Python to 
immediately shut down, *before* __exit__ returns and the exception is 
propagated.

So yes, you'd have to do something specific for argparse (which raises a 
SystemExit exception if parsing fails) if you want to do something non-normal 
with SystemExit.  That is, you'll need to catch SystemExit.

This is really a duplicate of issue 9938.

--
dependencies: +Documentation for argparse interactive use
nosy: +r.david.murray
resolution: not a bug - duplicate
stage:  - resolved
versions: +Python 3.4, Python 3.5 -Python 3.3

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch that adds a free list for 1-digit long objects.

$ ./python -m timeit -s r = range(10**3) -- for i in r: pass
Unpatched: 1 loops, best of 3: 54.4 usec per loop
With free list: 1 loops, best of 3: 38 usec per loop
With hacked range: 1 loops, best of 3: 34.5 usec per loop
Python 2.7: 1 loops, best of 3: 37.1 usec per loop

$ ./python -m timeit -s r = list(range(10**3)) -- for i in r: pass
1 loops, best of 3: 30.7 usec per loop

In Python 2.7:
$ ./python -m timeit -s r = xrange(10**3) -- for i in r: pass
1 loops, best of 3: 41.4 usec per loop
$ ./python -m timeit -s r = range(10**3) -- for i in r: pass
1 loops, best of 3: 37.1 usec per loop

--

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



[issue23888] Fixing fractional expiry time bug in cookiejar

2015-05-06 Thread ssh

ssh added the comment:

Attaching patch after addressing comments in code review.

--
Added file: http://bugs.python.org/file39311/mywork.patch

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



[issue22906] PEP 479: Change StopIteration handling inside generators

2015-05-06 Thread Chris Angelico

Chris Angelico added the comment:

You sure can! Take it, deploy it, run the test suite, and then start writing 
real code that uses it. When you find a problem, that's what needs help! :)

--

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



[issue24137] Force not using _default_root in IDLE

2015-05-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Perhaps explicitly calling NoDefaultRoot() in IDLE will help to catch some 
possible bugs (in IDLE or in Tkinter). It should be called only when IDLE is 
ran in subprocess mode, so it will not affect user code that uses Tkinter. 
_default_root is used mainly for interactive experiments with Tkinter.

It is worth also to call NoDefaultRoot() in IDLE tests (see Tkinter tests as a 
guide).

--
components: IDLE, Tkinter
messages: 242680
nosy: kbk, roger.serwy, serhiy.storchaka, terry.reedy
priority: normal
severity: normal
status: open
title: Force not using _default_root in IDLE
type: enhancement
versions: Python 3.5

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



[issue22334] test_tcl.test_split() fails on x86 FreeBSD 7.2 3.x buildbot

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The test no longer failed since fixing full Tcl version parsing in 
cebe15821a0c/5bf0d9086cfc/9f13e9385186. It is now just skipped on non-final Tcl 
8.6.

In any case I suggest to upgrade Tcl/Tk on this buildbot.

--
resolution:  - out of date
stage:  - resolved
status: open - closed

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

Made a couple of review comments on the English in the test comments.

Patch looks good to me.

--

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Henrik Heimbuerger

Henrik Heimbuerger added the comment:

To your earlier question: yes, I can reproduce this with Python 3.4.3.

This is all on Windows 10.0.10074, 64-bit. I don't have a 32-bit system to 
test. UAC configuration is unmodified and on the default setting (third of the 
four steps on the slider).

Python has been installed using the MSI installer without administrative 
rights. On Python 2, pip has been installed using the official 6.1.1 
get-pip.py. For Python 3, it has been tested both with the preinstalled pip (I 
believe that was 6.0.8) as well as after upgrading it from PyPI (using the 
python -m pip workaround).

--

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