[issue25480] string format in large number

2015-10-26 Thread tryme

New submission from tryme:

I am new to python and I don't know if it really is a bug. But indeed when I 
see sth is not right it is worthwhile to point out.

Using fresh installed ubuntu desktop with build in python3.
typing the command line by line in terminal just for learning. below is the 
scene
it has automatically round down. Don't know if it is limit of float.


$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> "hello{0:5.2f}".format(100.234)
'hello100.23'
>>> "hello{0:5.2f}".format(417.234)
'hello468.00'
>>> "hello{0:5.2f}".format(100.234)
'hello100.00'

--
components: Build
messages: 253459
nosy: tryme
priority: normal
severity: normal
status: open
title: string format in large number
type: behavior
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



[issue25476] close() behavior on non-blocking BufferedIO objects with sockets

2015-10-26 Thread eryksun

eryksun added the comment:

I meant that you need a check in buffered_close such as the following:

if (res == NULL) {
if (PyErr_ExceptionMatches(PyExc_BlockingIOError))
goto end;
PyErr_Fetch(, , );
} else
Py_DECREF(res);

For 2.7 you could create a function similar to _PyIO_trap_eintr, but trap the 
errors that Python 3 maps to BlockingIOError: EAGAIN/EWOULDBLOCK, EALREADY, and 
EINPROGRESS.

--

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Ezio Melotti

Ezio Melotti added the comment:

Thanks for the report and the patch.

I think a better way to handle this would be to add a "tag" next to the 
function name for both deprecations and "new in", and leave the actual 
deprecation/new-in notes at the bottom, something like:

funcname(args)  [new in 3.2] [deprecated in 3.5]
  Func description here.

  New in 3.2: the funcname() function was added.
  Deprecated in 3.5: funcname() has been deprecated.  Use anotherfunc() instead.

I've seen other docs doing it, however I'm not sure how easy it would be to 
implement something similar for Sphinx (maybe it's necessary to redefine the 
func/meth/class roles).

--
nosy: +eric.araujo, ezio.melotti, georg.brandl

___
Python tracker 

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



[issue25479] Increase unit test coverage for abc.py

2015-10-26 Thread Szymon Trapp

New submission from Szymon Trapp:

Added a new function to unit tests for abc.py to increase the test coverage, 
specifically for the usage of __subclasshook__.

This will cover lines 209-214.

Note: this is my first submission to Python and I'm following the advice to 
start with the unit tests coverage.

--
components: Tests
files: mywork.patch
keywords: patch
messages: 253453
nosy: szymon
priority: normal
severity: normal
status: open
title: Increase unit test coverage for abc.py
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file40860/mywork.patch

___
Python tracker 

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



[issue25466] offer "from __future__ import" option for "raise... from"

2015-10-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Except for *very* carefully considered security features for 2.7, we do not add 
new features to python x.y after initial release.  The 2.7 security exception 
required a PEP, and I believe the PEP was limited to features specified in the 
PEP.

I would expect porting guides (or 2 & 3 guides) to cover this issue.

Features added in 3.0 were considered for backporting to 2.7, which came out 18 
months later.  This one did not make the cut.

--
nosy: +terry.reedy
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue25478] Consider adding a normalize() method to collections.Counter()

2015-10-26 Thread Raymond Hettinger

New submission from Raymond Hettinger:

Allen Downey suggested this at PyCon in Montreal and said it would be useful in 
his bayesian statistics courses.  Separately, Peter Norvig created a 
normalize() function in his probablity tutorial at In[45] in 
http://nbviewer.ipython.org/url/norvig.com/ipython/Probability.ipynb .

I'm creating this tracker item to record thoughts about the idea.  Right now, 
it isn't clear whether Counter is the right place to support this operation, 
how it should be designed, whether to use an in-place operation or an operation 
that creates a new counter, should it have rounding to make the result exactly 
equal to 1.0, should it use math.fsum() for float inputs?

Should it support other target totals besides 1.0?

  >>> Counter(red=11, green=5, blue=4).normalize(100) # percentage
  Counter(red=55, green=25, blue=20)

Also would it make sense to support something like this?

  sampled_gender_dist = Counter(male=405, female=421)
  world_gender_dist = Counter(male=0.51, female=0.50)
  cs = world_gender_dist.chi_squared(observed=sampled_gender_dist)

Would it be better to just have a general multiply-by-scalar operation for 
scaling?

  c = Counter(observations)
  c.scale_by(1.0 / sum(c.values())

Perhaps use an operator?

  c /= sum(c.values())

--
assignee: rhettinger
components: Library (Lib)
messages: 253452
nosy: rhettinger
priority: low
severity: normal
status: open
title: Consider adding a normalize() method to collections.Counter()
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



[issue25444] Py Launch Icon

2015-10-26 Thread Nils Lindemann

Nils Lindemann added the comment:

it seems i have still not explained my issue in an understandable way: the 
three first icons in the file list in the screenshot, aka the icons which are 
used in eg py 3.2, these icons are cool.

the icon i do not like, is the launcher icon which is used in eg py 3.5 and 
which shows up in the windows task bar when i run python scripts which open a 
commandline. This is the last icon in the file list in the screenshot.

Im fine with everything else, i always liked the original icons, just the new 
launcher icon is terrible in my opinion :-(

--

___
Python tracker 

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



[issue25311] Add f-string support to tokenize.py

2015-10-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 21f6c4378846 by Eric V. Smith in branch 'default':
Issue 25311: Add support for f-strings to tokenize.py. Also added some comments 
to explain what's happening, since it's not so obvious.
https://hg.python.org/cpython/rev/21f6c4378846

--
nosy: +python-dev

___
Python tracker 

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



[issue25482] signal.set_wakeup_fd() doesn't work if the signal don't have handler

2015-10-26 Thread Atsuo Ishimoto

New submission from Atsuo Ishimoto:

I expect following code prints '\x1c' when I resize terminal window on 
Linix/Mac terminal.


import select, os, signal

rfd, wfd = os.pipe()
os.set_blocking(wfd, False)

signal.set_wakeup_fd(wfd)
select.select([rfd], [], [])
print(os.read(rfd, 2))


Resizing terminal window make SIGWINCH signal sent to Python process. But 
nothing written to fd I specified to set_wakeup_fd().

I checked Modules/signalmodule.c and found I should assign signal handler for 
the signal I want to wakeup fd. So following code works as I expected.


import select, os, signal

rfd, wfd = os.pipe()
os.set_blocking(wfd, False)

signal.set_wakeup_fd(wfd)

signal.signal(signal.SIGWINCH, lambda *args:0)
select.select([rfd], [], [])
print(os.read(rfd, 2))


Is this an expected behavior of signal.set_wakeup_fd()?

--
components: Library (Lib)
messages: 253468
nosy: ishimoto
priority: normal
severity: normal
status: open
title: signal.set_wakeup_fd() doesn't work if the signal don't have handler
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



[issue25193] itertools.accumulate should have an optional initializer argument

2015-10-26 Thread Raymond Hettinger

Raymond Hettinger added the comment:

To me prime sieve demos and puzzle problems aren't motivating use cases.  Also, 
the two examples in the single stack-exchange answer become awkward because 
they would also need a middle argument for the accumulation function:

Current:
  cs = accumulate(chain([11], cycle(wh11)))
  wheel = accumulate(chain([psq+x[i]], cycle(x[i+1:] + x[:i+1])))

Proposed:
  cs = accumulate(cycle(wh11), operator.add, 11)
  wheel = accumulate(cycle(x[i+1:] + x[:i+1]), operator.add, psq+x[i])

IMO both of the newer ones are wordier, don't read well, and are slower.  

After more thought, I've decided to stick with the original decision and 
decline the feature request.  There are other major languages that seem to do 
fine without the feature, the current approach works fine, my search for 
possible use cases shows that they are uncommon or contrived, and looking at 
the revised examples I just don't think that the newer code reads well.

--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue25476] close() behavior on non-blocking BufferedIO objects with sockets

2015-10-26 Thread eryksun

eryksun added the comment:

Per issue 16597, when an exception occurs in flush(), the file is closed 
anyway. You'd have to check the exception and only skip to the end for 
EWOULDBLOCK or EAGAIN. That way you're not introducing a regression for ENOSPC 
and other exceptions for which retrying will just repeatedly fail. 

I'm adding 2.7 to keep the io module consistent; however, socket.makefile in 
2.7 doesn't use the io module.

--
nosy: +eryksun
versions: +Python 2.7, Python 3.4, Python 3.6

___
Python tracker 

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



[issue25476] close() behavior on non-blocking BufferedIO objects with sockets

2015-10-26 Thread David Beazley

David Beazley added the comment:

Please don't make flush() close the file on a BlockingIOError.   That would be 
an unfortunate mistake and make it impossible to implement non-blocking I/O 
correctly with buffered I/O.

--

___
Python tracker 

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



[issue25154] Drop the pyvenv script

2015-10-26 Thread Eric V. Smith

Eric V. Smith added the comment:

There's a typo here in 'executable':

+  '`{} -m venv`'.format(exeutable), file=sys.stderr)

And this could now be:
print('WARNING: the pyenv script is deprecated in favour of '
  f'`{executable} -m venv`', file=sys.stderr)

!

And since there is no .format() call, you can't accidentally pass it file=.

--
nosy: +eric.smith
Added file: http://bugs.python.org/file40861/issue25154-1.diff

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread jaystrict

New submission from jaystrict:

When running subprocess.check_output(['doesnotexist']) as another user, I 
expect a FileNotFoundError, but a PermissionError is thrown.

How to reproduce:

[user1 tmp]$ su --login user2
Password: 
[user2 ~]$ python
Python 3.5.0 (default, Sep 20 2015, 11:28:25) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.check_output(['asdf'])
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/subprocess.py", line 629, in check_output
**kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1540, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'asdf'
>>> quit()
[user2 ~]$ exit
logout
[user1 tmp]$ su user2
Password: 
[user2 tmp]$ python
Python 3.5.0 (default, Sep 20 2015, 11:28:25) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.check_output(['asdf'])
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/subprocess.py", line 629, in check_output
**kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1540, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
>>> quit()
[user2 tmp]$

--
messages: 253462
nosy: jaystrict
priority: normal
severity: normal
status: open
title: PermissionError in subprocess.check_output() when running as a different 
user (not login shell)
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



[issue25480] string format in large number

2015-10-26 Thread Eric V. Smith

Eric V. Smith added the comment:

You should read: https://docs.python.org/3/tutorial/floatingpoint.html

--
components:  -Build
nosy: +eric.smith
resolution:  -> not a bug
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



[issue25300] Enable Intel MPX (Memory protection Extensions) feature

2015-10-26 Thread Florin Papa

Florin Papa added the comment:

Hi all,

I updated the patch after fixing crashes that occurred at compile and run time 
on Ubuntu 15.10, with kernel version 4.2.0-16-generic, LD version 2.25.1 and 
GCC version 5.2.1. The Python MPX binary will be built with –O0 because other 
optimization levels will change instruction order and cause crashes, making it 
useful for debugging purposes. The minimum GCC version was upgraded to 5.2 for 
the MPX build in order to make sure there is full support for this feature.

All tests from regrtest pass, except pest_pyclbr which also fails on a non-MPX 
build and two other tests, test_capi and test_faulthandler, which fail because 
the output expected after a segmentation fault is generated is modified by MPX 
(which reacts to a memory violation).

The built MPX Python binary was evaluated (“./python -m test.regrtest”) on two 
older Intel generation processors, Haswell and Broadwell, and no functional 
issue was observed.  However, we don’t know its impact on third-party 
extensions.

Thank you,
Florin

--
Added file: http://bugs.python.org/file40862/mpx_enable_3_6_v5.patch

___
Python tracker 

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



[issue25311] Add f-string support to tokenize.py

2015-10-26 Thread Eric V. Smith

Changes by Eric V. Smith :


--
keywords:  -patch
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



[issue25311] Add f-string support to tokenize.py

2015-10-26 Thread Eric V. Smith

Eric V. Smith added the comment:

I've fixed this particular problem, but the tokenize module definitely has some 
other issues. It recompiles regexes very often when it doesn't need to, it 
treats single- and triple-quoted strings differently (leading to some code 
bloat), etc. I may open another issue to address some of these problems.

And I'll be adding more tests. tokenize is still woefully under-tested.

--
resolution:  -> fixed

___
Python tracker 

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



[issue20519] Replace uuid ctypes usage with an extension module.

2015-10-26 Thread Gustavo J. A. M. Carneiro

Gustavo J. A. M. Carneiro added the comment:

One issue of note is regarding generate_time().  Originally I found ctypes 
bindings for this function, so I wrapped it as well in the extension module.  
However, it doesn't appear to be used...

--

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread feliep

feliep added the comment:

I think that the following part could replace the part of the other text that's 
between ###. It's more objective and easier to understand. 

classinfo may could be a tuple of type objects, or may contains others tuples 
that contains type objects (other sequence types are not accepted).

Return true if the object argument is an instance of the classinfo argument, or 
of a (direct, indirect or virtual) subclass thereof. If object is not an object 
of the given type, the function always returns false. ### If classinfo is not a 
class (type object), it may be a tuple of type objects, or may recursively 
contain other such tuples (other sequence types are not accepted). ### If 
classinfo is not a type or tuple of types and such tuples, a TypeError 
exception is raised.

What do you think?

--
nosy: +felipevolpone

___
Python tracker 

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



[issue20438] inspect: Deprecate getfullargspec?

2015-10-26 Thread Yury Selivanov

Yury Selivanov added the comment:

> This is the situation I am in: coverage.py uses getargspec in a very simple 
> way in its tooling.  I support 2.7 and 3.5, so I have to do this:

try:
getargspec = inspect.getfullargspec
except AttributeError:
getargspec = inspect.getargspec
argspec = getargspec(function)

I think it was me who submitted this code to coverage.py.. :)  It might be 
worthwhile to keep it anyways, as getfullargspec uses the signature API, which 
supports a wider range of callables.

--

___
Python tracker 

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



[issue20438] inspect: Deprecate getfullargspec?

2015-10-26 Thread Yury Selivanov

Yury Selivanov added the comment:

> The thing is, we've adopted a policy that if something exists in python2.7 we 
> shouldn't delete it in python3 until after 2.7 is officially out of 
> maintenance (at the earliest), in order to facilitate single-source porting 
> to python3.  That policy was adopted relatively recently, after the 
> deprecation warning mentioning 3.6 was added in this issue, as I recall it.

In this case we better resurrect getargspec().  Here's an issue for that: #25486

--
dependencies: +Resurrect inspect.getargspec() in 3.6

___
Python tracker 

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



[issue23749] asyncio missing wrap_socket (starttls)

2015-10-26 Thread Yury Selivanov

Yury Selivanov added the comment:

Guido, Victor,

Please find attached a first draft of the patch.  It's a very early attempt 
(i.e. I'm not including unit tests/docstrings), and its primary purpose is to 
gather initial feedback.

Some points:

1. As discussed earlier, the primary API point is new transports.TLSTransport 
class with a `start_tls(sslcontetx, *, server_side=False, 
server_hostname=None)` method.

2. While experimenting with the code and unit tests, I thought that it would be 
great if stream writers could do start_tls too, this patch has that too.  I 
like this new idea -- makes it so much simpler to write protocols.

--
keywords: +patch
Added file: http://bugs.python.org/file40866/tls1.patch

___
Python tracker 

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



[issue23749] asyncio missing wrap_socket (starttls)

2015-10-26 Thread Yury Selivanov

Yury Selivanov added the comment:

Here's an example client implementation with writer.start_tls() (taken from my 
debug code):

@asyncio.coroutine
def client(addr):
reader, writer = yield from asyncio.open_connection(
*addr, loop=loop)

print("CLIENT: ", (yield from reader.readexactly(4)))
writer.write(b'ehlo')
yield from writer.start_tls(sslctx)
# encrypted channel from this point
print("CLIENT: ", (yield from reader.readexactly(4)))

--

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Ezio Melotti

Ezio Melotti added the comment:

> I don't want to be distracted by "new in 3.1" tags when reading
> the 3.6 documentation.

This is true, but on the other hand you might want to see the [new in 3.4] 
while looking at 3.6 docs and working on a program that must support Python 
3.3+.  Anyway we can discuss this again once we have a patch -- depending on 
how it is implemented, it might be easy enough to include the tag only for 
functions added in the last 2 releases, or perhaps the tag won't be 
particularly distracting and can be used for all versions.

--
stage:  -> needs patch

___
Python tracker 

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



[issue25486] Resurrect inspect.getargspec() in 3.6

2015-10-26 Thread Yury Selivanov

New submission from Yury Selivanov:

See issue #20438 for more details

--
components: Library (Lib)
messages: 253499
nosy: yselivanov
priority: normal
severity: normal
stage: needs patch
status: open
title: Resurrect inspect.getargspec() in 3.6
type: behavior
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



[issue20519] Replace uuid ctypes usage with an extension module.

2015-10-26 Thread Gustavo J. A. M. Carneiro

Gustavo J. A. M. Carneiro added the comment:

This patch fixes the Mac OS X issue @haypo pointed out.

--
Added file: http://bugs.python.org/file40865/issue20519_10941v2.diff

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

The fact that nested tuples are accepted is just bizarre, IMO :(.

It could say something like "If classinfo is a (possibly nested) list of types, 
return True if any of the types match."

--

___
Python tracker 

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



[issue25486] Resurrect inspect.getargspec() in 3.6

2015-10-26 Thread Ned Batchelder

Changes by Ned Batchelder :


--
nosy: +nedbat

___
Python tracker 

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



[issue25154] Drop the pyvenv script

2015-10-26 Thread Brett Cannon

Brett Cannon added the comment:

Took Eric's advice in 8828d7847e92 as well as actually tested the results this 
time. :P

--
status: open -> closed

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread Felipe Volpone

Felipe Volpone added the comment:

r.david.murray: I liked your way.

--

___
Python tracker 

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



[issue23391] Documentation of EnvironmentError (OSError) arguments disappeared

2015-10-26 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cb554248ce54 by Martin Panter in branch '3.4':
Issue #23391: Restore OSError constructor argument documentation
https://hg.python.org/cpython/rev/cb554248ce54

New changeset 7b1a9a12eb77 by Martin Panter in branch '3.5':
Issue #23391: Merge OSError doc from 3.4 into 3.5
https://hg.python.org/cpython/rev/7b1a9a12eb77

New changeset e5df201c0846 by Martin Panter in branch 'default':
Issue #23391: Merge OSError doc from 3.5
https://hg.python.org/cpython/rev/e5df201c0846

--
nosy: +python-dev

___
Python tracker 

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

Sure, that's fine with me.  I was trying to minimize words, but clarity is good.

--

___
Python tracker 

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



[issue25487] imp module DeprecationWarning in test suite

2015-10-26 Thread Martin Panter

New submission from Martin Panter:

I typically run the test suite with the “python -bWall” options enabled, and 
there is a new warning. I suspect it is a result of the DeprecationWarning 
upgrade in revision 5877c191b76e. When -Werror is enabled it causes test 
failure.

The fix is probably pretty easy; there are probably other deprecated modules 
tested in the test suite to copy from. I think there is a test.support function 
that can suppress deprecation warnings while importing a particular module.

$ make -s -j2 && LC_TIME= ./python -bWall -m test.regrtest -j0
. . .
[167/399] test_imp
/media/disk/home/proj/python/cpython/Lib/test/test_imp.py:16: 
DeprecationWarning: the imp module is deprecated in favour of importlib; see 
the module's documentation for alternative uses
  import imp
. . .
[207/399] test_modulefinder -- running: test_lzma (39 sec)
/media/disk/home/proj/python/cpython/Lib/modulefinder.py:14: 
DeprecationWarning: the imp module is deprecated in favour of importlib; see 
the module's documentation for alternative uses
  import imp
. . .
[335/399] test_threaded_import -- running: test_tarfile (36 sec), 
test_subprocess (62 sec)
/media/disk/home/proj/python/cpython/Lib/modulefinder.py:14: 
DeprecationWarning: the imp module is deprecated in favour of importlib; see 
the module's documentation for alternative uses
  import imp

--
components: Tests
messages: 253509
nosy: brett.cannon, martin.panter
priority: normal
severity: normal
status: open
title: imp module DeprecationWarning in test suite
type: behavior
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



[issue23391] Documentation of EnvironmentError (OSError) arguments disappeared

2015-10-26 Thread Martin Panter

Martin Panter added the comment:

I will leave opening a bug for the args issue for someone else. But if you come 
up with a sensible solution or find out all the details, I am happy to help 
write up or review the documentation changes.

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



[issue25432] isinstance documentation: explain behavior when type is a tuple

2015-10-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

David, if you are suggesting that the initial negative clause of "If classinfo 
is not a class (type object)" is not needed, I agree.  If classinfo is a tuple, 
is is not a class.  'list of types' has to be 'tuple of types'. I think 'match' 
needs to be expanded to 'is an instance of'. How about

"If classinfo is a tuple of type objects (or recursively, other such tuples), 
return true if object is an instance of any of the types.

This leaves out the left to right ordering of the tests, but I think that is 
implied by how Python generally works.  Short circuiting certainly is.

--

___
Python tracker 

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



[issue25483] Improve f-string implementation: FORMAT_VALUE opcode

2015-10-26 Thread Eric V. Smith

Eric V. Smith added the comment:

This patch addresses Larry's review, plus bumps the bytecode magic number.

--

___
Python tracker 

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



[issue20519] Replace uuid ctypes usage with an extension module.

2015-10-26 Thread STINNER Victor

STINNER Victor added the comment:

New review (question for Windows).

--

___
Python tracker 

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



[issue25465] Pickle uses O(n) memory overhead

2015-10-26 Thread Martin Panter

Martin Panter added the comment:

Perhaps by OS crash you mean either the Linux out-of-memory (OOM) killer, that 
takes a hueristic stab at killing the right process, or Linux running almost 
out of memory, and everything grinding to a halt presumably because each task 
switch needs to re-read its program off the hard disk.

If either is the case, I understand this is part of Linux’s design, called 
“memory overcommit” or something. It is possible to disable it, though I 
haven’t tried myself, and many programs (probably including Python) are 
apparently not compatible.

--
nosy: +martin.panter

___
Python tracker 

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



[issue25482] signal.set_wakeup_fd() doesn't work if the signal don't have handler

2015-10-26 Thread Atsuo Ishimoto

Atsuo Ishimoto added the comment:

Okay, so I think this needed to be documented in signal.set_wakeup_fd(). 

IMO this reduces usefulness of set_wakeup_fd(). If I need to install custom 
handler by my self, I can write to fd in my own custom handler.

And,  installing custom handler omits existing handler, but we can not execute 
existing signal handler from python script. In my real-world case, SIGWINCH 
signal does not delivered to curses library. 

pep-475(https://www.python.org/dev/peps/pep-0475/#backward-compatibility) 
claims that 

"For applications using event loops, signal.set_wakeup_fd() is the 
recommanded option to handle signals. "

But I think side effect of signal.set_wakeup_fd() is lager than pep-475 authors 
expected.

--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python
resolution: not a bug -> 
status: closed -> open

___
Python tracker 

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



[issue25478] Consider adding a normalize() method to collections.Counter()

2015-10-26 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Counter is documented as being primarily intended for integer counts. While you 
can use them with floats, I'm not sure they're the right data type for this use 
case. Having some methods that only make sense with floats, and others (like 
elements) that only make sense with integers is just confusing.

--
nosy: +josh.r

___
Python tracker 

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



[issue25356] Idle (Python 3.4 on Ubuntu) does not allow typing accents

2015-10-26 Thread eryksun

eryksun added the comment:

This seems to be a problem with Tk 8.6 when using an international keyboard 
layout on Linux. I ran the following test.tcl script via wish:

text .t
pack .t

Initially dead keys work, but they stop working if I switch away from the text 
entry to another window and then back. Using the menu to save a file in IDLE 
has the same effect. I suggest opening a ticket at http://core.tcl.tk/tk.

--
nosy: +eryksun

___
Python tracker 

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



[issue16785] Document the fact that constructing OSError with erron returns subclass if possible

2015-10-26 Thread Martin Panter

Martin Panter added the comment:

Hopefully revision cb554248ce54 is good enough to close this. The documentation 
now says

'''
The constructor often actually returns a subclass of OSError, as described in 
“OS exceptions” below. The particular subclass depends on the final “errno” 
value. This behaviour only occurs when constructing OSError directly or via an 
alias, and is not inherited when subclassing.
'''

Serhiy’s first case does not set the “errno” attribute (by design I assume). In 
the second case, I suspect the behaviour has changed since 2012, or it depends 
on the platform. On Windows, the 'spam' argument is meant to become “winerror”, 
which can override “errno” if it is an integer. 3.6 on Linux:

>>> OSError(errno.ENOENT, 'error msg', 'filename', 'spam')
FileNotFoundError(2, 'error msg')

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



[issue25472] Typing: Specialized subclasses of generics cannot be unpickled

2015-10-26 Thread Guido van Rossum

Guido van Rossum added the comment:

FWIW the pickle produced looks like this, decoded with pickletools.dis():

0: \x80 PROTO  3
2: cGLOBAL '__main__ B'
   14: qBINPUT 0
   16: )EMPTY_TUPLE
   17: \x81 NEWOBJ
   18: qBINPUT 1
   20: }EMPTY_DICT
   21: qBINPUT 2
   23: XBINUNICODE 'x'
   29: qBINPUT 3
   31: XBINUNICODE 'hello'
   41: qBINPUT 4
   43: sSETITEM
   44: bBUILD
   45: .STOP

--

___
Python tracker 

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



[issue25472] Typing: Specialized subclasses of generics cannot be unpickled

2015-10-26 Thread Guido van Rossum

Guido van Rossum added the comment:

The issue seems to be the line

inst_dict = inst.__dict__


in _Unpickler.load_build().  (I found this out by forcing 
sys.modules['_pickle'] = None, so the pure-Python pickle.py code gets used.)

This leads to a simpler repro: 

# Use the same class definitions for A and B
b = B("hello")
print(b.__dict__)  # Same error message as before

That is, specialized subclasses of generics don't have a working __dict__ 
attribute!  Interestingly, A("hello").__dict__ works.

I have to ponder this more.

--

___
Python tracker 

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



[issue25482] signal.set_wakeup_fd() doesn't work if the signal don't have handler

2015-10-26 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Yes, you need to tell the kernel to not ignore SIGWINCH automatically for you.

--
nosy: +benjamin.peterson
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

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



[issue25439] Add type checks to urllib.request.Request

2015-10-26 Thread Martin Panter

Martin Panter added the comment:

There is already a check for request.data being str in do_request_(). Maybe it 
is okay to remove this check; I think it would be equivalent to the new check.

Regarding the dict check, here is a strange class that currently works, but 
would be broken by the patch. Maybe it is okay to break it though, since it 
certainly goes against the urlopen() documentation.

class ReaderMapping(dict):
def __init__(self):
super().__init__({"abc": "xyz"})
self.mode = "r"
self.data = "123"
def read(self, size):
data = self.data
self.data = ""
return data

urlopen(Request("http://localhost/;, headers={"Content-Length": 3}, 
data=ReaderMapping()))

If we wanted to continue to support this kind of usage, perhaps the safest 
option would be to change the test to “if type(data) is dict” rather than use 
isinstance().

I also left a comment about eliminating urlencode() in the test.

--
stage: needs patch -> patch review

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread jaystrict

jaystrict added the comment:

Narrowing it down further:

In $PATH there is a subdirectory of /home/user1.
PATH="/home/user1/bin:/usr/local/sbin:/usr/local/bin:/usr/bin"

Doing an strace on the example above shows the line
stat("/home/user1/bin/python", 0x7fff9d365bb0) = -1 EACCES (Permission denied)
AFAICT this line is generated when the shell looks for the correct python 
executable, but it should not interfere with the (later) call to 
subprocess.check_output().

If I delete "/home/user1/bin" from $PATH, then the correct FileNotFoundError is 
thrown.

So it seems (just guessing) that subprocess.check_output() somehow throws the 
older, obsolete error code. Would this be possible?

--

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

What do you mean by older obsolete error code?  It sounds like the problem is 
that user2 doesn't have read (or execute?) permission for that directory in the 
path.  I'd think it would just skip it in that case, though.  I don't have time 
to run tests myself right now...maybe you can take a look at what subprocess is 
actually doing when that error is generated?  (It might be in the C code, 
though, I don't remember).

--

___
Python tracker 

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



[issue20438] inspect: Deprecate getfullargspec?

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

The thing is, we've adopted a policy that if something exists in python2.7 we 
shouldn't delete it in python3 until after 2.7 is officially out of maintenance 
(at the earliest), in order to facilitate single-source porting to python3.  
That policy was adopted relatively recently, after the deprecation warning 
mentioning 3.6 was added in this issue, as I recall it.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue25465] Pickle uses O(n) memory overhead

2015-10-26 Thread Herbert

Herbert added the comment:

Hi Eric,

I would assume that for the right range-parameter (in my case 30 * 1000 ** 2), 
which just fits in memory, your system would also crash after a pickle.dump. 
That is, I had this behavior on two of my machine both running a Ubuntu setup 
though.

Nevertheless, if you give me some time I'm happy to check my dmesg and any log 
you wish. I find it strange that sometimes I get a MemoryError when I run out 
of memory (in particular when using numpy), and sometimes the system crashes 
(in particular when using other python-stuff). Therefore I don't think this is 
pickle-specific, or even if this is a bug instead of a 'feature'.

--

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Ezio Melotti

Ezio Melotti added the comment:

> I’m not sure I understand what you mean by “tag”.

>> funcname(args)  [new in 3.2] [deprecated in 3.5]
>>   Func description here.

I mean some kind of tag/label next to the name of the function in the 
documentation (red/orange for deprecations, green for new-in)  -- it's not a 
Sphinx-specific term.
I saw it in some other documentation but I can't find it anymore, however if 
you look at the [task] and [assigned] tags/labels at the top of 
https://twistedmatrix.com/trac/ticket/5000 you can get a pretty close idea of 
what I'm thinking about.

> Are you saying that the source documentation would remain as-is,
> but something during the Sphinx _transformation_ would generate
> the new/deprecated tags?  

That's the idea.  Ideally the func/meth/class directives [0] would add the 
tags/labels if they contain 
version-added/version-changed/deprecated/deprecated-remove directives.

[0]: directives look like ".. function:: foo(args)", whereas roles look like 
:func:`foo`.  Functions are defined using directives.  In the previous message 
I mistakenly said "roles".  See also 
https://docs.python.org/devguide/documenting.html#directives

--

___
Python tracker 

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



[issue20438] inspect: Deprecate getfullargspec?

2015-10-26 Thread Ned Batchelder

Ned Batchelder added the comment:

This is the situation I am in: coverage.py uses getargspec in a very simple way 
in its tooling.  I support 2.7 and 3.5, so I have to do this:

try:
getargspec = inspect.getfullargspec
except AttributeError:
getargspec = inspect.getargspec
argspec = getargspec(function)

It seems like needless churn.

--

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

It is almost certainly the case that the error message is correct.  The most 
likely explanation given your pasted session is that user2 does not have 
permission in the CWD.  When you use --login, the CWD changes to user2's home, 
which it of course has permission in.

--
nosy: +r.david.murray
status: open -> pending

___
Python tracker 

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



[issue25425] white-spaces encountered in 3.4

2015-10-26 Thread pavan kumar Dharmavarapu

pavan kumar Dharmavarapu added the comment:

Terry:

Thanks for you comments and  your help we will keep your mail as reference
, I will be posting regarding this in near future since we are developing
some of our applications.

On Mon, Oct 26, 2015 at 6:06 AM, Terry J. Reedy 
wrote:

>
> Terry J. Reedy added the comment:
>
> Pavan, if you want to followup, please post to python-list where you can
> get help explaining whatever you see as a problem.  If you get agreement
> there that a patch to CPython is needed, we can reopen this.
>
> --
> nosy: +terry.reedy
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
> type: performance ->
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Tony R.

Tony R. added the comment:

> Thanks for the report and the patch.

Thank you for the review!

> I think a better way to handle this would be to add a "tag" next to the 
> function name for both deprecations and "new in", and leave the actual 
> deprecation/new-in notes at the bottom, something like:
> 
> funcname(args)  [new in 3.2] [deprecated in 3.5]
>  Func description here.
> 
>  New in 3.2: the funcname() function was added.
>  Deprecated in 3.5: funcname() has been deprecated.  Use anotherfunc() 
> instead.

I’m not sure I understand what you mean by “tag”.

(ASIDE: I’m only marginally familiar with Sphinx, so I don’t know if “tag” has 
a specific meaning here.  I dabble across lots of markup-to-full-docs 
generation tools; Sphinx is just one that I happen to know the least.)

Are you saying that the source documentation would remain as-is, but something 
during the Sphinx _transformation_ would generate the new/deprecated tags?  

As long as those tags are clearly visible at-or-near the start, then I’m all 
for it.  If that is what you propose, then I can think of several possible ways 
to structure the generated HTML & CSS—and from there I would just need to dive 
into the Sphinx transformations and figure out where to sprinkle the “tags”.

--

___
Python tracker 

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



[issue25444] Py Launch Icon

2015-10-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I am the current IDLE maintainer, so that is my interest.  I am not responsible 
for the launcher icon and don't care about it either way.  The second one is 
the one used for IDLE, but Windows has a different format for icons and the 
little one on the title bar does not look as in the screenshot.  It looks 
terrible, worse than the launcher icon.  I do not really know why but I want to 
fix it.

--

___
Python tracker 

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



[issue24570] IDLE Autocomplete and Call Tips Do Not Pop Up on OS X with ActiveTcl 8.5.18

2015-10-26 Thread Jose M. Alcaide

Jose M. Alcaide added the comment:

My previous comment was incorrect, sorry.

I thought that this issue was fixed in time for the release of Python 3.5, but 
it wasn't (fix was committed on Sep 26, two weeks after 3.5's release).

My apologies.

--

___
Python tracker 

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



[issue25484] Operator issue with "in" on same level and preceding ==

2015-10-26 Thread Sapphire Becker

New submission from Sapphire Becker:

So I found this while using == as xnor, here's a summary of the issue:

>>> "h" in ["h"] == True
False
>>> ("h" in ["h"]) == True
True
>>> "h" in (["h"] == True)
Traceback (most recent call last):
File "", line 1, in 
TypeError: argument of type 'bool' is not iterable

Now obviously #3 should error but I would expect #1 and #2 to be the same. I 
checked it out with dis (in Py 3.4) and it seems like a bug. In detail:

#2's is very clean, exactly what I would expect:
>>> dis.dis('("h" in ["h"]) == True')
  1   0 LOAD_CONST   0 ('h')
  3 LOAD_CONST   2 (('h',))
  6 COMPARE_OP   6 (in)
  9 LOAD_CONST   1 (True)
 12 COMPARE_OP   2 (==)
 15 RETURN_VALUE

#1's, however, looks like a mess:
>>> dis.dis('"h" in ["h"] == True')
  1   0 LOAD_CONST   0 ('h')
  3 LOAD_CONST   0 ('h')
  6 BUILD_LIST   1
  9 DUP_TOP
 10 ROT_THREE
 11 COMPARE_OP   6 (in)
 14 JUMP_IF_FALSE_OR_POP24
 17 LOAD_CONST   1 (True)
 20 COMPARE_OP   2 (==)
 23 RETURN_VALUE
>>   24 ROT_TWO
 25 POP_TOP
 26 RETURN_VALUE

I had to write out the stack to understand this:
1. ['h']
2. ['h', 'h']
3. ['h', ['h']]
4. ['h', ['h'], ['h']]
5. [['h'], 'h', ['h']]
6. [['h'], True] # True = result of in operation
7. [['h']]
8. [['h'], True] # True = =='s right-hand value
9. [False] # False = result of == operation

Therefore the way to actually get true in the first case is:

>>> "h" in ["h"] == ["h"]
True


I won't pretend to know how simple it is in Python's architecture but I imagine 
it's just setting a higher precedence for "in" than ==?

Not a huge deal, it's workaroundable, just awkward that there wasn't really any 
indication it was failing so it took a bit to debug.

--
components: Interpreter Core
messages: 253478
nosy: Sapphire Becker
priority: normal
severity: normal
status: open
title: Operator issue with "in" on same level and preceding ==
type: behavior
versions: Python 2.7, Python 3.4

___
Python tracker 

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



[issue25483] Improve f-string implementation: FORMAT_VALUE opcode

2015-10-26 Thread Eric V. Smith

New submission from Eric V. Smith:

Currently, the f-string f'a{3!r:10}' evaluates to bytecode that does the same 
thing as:

''.join(['a', format(repr(3), '10')])

That is, it literally calls the functions format() and repr(). The same holds 
true for str() and ascii() with !s and !a, respectively.

By redefining format, str, repr, and ascii, you can break or pervert the 
computation of the f-string's value:

>>> def format(v, fmt=None): return '42'
...
>>> f'{3}'
'42'

It's always been my intention to fix this. This patch adds an opcode 
FORMAT_VALUE, which instead of looking up format, etc., directly calls 
PyObject_Format, PyObject_Str, PyObject_Repr, and PyObject_ASCII. Thus, you can 
no longer modify what an f-string produces merely by overriding the named 
functions.


In addition, because I'm now saving the name lookups and function calls, 
performance is improved.

Here are the times without this patch:

$ ./python -m timeit -s 'x="test"' 'f"{x}"'
100 loops, best of 3: 0.3 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x!s}"'
100 loops, best of 3: 0.511 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x!r}"'
100 loops, best of 3: 0.497 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x!a}"'
100 loops, best of 3: 0.461 usec per loop


And with this patch:

$ ./python -m timeit -s 'x="test"' 'f"{x}"'
1000 loops, best of 3: 0.02 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x!s}"'
1 loops, best of 3: 0.02 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x!r}"'
1000 loops, best of 3: 0.0896 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x!a}"'
1000 loops, best of 3: 0.0923 usec per loop


So a 90%+ speedup, for these simple cases.

Also, now f-strings are faster than %-formatting, at least for some types:

$ ./python -m timeit -s 'x="test"' '"%s"%x'
1000 loops, best of 3: 0.0755 usec per loop

$ ./python -m timeit -s 'x="test"' 'f"{x}"'
1000 loops, best of 3: 0.02 usec per loop


Note that people often "benchmark" %-formatting with code like the following. 
But the optimizer converts this to a constant string, so it's not a fair 
comparison:

$ ./python -m timeit '"%s"%"test"'
1 loops, best of 3: 0.0161 usec per loop


These microbenchmarks aren't the end of the story, since the string 
concatenation also takes some time. That's another optimization I might 
implement in the future.

Thanks to Mark and Larry for some advice on this.

--
assignee: eric.smith
components: Interpreter Core
files: format-opcode.diff
keywords: patch
messages: 253476
nosy: Mark.Shannon, eric.smith, larry
priority: normal
severity: normal
stage: patch review
status: open
title: Improve f-string implementation: FORMAT_VALUE opcode
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file40863/format-opcode.diff

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Brett Cannon

Changes by Brett Cannon :


--
nosy: +brett.cannon

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread jaystrict

jaystrict added the comment:

I just tried the same thing in /home/user2 which is the home of user2 and in /.
In both directories the result is the PermissionError. So the cause is not the 
CWD.

--

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Tony R.

Tony R. added the comment:

> On Oct 26, 2015, at 1:49 PM, Ezio Melotti  wrote:
> 
> Not sure if there's a clever way to do it though (maybe a CSS class can be 
> added to the directives and the labels can be added with CSS :after).

I was thinking something along these lines.  Other possibilities come to mind, 
also.

--

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

I think Ezio's idea is great.  I would not want to see the notices at the top, 
but a label would make things clear (and the label could be hyperlinked to the 
note, since sometimes they are a bit of a distance away).

Someone has to figure out the Sphinx programming, though.

Note that the 'new' label should only appear for stuff that is new in that 
release.  It's not clear to me if it should appear at all in the docs for 
maintenance releases...that should be discussed.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue25483] Improve f-string implementation: FORMAT_VALUE opcode

2015-10-26 Thread Eric V. Smith

Eric V. Smith added the comment:

Small cleanups. Fixed a bug in PyCompile_OpcodeStackEffect.

--
Added file: http://bugs.python.org/file40864/format-opcode-1.diff

___
Python tracker 

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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread Ezio Melotti

Ezio Melotti added the comment:

> Note that the 'new' label should only appear for stuff that is new
> in that release.

This is not a problem if it says [new in x.y] explicitly.  This way for each 
version-added/version-changed/deprecated/deprecated-remove directive we will 
also have a label.

As for the implementation, I'm pretty sure it can be done by 
changing/redefining all the function/method/class directives.  The directives 
should then be able to inspect the nodes they contain and see if there are any 
of the aforementioned directives and turn them into labels.  Not sure if 
there's a clever way to do it though (maybe a CSS class can be added to the 
directives and the labels can be added with CSS :after).

--

___
Python tracker 

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



[issue25484] Operator issue with "in" on same level and preceding ==

2015-10-26 Thread Ezio Melotti

Ezio Melotti added the comment:

As far as I understand, this is treated as "x < y < z" or "x == y == z":

>>> import ast
>>> ast.dump(ast.parse("1 < 2 < 3"))
'Module(body=[Expr(value=Compare(left=Num(n=1), ops=[Lt(), Lt()], 
comparators=[Num(n=2), Num(n=3)]))])
>>> ast.dump(ast.parse("1 == 2 == 3"))
'Module(body=[Expr(value=Compare(left=Num(n=1), ops=[Eq(), Eq()], 
comparators=[Num(n=2), Num(n=3)]))])'
>>> ast.dump(ast.parse("1 in 2 == 3"))
'Module(body=[Expr(value=Compare(left=Num(n=1), ops=[In(), Eq()], 
comparators=[Num(n=2), Num(n=3)]))])'

The following code is also valid and works as expected:
>>> 1 in [1] in [[1]]
True
>>> 2 not in [1] in [[1]]
True

Your example yields an unexpected result, but I'm not sure if and how it can be 
fixed.

--

___
Python tracker 

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



[issue25154] Drop the pyvenv script

2015-10-26 Thread Brett Cannon

Changes by Brett Cannon :


--
status: closed -> open

___
Python tracker 

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



[issue25484] Operator issue with "in" on same level and preceding ==

2015-10-26 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread jaystrict

jaystrict added the comment:

user2 in fact has permissions in the CWD.
The CWD has been set to /tmp intentionally, exactly for that reason that every 
user has "rwx" access there.

--
status: pending -> open

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

On some unix systems you cannot execute files in /tmp, even if x is set.  Is 
that true for yours?  Bascially, subprocess is just reporting the error that 
the OS is reporting to it, which is why I say the messages is almost certainly 
correct.

--

___
Python tracker 

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



[issue25484] Operator issue with "in" on same level and preceding ==

2015-10-26 Thread Ezio Melotti

Ezio Melotti added the comment:

https://docs.python.org/3/reference/expressions.html#comparisons says that "a 
op1 b op2 c ... y opN z is equivalent to a op1 b and b op2 c and ... y opN z" 
and this explains the "unexpected" result:

>>> 1 in [1] == True
False
>>> 1 in [1] and [1] == True
False

"in" and "not in" are also listed among the comparison operators, so I think 
this behavior is expected and by design.  I don't think there's anything that 
needs to be fixed here.

--
resolution:  -> not a bug
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



[issue25485] Add a context manager to telnetlib.Telnet

2015-10-26 Thread desbma

New submission from desbma:

telnetlib.Telnet could have a context manager to call close() automatically.

I can provide a patch if the idea is approved, although I have never 
contributed to Python.

--
components: Library (Lib)
messages: 253489
nosy: desbma
priority: normal
severity: normal
status: open
title: Add a context manager to telnetlib.Telnet
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



[issue25467] Put “deprecated” warnings first

2015-10-26 Thread R. David Murray

R. David Murray added the comment:

Insert "in my opinion" into that sentence.  I don't want to be distracted by 
"new in 3.1" tags when reading the 3.6 documentation.  It isn't new from my POV 
:)

--

___
Python tracker 

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



[issue25481] PermissionError in subprocess.check_output() when running as a different user (not login shell)

2015-10-26 Thread jaystrict

jaystrict added the comment:

I just found that a "chmod o+x /home/user1" fixes the problem in the sense that 
now a FileNotFoundError is thrown.
So I am very certain that you can reproduce this by making your home directory 
non-executable.

Could it be that python tries to access the "original" home directory somehow? 
For example to write to a pipe?

--

___
Python tracker 

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