[issue20430] Make argparse.SUPPRESS work as an argument "dest"

2016-04-24 Thread paul j3

paul j3 added the comment:

I just found a case where `dest` is `SUPPRESS` - the default subparsers setup.

  _SubParsersAction(option_strings=[], dest='==SUPPRESS==', nargs='A...', 
...

If I make this Action 'required' (in the current distribution 'subparsers' are 
not required - there's a bug/issue for that)

 parser._actions[1].required=True

and call the parser without the required subparser argument I should get an 
error message.  In earlier versions this would have been a non specific,  
`error: too few arguments', but the new one tries to name the missing argument, 
e.g.

program: error: the following arguments are required: choice

But with SUPPRESS I get a further error as _parse_known_args tries to format 
this error message:

C:\Users\paul\Miniconda3\lib\argparse.py in _parse_known_args(self, 
arg_strings, namespace)
   1991 if required_actions:
   1992 self.error(_('the following arguments are required: %s') %
-> 1993', '.join(required_actions))

TypeError: sequence item 0: expected str instance, NoneType found

(This error may have been reported elsewhere.  This issue is the first one I 
found that deals with `dest=argparse.SUPPRESS`.)

--

___
Python tracker 

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



[issue24114] ctypes.utils uninitialized variable 'paths'

2016-04-24 Thread Berker Peksag

Changes by Berker Peksag :


--
keywords: +easy
versions: +Python 3.5, Python 3.6

___
Python tracker 

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



[issue24331] *** Error in `/usr/bin/python': double free or corruption (!prev): 0x0000000000f5c760 *** when cloning hg repository into directory on cifs

2016-04-24 Thread Berker Peksag

Berker Peksag added the comment:

Agreed, this is unlikely an issue with Python. Please report it to Mercurial 
developers.

--
nosy: +berker.peksag
resolution:  -> third party
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



[issue23961] IDLE autocomplete window does not automatically close when selection is made

2016-04-24 Thread Berker Peksag

Changes by Berker Peksag :


--
stage:  -> resolved
status: open -> closed
superseder:  -> IDLE code completion window can hang or misbehave with mouse

___
Python tracker 

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



[issue11063] uuid.py module import has heavy side effects

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

One thing I am wondering about is why we have to use find_library() at all. 
Wouldn’t it be more robust, and more efficient, to call CDLL() directly? We 
just have to know the exactly library version we are expecting. On Linux, the 
full soname is libuuid.so.1. It seems on OS X it is called libc.dylib (but it 
would be good for someone else to confirm).

# The uuid_generate_* routines are provided by libuuid on at least
# Linux and FreeBSD, and provided by libc on Mac OS X.
if sys.platform == "darwin":
libname = "libc.dylib"
else:
libname = "libuuid.so.1"
_ctypes_lib = ctypes.CDLL(libname)

--
nosy: +martin.panter

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

Maybe Issue 21826 is relevant (slowdown on AIX caused by missing ldconfig)

--
nosy: +martin.panter

___
Python tracker 

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



[issue21826] Performance issue (+fix) AIX ctypes.util with no /sbin/ldconfig present

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

See also Issue 26439 about find_library() AIX support

--
nosy: +martin.panter

___
Python tracker 

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



[issue21622] ctypes.util incorrectly fails for libraries without DT_SONAME

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

On Linux, the find_library() function is documented to return “the filename of 
the library file”, but in reality it seems it return the soname, and therefore 
breaks if there is no soname. I do not know why we extract the soname, but it 
has been that way at least since ctypes was added to Python 2.5.

What do you intend to do with the result of find_library()? See also Issue 
9998, especially about searching LD_LIBRARY_PATH. I am struggling to see robust 
use cases for find_library().

--
nosy: +martin.panter

___
Python tracker 

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



[issue19317] ctypes.util.find_library should examine binary's RPATH on Solaris

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

find_library() is documented as emulating the build-time linker, and I suspect 
the RPATH of the Python executable is not relevant at build time. See also 
Issue 9998 and Issue 18502.

--
nosy: +martin.panter

___
Python tracker 

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



[issue9998] ctypes find_library should search LD_LIBRARY_PATH on linux

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

I also found Issue 18502 essentially about the same incompatibility between 
CDLL() and find_library().

The problem I see with using find_library() to blindly load a library is that 
you could be loading an incompatible version (wrong soname). That is why I 
asked Pau why they couldn’t give the proper library name to CDLL().

I noticed that Python’s own “uuid” module calls CDLL(find_library("uuid")); see 
. On my Linux 
computer, the full library name is libuuid.so.1, and according to online man 
pages, this is also the case on Free BSD. So I wonder if the “uuid” module 
should call CDLL("libuuid.so.1") directly. If somebody invented a new 
incompatible version libuuid.so.2, Python’s uuid module might crash, or become 
subtly broken, but programs that linked directly to libuuid.so.1 would continue 
to work.

Does anyone have any valid use cases where they want to use a shared library on 
LD_LIBRARY_PATH or similar, but cannot use CDLL() or LoadLibrary() directly? If 
people really want a way to load a library given its compile-time name, maybe 
changing find_library() is a valid way forward. But to me the use case does not 
seem robust or worth blessing in Python’s standard library.

--

___
Python tracker 

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



[issue26843] tokenize does not include Other_ID_Start or Other_ID_Continue in identifier

2016-04-24 Thread Joshua Landau

New submission from Joshua Landau:

This is effectively a continuation of https://bugs.python.org/issue9712.

The line in Lib/tokenize.py

Name = r'\w+'

must be changed to a regular expression that accepts Other_ID_Start at the 
start and Other_ID_Continue elsewhere. Hence tokenize does not accept '℘·'.


See the reference here:

https://docs.python.org/3.5/reference/lexical_analysis.html#identifiers

I'm unsure whether unicode normalization (aka the `xid` properties) needs to be 
dealt with too.


Credit to toriningen from http://stackoverflow.com/a/29586366/1763356.

--
components: Library (Lib)
messages: 264145
nosy: Joshua.Landau
priority: normal
severity: normal
status: open
title: tokenize does not include Other_ID_Start or Other_ID_Continue in 
identifier
type: behavior
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



[issue26793] uuid causing thread issues when forking using os.fork py3.4+

2016-04-24 Thread Steven Adams

Steven Adams added the comment:

anyone got any other thoughts on this??

--

___
Python tracker 

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



[issue18502] CDLL does not use same paths as util.find_library

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

Documenting this quirk seems reasonable to me if you want to suggest a patch 
(and we don’t agree to fix it).

See Issue 21042 for returning full paths on Linux. We tried to make this 
change, but it wasn’t easy to do it consistently for arbitrary ABIs, so I 
backed it out.

See Issue 9998 discussing changing find_library() to emulate a run-time linker, 
rather than a compile-time linker.

--
nosy: +martin.panter

___
Python tracker 

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



[issue6338] Error message displayed on stderr when no C compiler is present with ctypes

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

It would be good to close the file when it’s no longer needed. Also, if this 
bug is relevant to Python 3, I would use open() rather than file().

--
nosy: +martin.panter
stage:  -> patch review

___
Python tracker 

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



[issue24114] ctypes.utils uninitialized variable 'paths'

2016-04-24 Thread Martin Panter

Changes by Martin Panter :


--
stage: patch review -> needs patch
title: ctypes.utils uninitialized variable 'path' -> ctypes.utils uninitialized 
variable 'paths'
type:  -> behavior

___
Python tracker 

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



[issue15873] datetime: add ability to parse RFC 3339 dates and times

2016-04-24 Thread Eric Hanchrow

Changes by Eric Hanchrow :


--
nosy: +Eric.Hanchrow

___
Python tracker 

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



[issue21622] ctypes.util incorrectly fails for libraries without DT_SONAME

2016-04-24 Thread Kylie McClain

Kylie McClain added the comment:

This is still a problem on musl distributions as of 2.7.11. Are there any plans 
to fix this?

Patch used by Alpine Linux:
http://git.alpinelinux.org/cgit/aports/tree/main/python/musl-find_library.patch

--
nosy: +Kylie McClain

___
Python tracker 

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



[issue26804] Prioritize lowercase proxy variables in urllib.request

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

Yes that was my rambling way of saying that I had checked to see if they were 
in the right place, and reporting that it was all okay :)

New patch seems okay to me.

--

___
Python tracker 

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



[issue26800] Don't accept bytearray as filenames part 2

2016-04-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3fb0f9a0b195 by Guido van Rossum in branch 'default':
Rip out the promotion from bytearray/memoryview to bytes. See 
http://bugs.python.org/issue26800.
https://hg.python.org/peps/rev/3fb0f9a0b195

--
nosy: +python-dev

___
Python tracker 

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



[issue26800] Don't accept bytearray as filenames part 2

2016-04-24 Thread Guido van Rossum

Guido van Rossum added the comment:

Sigh, I was wrong, not only does mypy promote bytearray to bytes, it
actually depends on this in its own code. Not for filenames, but for a
regex match. It reads the source into a bytearray, and then passes that to
something that uses regex matches (which *do* support bytearrays, and
rightly so). If I remove the bytearray promotion I run into some type
errors, and if I fix those (without copying data) I run into more type
errors. I guess we could fix it by carefully marking up everything that
takes bytearrays in the stubs, but it's surely inconvenient. So maybe I'll
leave this in mypy for now.

--

___
Python tracker 

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



[issue26837] assertSequenceEqual() raises BytesWarning when format message

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

I think the change is good in spirit, especially using repr() and limiting the 
size. See the review for a couple problems.

--
nosy: +martin.panter
stage:  -> patch review

___
Python tracker 

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



[issue26800] Don't accept bytearray as filenames part 2

2016-04-24 Thread Guido van Rossum

Guido van Rossum added the comment:

OK, it isn't worth fighting for. I will update PEP 484. It seems mypy
doesn't support the special treatment bytearray anyway.

For posterity, the reason I thought that bytearray should be accepted is
not that bytearray is better in any way, just that sometimes you might read
a filename off a bytearray that you read off a file or a socket. But it's
clearly not a strong use case (or we had gotten complaints long ago) so
I'll let it go. Sorry!! Thanks for the feedback.

--

___
Python tracker 

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



[issue26842] Python Tutorial 4.7.1: Need to explain default parameter lifetime

2016-04-24 Thread Edward Segall

New submission from Edward Segall:

I am using the tutorial to learn Python. I know many other languages, and I've 
taught programming language theory, but even so I found the warning in Section 
4.7.1 about Default Argument Values to be confusing. After I spent some effort 
investigating what actually happens, I realized that the warning is incomplete. 

I'll suggest a fix below, after explaining what concerns me. 

Here is the warning in question:

-
Important warning: The default value is evaluated only once. This makes a 
difference when the default is a mutable object such as a list, dictionary, or 
instances of most classes. ...

def f(a, L=[]):
L.append(a)
return L

print(f(1))
print(f(2))
print(f(3))

This will print

[1]
[1, 2]
[1, 2, 3]
-

It's clear from this example that values are carried from one function 
invocation to another. That's pretty unusual behavior for a "traditional" 
function, but it's certainly not unheard of -- in C/C++/Java, you can preserve 
state across invocations by declaring that a local variable has static 
lifetime. When using this capability, though, it's essential to understand 
exactly what's happening -- or at least well enough to anticipate its behavior 
under a range of conditions. I don't believe the warning and example are 
sufficient to convey such an understanding. 

After playing with it for a while, I've concluded the following: "regular" 
local variables have the usual behavior (called "automatic" lifetime in C/C++ 
jargon), as do the function's formal parameters, EXCEPT when a default value is 
defined. Each default value is stored in a location that has static lifetime, 
and THAT is the reason it matters that (per the warning) the expression 
defining the default value is evaluated only once. 

This is very unfamiliar behavior -- I don't think I have used another modern 
language with this feature. So I think it's important that the explanation be 
very clear. 

I would like to suggest revising the warning and example to something more like 
the following: 

-
Important warning: When you define a function with a default argument value, 
the expression defining the default value is evaluated only once, but the 
resultant value persists as long as the function is defined. If this value is a 
mutable object such as a list, dictionary, or instance of most classes, it is 
possible to change that object after the function is defined, and if you do 
that, the new (mutated) value will subsequently be used as the default value.  

For example, the following function accepts two arguments:

def f(a, L=[]):
L.append(a)
return L

This function is defined with a default value for its second formal parameter, 
called L. The expression that defines the default value denotes an empty list. 
When the function is defined, this expression is evaluated once. The resultant 
list is saved as the default value for L. 

Each time the function is called, it appends the first argument to the second 
one by invoking the second argument's append method. 

If we call the function with two arguments, the default value is not used. 
Instead, the list that is passed in as the second argument is modified. 
However, if we call the function with one argument, the default value is 
modified. 

Consider the following sequence of calls. First, we define a list and pass it 
in each time as the second argument. This list accumulates the first arguments, 
as follows: 


myList=[]
print(f(0, myList))
print(f(1, myList))

This will print: 

[0]
[0, 1]

As you can see, myList is being used to accumulate the values passed in to the 
first as the first argument.
 
If we then use the default value by passing in only one argument, as follows:

print(f(2))
print(f(3))

we will see: 

[2]
[2, 3]

Here, the two invocations appended values to to the default list. 

Let's continue, this time going back to myList:

print(f(4,myList))

Now the result will be:

[0, 1, 4]

because myList still contains the earlier values.

The default value still has its earlier values too, as we can see here:

print(f(5))

[2, 3, 5]

To summarize, there are two distinct cases: 

1) When the function is invoked with an argument list that includes a value for 
L, that L (the one being passed in) is changed by the function. 

2) When the function is invoked with an argument list that does not include a 
value for L, the default value for L is changed, and that change persists 
through future invocations. 
-

I hope this is useful. I realize it is much longer than the original. I had 
hoped to make it shorter, but when I did I found I was glossing over important 
details.

--
assignee: docs@python
components: Documentation
messages: 264135
nosy: 

[issue12305] Building PEPs doesn't work on Python 3

2016-04-24 Thread Berker Peksag

Berker Peksag added the comment:

peps repo is now Python 3 compatible. Related commits:

* https://github.com/python/peps/commit/88f9f6da5d51a36d0f6a1bb833a6e8c85763c7d2
* https://github.com/python/peps/commit/3e5cad857053e0c15b2621dae728f32b4099c1a5

--
nosy: +berker.peksag
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
type: compile error -> behavior

___
Python tracker 

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



[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch that adds fast checks before calling _PyArg_NoKeywords().

Other option is redefine _PyArg_NoKeywords as a macro:

#define _PyArg_NoKeywords(name, kw)  ((kw) != NULL && _PyArg_NoKeywords((name), 
(kw)))

This will affect all usages of _PyArg_NoKeywords.

--
Added file: 
http://bugs.python.org/file42583/operator_getters_kwargs_speedup.patch

___
Python tracker 

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



[issue26249] Change PyMem_Malloc to use pymalloc allocator

2016-04-24 Thread STINNER Victor

STINNER Victor added the comment:

I documented the change, buildbots are happy, I close the issue.

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

___
Python tracker 

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



[issue26840] Hidden test in test_heapq

2016-04-24 Thread Berker Peksag

Berker Peksag added the comment:

This is a duplicate of issue 19119.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> duplicate test name in Lib/test/test_heapq.py

___
Python tracker 

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



[issue26841] Hidden test in ctypes tests

2016-04-24 Thread Berker Peksag

Berker Peksag added the comment:

This is a duplicate of issue 19113.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> duplicate test names in Lib/ctypes/test/test_functions.py

___
Python tracker 

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



[issue26249] Change PyMem_Malloc to use pymalloc allocator

2016-04-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7acad5d8f80e by Victor Stinner in branch 'default':
Issue #26249: Mention PyMem_Malloc() change in What's New in Python 3.6 in the
https://hg.python.org/cpython/rev/7acad5d8f80e

--

___
Python tracker 

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



[issue26698] Tk DPI awareness

2016-04-24 Thread Westley Martínez

Westley Martínez added the comment:

IDLE 3.5.1 on Windows 10

--

___
Python tracker 

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



[issue26841] Hidden test in ctypes tests

2016-04-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

There are two methods named "test_errors" in FunctionTestCase in 
Lib/ctypes/test/test_functions.py. The latter hides the former.

--
components: Tests
messages: 264127
nosy: amaury.forgeotdarc, belopolsky, meador.inge, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Hidden test in ctypes tests
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

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



[issue26839] python always calls getrandom() at start, causing long hang after boot

2016-04-24 Thread STINNER Victor

STINNER Victor added the comment:

Python 3 uses os.urandom() at startup to randomize the hash function. 
os.urandom() now uses the new Linux getrandom() function which blocks until the 
Linux kernel is feeded with enough entropy. It's a deliberate choice.

The workaround is simple: set the PYTHONHASHSEED environment variable to use a 
fixed seed. For example, PYTHONHASHSEED=0 disables hash randomization.

If you use virtualization and Linux is not feeded with enough entropy, you have 
security issues.

> I just debugged the adt-virt-qemu failure (...)

If you use qemu, you can use virt-rng to provide good entropy to the VM from 
the host kernel.

--

___
Python tracker 

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



[issue26822] itemgetter/attrgetter/methodcaller objects ignore keyword arguments

2016-04-24 Thread Raymond Hettinger

Raymond Hettinger added the comment:

In general there should be an early out test for keywords==NULL before calling 
the comparatively high overhead function _PyArg_NoKeywords.  

That function adds overhead everywhere it is used and provides zero benefit to 
correct programs in order to provide earlier detection of a very rare class of 
errors.

Some care needs to be taken before slapping _PyArg_NoKeywords onto every 
function in the core that doesn't use keyword arguments.

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

___
Python tracker 

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



[issue26800] Don't accept bytearray as filenames part 2

2016-04-24 Thread STINNER Victor

STINNER Victor added the comment:

I'm really sceptical that anyone really use bytearray for filenames in Python. 
I'm quite sure that most functions fail with bytearray. Do you have an example 
of application using bytearray? What's the point of using bytearray? To limit 
memory copy and optimize the memory usage?

The two most common functions for filenames are os.path.join() and open(). I 
just tried:

>>> os.path.join(bytearray(b"a"), b"b")
Traceback (most recent call last):
  ...
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

>>> open(bytearray(b"/etc/issue"))
Traceback (most recent call last):
  ...
TypeError: invalid file: bytearray(b'/etc/issue')

Hum, so bytearray are not accepted for open() nor os.path.join(), right?

--

___
Python tracker 

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



[issue26840] Hidden test in test_heapq

2016-04-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

There are two methods test_get_only in TestErrorHandling in test_heapq. The 
latter hides the former.

There is only one test_get_only in 2.7.

--
assignee: rhettinger
components: Tests
messages: 264123
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Hidden test in test_heapq
type: behavior
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue26839] python always calls getrandom() at start, causing long hang after boot

2016-04-24 Thread Matthias Klose

Matthias Klose added the comment:

other issues fixed between these dates:

- Issue #26659: Make the builtin slice type support cycle collection.
- Issue #26718: super.__init__ no longer leaks memory if called multiple
  times.  NOTE: A direct call of super.__init__ is not endorsed!
- Issue #25339: PYTHONIOENCODING now has priority over locale in setting
  the error handler for stdin and stdout.
- Issue #26717: Stop encoding Latin-1-ized WSGI paths with UTF-8.
- Issue #26735: Fix :func:`os.urandom` on Solaris 11.3 and newer when
  reading more than 1,024 bytes: call ``getrandom()`` multiple times with
  a limit of 1024 bytes per call.
- Issue #16329: Add .webm to mimetypes.types_map.
- Issue #13952: Add .csv to mimetypes.types_map.
- Issue #26709: Fixed Y2038 problem in loading binary PLists.
- Issue #23735: Handle terminal resizing with Readline 6.3+ by installing
  our own SIGWINCH handler.
- Issue #26586: In http.server, respond with "413 Request header fields too
  large" if there are too many header fields to parse, rather than killing
  the connection and raising an unhandled exception.
- Issue #22854: Change BufferedReader.writable() and
  BufferedWriter.readable() to always return False.
- Issue #6953: Rework the Readline module documentation to group related
  functions together, and add more details such as what underlying Readline
  functions and variables are accessed.

--

___
Python tracker 

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



[issue26839] python always calls getrandom() at start, causing long hang after boot

2016-04-24 Thread Matthias Klose

New submission from Matthias Klose:

[forwarded from https://bugs.debian.org/822431]

This regression / change of behaviour was seen between 20160330 and 20160417 on 
the 3.5 branch. The only check-in which could affect this is the fix for issue 
#26735.

3.5.1-11 = 20160330
3.5.1-12 = 20160417

Martin writes:
"""
I just debugged the adt-virt-qemu failure with python 3.5.1-11 and
tracked it down to python3.5 hanging for a long time when it gets
called before the kernel initializes its RNG (which can take a minute
in VMs which have low entropy sources).

With 3.5.1-10:

  $ strace -e getrandom python3 -c 'True'
  +++ exited with 0 +++

With -11:
  $ strace -e getrandom python3 -c 'True'
  
getrandom("\300\0209\26\232\264\325\217\322\303:]\30\212Q\314\244\257t%\206\"",
 24, 0) = 24
  +++ exited with 0 +++

When you do this with -11 right after booting a VM, the getrandom()
can block for a long time, until the kernel initializes its random
pool:

   11:21:36.118034 
getrandom("/V#\200^O*HD+D_\32\345\223M\205a\336/\36x\335\246", 24, 0) = 24
   11:21:57.93 ioctl(0, TCGETS, 0x7ffde1d152a0) = -1 ENOTTY (Inappropriate 
ioctl for device)

   [1.549882] [TTM] Initializing DMA pool allocator
   [   39.586483] random: nonblocking pool is initialized

(Note the time stamps in the strace in the first paragraph)

This is really unfriendly -- it essentially means that you stop being
able to use python3 early in the boot process or even early after
booting. It would be better to initialize that random stuff lazily,
until/if things actually need it.

In the diff between -10 and -11 I do seem some getrandom() fixes to
supply the correct buffer size (but that should be irrelevant as in
-10 getrandom() wasn't called in the first place), and a new call
which should apply to Solaris only (#ifdef sun), so it's not entirely
clear where that comes from or how to work around it.

It's very likely that this is the same cause as for #821877, but the
description of that is both completely different and also very vague,
so I file this separately for now.
"""

--
components: Interpreter Core
messages: 264121
nosy: doko, haypo
priority: normal
severity: normal
status: open
title: python always calls getrandom() at start, causing long hang after boot
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue23277] Cleanup unused and duplicate imports in tests

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thanks Berker.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> enhancement

___
Python tracker 

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



[issue23277] Cleanup unused and duplicate imports in tests

2016-04-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fa44d1bc9b68 by Serhiy Storchaka in branch 'default':
Issue #23277: Remove unused imports in tests.
https://hg.python.org/cpython/rev/fa44d1bc9b68

--

___
Python tracker 

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



[issue26800] Don't accept bytearray as filenames part 2

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The os.path module and os.fsdecode() don't support bytearray paths. Should we 
add bytearray support? This will complicate and slowdown os.path functions 
which often are used multiple times in tight loops.

Correspondingly, many Python implemented functions in the os module, such as 
makedirs() or walk(), doesn't support bytearray paths.

In 3.2 almost all functions used PyUnicode_FSConverter() and supported only str 
and bytes paths. Few functions accidentally supported other types (on Windows 
only!): chdir(), rmdir() and unlink() supported read-only buffers (i.e. 
bytearray was not supported), and rename() and symplink() supported any 
buffers, including bytearray. Now all these functions emit a warning since 
non-string paths are deprecated on Windows. It looks to me that the support of 
non-bytes paths was added by accident.

--

___
Python tracker 

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



[issue26739] idle: Errno 10035 a non-blocking socket operation could not be completed immediately

2016-04-24 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Kristján, thank you for the response.  The socket communication part of IDLE is 
pretty much a black box to me.  Just to clarify, you are saying that select 
polling is only needed for non-blocking sockets; sockets are blocking by 
default; and you see no override of the default.  Me neither.  It would be nice 
to know.  Idlelib.PyShell has the following lines: 
<445>self.rpcclt.listening_sock.settimeout(10)
<561>response = clt.pollresponse(self.active_seq, wait=0.05)
The wait is ultimately passed to rpc.py, line 353:
r, w, x = select.select([self.sock.fileno()], [], [], wait)

(IDLE is very much in use, and I hope to modernize the 3.x version, and perhaps 
replace the sockets with non-blocking use of pipes.)

Michael: I cannot change 2.7.5 and I am not inclined to change 2.7.12+ until I 
know there is a problem with the current 2.7 release.  Numerous people are 
using IDLE with 2.7.11 (and 3.x) on Windows without problems.

--

___
Python tracker 

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



[issue23277] Cleanup unused and duplicate imports in tests

2016-04-24 Thread Berker Peksag

Berker Peksag added the comment:

LGTM

--

___
Python tracker 

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



[issue26804] Prioritize lowercase proxy variables in urllib.request

2016-04-24 Thread Hans-Peter Jansen

Hans-Peter Jansen added the comment:

> In Python 2, it looks like the proxy_bypass_etc() functions are defined
> in urllib and imported into urllib2, so it makes sense to include the
> tests in test_urllib rather than test_urllib2.

The tests are in test_urllib. test_urllib2 is testing proxy behaviour on a 
higher level, so I think, they're in the correct module, aren't they?

--

___
Python tracker 

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



[issue26804] Prioritize lowercase proxy variables in urllib.request

2016-04-24 Thread Hans-Peter Jansen

Hans-Peter Jansen added the comment:

* blatant error fixed
* one test case added

--
Added file: 
http://bugs.python.org/file42582/python-urllib-prefer-lowercase-proxies-v6.diff

___
Python tracker 

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



[issue26800] Don't accept bytearray as filenames part 2

2016-04-24 Thread Guido van Rossum

Guido van Rossum added the comment:

OK, I actually agree with you on memoryview and and other types that support 
the buffer view. I will update PEP 484 to exclude memoryview. But I think 
bytearray has a special role and purose, and as much as possible it needs to be 
accepted in places that support bytes. So IMO as long as the os module supports 
bytes at all, I see no reason not to support bytearray. (It even has the extra 
trailing \0 needed to pass it to a typical C function.)

So as long as we support bytes (and on Linux, and probably some other Unixoid 
systems, bytes are the *correct* type for paths) we should also support 
bytearray.

The issue that Path doesn't support bytes is separate. I think it's the right 
choice. But that doesn't mean e.g. os.listdir() shouldn't support bytes.

--

___
Python tracker 

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



[issue26838] sax.xmlreader.InputSource.setCharacterStream() does not work?

2016-04-24 Thread Alan Jenkins

Alan Jenkins added the comment:

Looks like this is documented elsewhere and fixed in 3.5.

https://fossies.org/diffs/Python/3.4.3_vs_3.5.0/Doc/library/xml.sax.reader.rst-diff.html

--
status: open -> closed

___
Python tracker 

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



[issue26838] sax.xmlreader.InputSource.setCharacterStream() does not work?

2016-04-24 Thread Alan Jenkins

New submission from Alan Jenkins:

python3-3.4.3-5.fc23-x86_64

So far I spelunked here.  Starting from 
.  I experimented with using 
setCharacterStream() instead of setByteStream()

setCharacterStream() is shown in documentation but exercising it fails

>>> help(InputSource)
 |  setCharacterStream(self, charfile)
 |  Set the character stream for this input source. (The stream
 |  must be a Python 2.0 Unicode-wrapped file-like that performs
 |  conversion to Unicode strings.)
 |  
 |  If there is a character stream specified, the SAX parser will
 |  ignore any byte stream and will not attempt to open a URI
 |  connection to the system identifier.

Actually using an InputSource set up this way errors out as follows:

  File 
"/home/alan/.local/lib/python3.4/site-packages/feedparser-5.2.1-py3.4.egg/feedparser/api.py",
 line 236, in parse
  File "/usr/lib64/python3.4/site-packages/drv_libxml2.py", line 146, in parse
source = saxutils.prepare_input_source(source)
  File "/usr/lib64/python3.4/xml/sax/saxutils.py", line 355, in 
prepare_input_source
sysidfilename = os.path.join(basehead, sysid)
  File "/usr/lib64/python3.4/posixpath.py", line 79, in join
if b.startswith(sep):
AttributeError: 'NoneType' object has no attribute 'startswith'

because the character stream is not actually used:

def prepare_input_source(source, base=""):
"""This function takes an InputSource and an optional base URL and
returns a fully resolved InputSource object ready for reading."""

if isinstance(source, str):
source = xmlreader.InputSource(source)
elif hasattr(source, "read"):
f = source
source = xmlreader.InputSource()
source.setByteStream(f)
if hasattr(f, "name") and isinstance(f.name, str):
source.setSystemId(f.name)

if source.getByteStream() is None:
sysid = source.getSystemId()
basehead = os.path.dirname(os.path.normpath(base))
sysidfilename = os.path.join(basehead, sysid)

--
components: XML
messages: 264111
nosy: sourcejedi
priority: normal
severity: normal
status: open
title: sax.xmlreader.InputSource.setCharacterStream() does not work?
versions: Python 3.4

___
Python tracker 

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



[issue26837] assertSequenceEqual() raises BytesWarning when format message

2016-04-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

assertSequenceEqual() raises BytesWarning when format failure report. See for 
example 
http://buildbot.python.org/all/builders/AMD64%20OpenIndiana%203.x/builds/10575/steps/test/logs/stdio
 :

==
ERROR: test_close_fds_0_1 (test.test_subprocess.POSIXProcessTestCase)
--
Traceback (most recent call last):
  File 
"/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_subprocess.py",
 line 1741, in test_close_fds_0_1
self.check_close_std_fds([0, 1])
  File 
"/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_subprocess.py",
 line 1727, in check_close_std_fds
self.assertEqual((out, err), (b'apple', b'orange'))
  File 
"/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py",
 line 820, in assertEqual
assertion_func(first, second, msg=msg)
  File 
"/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py",
 line 1029, in assertTupleEqual
self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
  File 
"/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/unittest/case.py",
 line 967, in assertSequenceEqual
(i, item1, item2))
BytesWarning: str() on a bytes instance

==

Proposed patch fixes message formatting and adds tests for assertions that can 
emit BytesWarning.

--
components: Library (Lib), Tests
files: unittest_assert_bytes_warning.patch
keywords: patch
messages: 264110
nosy: ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
priority: normal
severity: normal
status: open
title: assertSequenceEqual() raises BytesWarning when format message
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42581/unittest_assert_bytes_warning.patch

___
Python tracker 

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



[issue26836] Add memfd_create to os module

2016-04-24 Thread Christian Heimes

New submission from Christian Heimes:

Add memfd_create() and constants MFD_ALLOW_SEALING, MFD_CLOEXEC to the os 
module. A glibc wrapper for memfd_create() is not available yet but the 
interface has been standardized.

http://man7.org/linux/man-pages/man2/memfd_create.2.html
https://dvdhrm.wordpress.com/tag/memfd/

--
assignee: christian.heimes
components: Extension Modules
messages: 264109
nosy: christian.heimes
priority: normal
severity: normal
stage: needs patch
status: open
title: Add memfd_create to os module
type: enhancement
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



[issue26835] Add file-sealing ops to fcntl

2016-04-24 Thread Christian Heimes

New submission from Christian Heimes:

The file-sealing ops are useful for memfd_create(). The new syscall and ops are 
only available on Linux with a recent kernel.

http://man7.org/linux/man-pages/man2/fcntl.2.html
http://man7.org/linux/man-pages/man2/memfd_create.2.html

Code:

#include 

#ifndef F_ADD_SEALS

/*
 * Set/Get seals
 */
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)

/*
 * Types of seals
 */
#define F_SEAL_SEAL 0x0001  /* prevent further seals from being set */
#define F_SEAL_SHRINK   0x0002  /* prevent file from shrinking */
#define F_SEAL_GROW 0x0004  /* prevent file from growing */
#define F_SEAL_WRITE0x0008  /* prevent writes */
/* (1U << 31) is reserved for signed error codes */

#endif /* F_ADD_SEALS */

--
assignee: christian.heimes
components: Extension Modules
messages: 264108
nosy: christian.heimes
priority: normal
severity: normal
stage: needs patch
status: open
title: Add file-sealing ops to fcntl
type: enhancement
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



[issue23277] Cleanup unused and duplicate imports in tests

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is the patch that contains the rest of changes, after resolving conflicts 
and fixing some errors. I have reviewed and tested these changes and they LGTM. 
I think it is worth to push them.

--
resolution: fixed -> 
status: closed -> open
Added file: http://bugs.python.org/file42580/cleanup-unused-imports_2.patch

___
Python tracker 

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



[issue23277] Cleanup unused and duplicate imports in tests

2016-04-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9d7f2615f7b3 by Serhiy Storchaka in branch 'default':
Issue #23277: Remove more unused sys and os imports.
https://hg.python.org/cpython/rev/9d7f2615f7b3

New changeset abf3f0dcf2fd by Serhiy Storchaka in branch 'default':
Issue #23277: Remove unused support.run_unittest import.
https://hg.python.org/cpython/rev/abf3f0dcf2fd

--

___
Python tracker 

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



[issue26739] idle: Errno 10035 a non-blocking socket operation could not be completed immediately

2016-04-24 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Caveat emptor:  I know nothing of IDLE, and I even suspect it to be dead or 
dying code.  Non the less, it could be patched.

I found this in the code:
def putmessage(self, message):
self.debug("putmessage:%d:" % message[0])
try:
s = pickle.dumps(message)
except pickle.PicklingError:
print >>sys.__stderr__, "Cannot pickle:", repr(message)
raise
s = struct.pack(" 0:
try:
r, w, x = select.select([], [self.sock], [])
n = self.sock.send(s[:BUFSIZE])
except (AttributeError, TypeError):
raise IOError, "socket no longer exists"
except socket.error:
raise
else:
s = s[n:]


If the socket were non-blocking, this would be the place to add a handler to 
catch socket.error with errno=errno.EWOULDBLOCK

However, I can't see that this socket is non-blocking.  Perhaps I have some 
blindness, but the select calls seem to be redundant to me, I can't see any 
sock.setblocking(False) or sock.settimeout(0.0) being done anywhere.


Having said that, the following change can be made (which is the prudent way to 
use select/send anyway)
while len(s) > 0:
try:
while True:
r, w, x = select.select([], [self.sock], [])
try:
n = self.sock.send(s[:BUFSIZE])
break
except socket.error as e:
import errno # should be done at the top
if e.errno != errno.EWOULDBLOCK:
raise
except (AttributeError, TypeError):
raise IOError, "socket no longer exists"
except socket.error:
raise
else:
s = s[n:]

--

___
Python tracker 

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



[issue20572] subprocess.Popen.wait() undocumented "endtime" parameter

2016-04-24 Thread Daryl Luna

Changes by Daryl Luna :


--
nosy: +Daryl Luna
status: pending -> open
Added file: http://bugs.python.org/file42579/downloadfile.htm

___
Python tracker 

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



[issue26739] idle: Errno 10035 a non-blocking socket operation could not be completed immediately

2016-04-24 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Hi there.
I don't think this is in relation to issue #9090.
That one had to do with the internal mechanisms of doing blocking IO with 
timeout.  this is done internally by using non-blocking sockets and select(), 
and the backport dealt with some edge cases on windows where select() could 
falsely indicate that data were ready.

>From what I can see in this error description, we are dealing with real 
>non-blocking IO, i.e. an application is using select and non-blocking sockets.

It is possible that this windows edge case is now being elevated into the 
application code and whatever select() logic being used in rpc.py needs to be 
aware of it, or that for some reason this socket is supposed to be blocking, 
but isn't.

I'll have a quick look at idlelib and see if I can see anything.

--

___
Python tracker 

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



[issue23277] Cleanup unused and duplicate imports in tests

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Note that setUpModule is correctly imported in 
Lib/tkinter/test/test_tkinter/test_widgets.py.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue26814] [WIP] Add a new _PyObject_FastCall() function which avoids the creation of a tuple or dict for arguments

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think you can simplify the patch by dropping keyword arguments support from 
fastcall. Then you can decrease _PyStack_SIZE to 4 (larger size will serve only 
1.7% of calls), and may be refactor a code since an array of 4 pointers 
consumes less C stack than an array of 10 pointers.

--

___
Python tracker 

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



[issue26814] [WIP] Add a new _PyObject_FastCall() function which avoids the creation of a tuple or dict for arguments

2016-04-24 Thread STINNER Victor

STINNER Victor added the comment:

> Thus I think we need to optimize only cases of calling with small number 
> (0-3) of positional arguments.

My code is optimized to up to 10 positional arguments: with 0..10 arguments, 
the C stack is used to hold the array of PyObject*. For more arguments, an 
array is allocated in the heap memory.

+   /* 10 positional parameters or 5 (key, value) pairs for keyword parameters.
+  40 bytes on 32-bit or 80 bytes on 64-bit. */
+#  define _PyStack_SIZE 10

For keyword parameters, I don't know yet what is the best API (fatest API). 
Right now, I'm also using the same PyObject** array for positional and keyword 
arguments using "int nk", but maybe a dictionary is faster to combinary keyword 
arguments and to parse keyword arguments.

--

___
Python tracker 

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



[issue26801] Fix shutil.get_terminal_size() to catch AttributeError

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Martin, your comment is helpful.

--
resolution:  -> fixed
stage: patch review -> 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



[issue26801] Fix shutil.get_terminal_size() to catch AttributeError

2016-04-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset df8652452d25 by Serhiy Storchaka in branch '3.5':
Issue #26801: shutil.get_terminal_size() now handles the case of stdout is
https://hg.python.org/cpython/rev/df8652452d25

New changeset d6e6dcef674f by Serhiy Storchaka in branch 'default':
Issue #26801: shutil.get_terminal_size() now handles the case of stdout is
https://hg.python.org/cpython/rev/d6e6dcef674f

--

___
Python tracker 

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



[issue26814] [WIP] Add a new _PyObject_FastCall() function which avoids the creation of a tuple or dict for arguments

2016-04-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I have collected statistics about using CALL_FUNCTION* opcodes in compliled 
code during running CPython testsuite. According to it, 99.4% emitted opcodes 
is the CALL_FUNCTION opcode, and 89% of emitted CALL_FUNCTION opcodes have only 
positional arguments, and 98% of them have not more than 3 arguments.

That was about calls from Python code. All convenient C API functions (like 
PyObject_CallFunction and PyObject_CallFunctionObjArgs) used for direct calling 
in C code use only positional arguments.

Thus I think we need to optimize only cases of calling with small number (0-3) 
of positional arguments.

--

___
Python tracker 

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



[issue26801] Fix shutil.get_terminal_size() to catch AttributeError

2016-04-24 Thread STINNER Victor

STINNER Victor added the comment:

Martin's comment is helpful and LGTM.

--

___
Python tracker 

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



[issue24911] Context manager of socket.socket is not documented

2016-04-24 Thread Martin Panter

Changes by Martin Panter :


--
resolution:  -> fixed
stage: commit review -> 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



[issue26801] Fix shutil.get_terminal_size() to catch AttributeError

2016-04-24 Thread Martin Panter

Martin Panter added the comment:

How about:

try:
size = os.get_terminal_size(sys.__stdout__.fileno())
except (AttributeError, ValueError, OSError):
# stdout is None, closed, detached, or not a terminal, or
# os.get_terminal_size() is unsupported
size = os.terminal_size(fallback)

--

___
Python tracker 

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