[issue26867] test_ssl test_options fails on ubuntu 16.04

2017-02-28 Thread Xiang Zhang

Changes by Xiang Zhang :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 2.7

___
Python tracker 

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



[issue29675] SysLogHandler does not seem to always expand %(loglevel)s properly

2017-02-28 Thread Vinay Sajip

Vinay Sajip added the comment:

This is not a bug - logging is formatting the message as per the specified 
format string. It then prepends the priority and sends the result to the 
socket. What you are seeing is just how systemd/journald interpret the message 
that's sent.

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



[issue29414] Change 'the for statement is such an iterator' in Tutorial

2017-02-28 Thread Wolfgang Maier

Wolfgang Maier added the comment:

> [...] I prefere the chapter as it currently is, because IMHO it
> introduces the concepts more gradually than your proposal.

That's ok! It's your PR and I only wanted to show an alternative.
I was hoping for a bit more people to provide feedback though.

The main reason I'm interested in changes to the tutorial is because
I'm teaching Python to undergraduates (not in CS, but in Biology) and
I recommend them to work through the Tutorial alongside the course so
I have a natural interest in its quality and really appreciate any
improvement, which I think your PR is certainly offering :)

Let me still comment on some of your points regarding my suggestion:

> In addition the modification of the title section from "for
> Statements" to "for Loops" IMHO makes the title not consistent with
> the other section titles.

I don't see this point. The other section titles are not about loops.
The preceding chapter introduces while loops as a loop, not a
statement, and this chapter talks about while and for loops further
down the page. 

>> - restructured the for loop section to discuss Python for loops
>> first and only compare them to Pascal/C afterwards
> +0. I think for a reader who is coming from another language is better
> to have the current introduction. But maybe it is not the same for a
> reader who is learning Python as a first programming language.

I don't agree with you on this. I'm coming from a C background myself,
but if I want to learn a new language the first thing I'm interested in
is not how it's *not* working, but how it does.
Plus, it's 2017, Perl has foreach, Javascript has at least
array.foreach and even C++11 has auto-iteration over collections so starting an 
explanation of for loops with 'hey, look Python is different 
from two > 40 years old languages' feels a bit outdated.

Regarding my main point of removing most of the ranges section it is
possible I went a bit too far with that and maybe one should still
briefly mention the optional start argument and stress that stop is not
included in the range, but my seealso is quite prominent and the linked
section on range is pretty good.

--

___
Python tracker 

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



[issue26867] test_ssl test_options fails on ubuntu 16.04

2017-02-28 Thread Xiang Zhang

Changes by Xiang Zhang :


--
pull_requests: +311

___
Python tracker 

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



[issue28598] RHS not consulted in `str % subclass_of_str` case.

2017-02-28 Thread Xiang Zhang

Changes by Xiang Zhang :


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



[issue29682] Checks for null return value

2017-02-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Extension Modules
keywords: +easy (C)
nosy: +gregory.p.smith, serhiy.storchaka
stage:  -> needs patch
type:  -> crash

___
Python tracker 

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



[issue29681] getopt fails to handle option with missing value in middle of list

2017-02-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I concur with Martin. This is not a bug.

--
nosy: +serhiy.storchaka
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



[issue29682] Checks for null return value

2017-02-28 Thread Alex CHEN

New submission from Alex CHEN:

Hi,

Our tool reported a position that doesn't check for returned value (from a 
function that might returns null). might need a look that is there any problem 
or I am missing something.

in function PyUnknownEncodingHandler of file pyexpat.c,

if (namespace_separator != NULL) {
self->itself = XML_ParserCreateNS(encoding, *namespace_separator);
}
else {
self->itself = XML_ParserCreate(encoding);   // could 
XML_ParserCreate returns null in this point?
}
.
XML_SetHashSalt(self->itself, // if it does 
return null, null pointer will passed into XML_SetHashSalt and will be 
dereferenced.
(unsigned long)_Py_HashSecret.prefix);
#endif

--
messages: 288739
nosy: alexc
priority: normal
severity: normal
status: open
title: Checks for null return value
versions: Python 2.7

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Nick Coghlan

Nick Coghlan added the comment:

python-dev thread: 
https://mail.python.org/pipermail/python-dev/2017-March/147501.html

In formulating my question for the list, it occurred to me that while 
asynccontextmanager doesn't need to depend on asyncio, the AsyncExitStack 
proposed in issue 29302 likely will, which pushes me towards favouring the 
`asyncio.contextlib.asynccontextmanager` approach.

--

___
Python tracker 

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



[issue29681] getopt fails to handle option with missing value in middle of list

2017-02-28 Thread Martin Panter

Martin Panter added the comment:

It's not clear what you expected the behaviour to be. A function cannot both 
raise an exception and return a value.

In any case, you are correct in saying "the next option, '-d', is taken as the 
argument." I do not think this is a bug. See 
 for the 
Posix specification of "getopt".

Perhaps you are confused by a bug or quirk of "argparse", where it treats most 
CLI arguments that begin with a dash specially, even if according to Posix they 
would be associated with an option. See Issue 9334.

--
components: +Library (Lib) -Extension Modules
nosy: +martin.panter
resolution:  -> not a bug

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Nick Coghlan

Nick Coghlan added the comment:

It's probably worth a python-dev discussion, but I personally draw the line at 
"Does this need to import 'asyncio'?". If it does, then that's a clear 
dependency inversion, and the functionality doesn't belong in a relatively low 
level module like contextlib.

If it doesn't, then I think the potentially tricky part of this kind of code is 
the way it interacts with the execution stack and the context management 
machinery, so it makes sense for it to live in contextlib and have a design and 
review process that's closely aligned with that for the corresponding 
synchronous APIs.

That said, one of my review comments on the PR was that the new test cases 
should be split out to their own file to avoiding making the existing tests 
depend on asyncio, which I'd consider a point in favour of adding an 
`asyncio.contextlib` module instead of adding these APIs directly to contextlib.

--

___
Python tracker 

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



[issue29302] add contextlib.AsyncExitStack

2017-02-28 Thread Nick Coghlan

Nick Coghlan added the comment:

I quite like the idea of enhancing the existing ExitStack to also handle 
asynchronous operations rather than having completely independent 
implementations. However, a separate object may end up being simpler in 
practice as it allows developers to more explicitly declare their intent of 
writing async-friendly code.

Sketching out what a combined implementation based on the current ExitStack 
might look like:

- add suitable `__aenter__` and `__aexit__` implementations
- add `enter_context_async` (async def, called with await)
- add `push_aexit` (normal def, but given function is called with await)
- add `coroutine_callback` (normal def, but given coroutine is called with 
await)
- add `close_async` (async def, called with await)
- add a new internal state flag `_allow_async`. This would default to True, but 
be set to False when the synchronous `__enter__` is called. When it's false, 
attempting to register an async callback would raise RuntimeError. `__enter__` 
would also need to check any previously register contexts and callbacks, and 
complain if any of them require the use of `Await`
- keep track of which callbacks should be invoked as synchronous calls and 
which should be called via await
- update `close` to raise RuntimeError if it's asked to clean up asynchronous 
resources

That's really quite messy and hard to explain, and makes async code look quite 
different from the corresponding synchronous code.

The repeated checks of `self._allow_async` and `iscoroutinefunction` would also 
slow down existing synchronous code for no specific end user benefit.

By contrast, a dedicated AsyncExitStack object can:

- assume everything passed to it is a coroutine or an async context manager by 
default
- always require close() to be called via await
- either add synchronous variants of the default-to-async methods 
(`enter_context_sync`, `push_sync`, `callback_sync`), or else make them 
auto-adapt to handle both synchronous and asynchronous inputs
- rather than using `iscoroutinefunction`, instead always invoke callbacks with 
await, and wrap synchronous callbacks supplied using the above methods in 
simple one-shot iterators

--

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Nick, do you think this belongs in contextlib to be side-by-side with 
@contextmanager or would it be better to group all async tools in their own 
module.   

It seems to me that people are going to ask for an async version of everything, 
effectively shadowing the core grammar and the library.  Before we go very far 
down that road, I think we should decide where it all should go.

--
nosy: +rhettinger

___
Python tracker 

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



[issue29302] add contextlib.AsyncExitStack

2017-02-28 Thread Nick Coghlan

Changes by Nick Coghlan :


--
nosy: +giampaolo.rodola, gvanrossum, haypo, ncoghlan, yselivanov

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Jelle Zijlstra

Jelle Zijlstra added the comment:

Thanks, I'll address your PR comments.

issue 29302 is asking for AsyncExitStack, but that can be an independent 
change. I haven't personally felt the need for AsyncExitStack.

--

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Nick Coghlan

Nick Coghlan added the comment:

The general idea seems reasonable to me, and I've added some specific code 
level feedback on the PR.

A related question to this one would be whether or not it may make sense to 
develop a more async-friendly variant of contextlib.ExitStack (I don't 
currently write enough async code to design that myself, but I'm open to the 
idea of adding something along those lines).

--

___
Python tracker 

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



[issue28598] RHS not consulted in `str % subclass_of_str` case.

2017-02-28 Thread Xiang Zhang

Changes by Xiang Zhang :


--
pull_requests: +310

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Nick Coghlan

Changes by Nick Coghlan :


--
nosy: +giampaolo.rodola, gvanrossum, haypo, ncoghlan, yselivanov

___
Python tracker 

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



[issue29680] gdb/libpython.py does not work with gdb 7.2

2017-02-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
components: +Demos and Tools
stage:  -> patch review

___
Python tracker 

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



[issue29681] getopt fails to handle option with missing value in middle of list

2017-02-28 Thread Marshall Giguere

New submission from Marshall Giguere:

Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
>>> from getopt import getopt
>>> argv = [ '-a', '-b', '-c', '-d', 'foo']
>>> opts, args = getopt( argv, 'abc:d:')
>>> opts
[('-a', ''), ('-b', ''), ('-c', '-d')]
>>> args
['foo']

Expected behavior:
opts = [('-a', ''), ('-b', ''), ('-c', ''), ('-d', 'foo')]
Throws execption:
getopt.GetoptError: option -c requires argument

Note that -c requires a value, getopt swallows the next option '-d' as the 
argument to -c.  However, if -c is the last option on the command line getopt 
properly throws an execption "getopt.GetoptError: option -c requires argument".

The documentation states that getopt will throw an exception when an option 
requiring a value is missing and exception will be thrown.
"exception getopt.GetoptError
This is raised when an unrecognized option is found in the argument list or 
when an option requiring an argument is given none."

The option -c requires an argument, none was given, no exception is thrown.  
Instead the next option, '-d', is taken as the argument.  I have also tried 
this test on 2.7 with the same result.

--
components: Extension Modules
messages: 288731
nosy: Marshall Giguere
priority: normal
severity: normal
status: open
title: getopt fails to handle option with missing value in middle of list
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



[issue29680] gdb/libpython.py does not work with gdb 7.2

2017-02-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
pull_requests: +308, 309

___
Python tracker 

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



[issue29680] gdb/libpython.py does not work with gdb 7.2

2017-02-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
pull_requests: +308

___
Python tracker 

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



[issue29680] gdb/libpython.py does not work with gdb 7.2

2017-02-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +haypo

___
Python tracker 

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



[issue29680] gdb/libpython.py does not work with gdb 7.2

2017-02-28 Thread Alexander Belopolsky

New submission from Alexander Belopolsky:

Printing the backtrace in gdb results in Python errors:

(gdb) bt
...
#6  0x77ba9745 in _PyEval_EvalCodeWithName (_co=, globals=Traceback (most recent call last):
  File "/home/a/.virtualenvs/3.6g/bin/python3.6-gdb.py", line 1358, in to_string
return pyop.get_truncated_repr(MAX_OUTPUT_LEN)
  File "/home/a/.virtualenvs/3.6g/bin/python3.6-gdb.py", line 243, in 
get_truncated_repr
self.write_repr(out, set())
  File "/home/a/.virtualenvs/3.6g/bin/python3.6-gdb.py", line 702, in write_repr
for pyop_key, pyop_value in self.iteritems():
  File "/home/a/.virtualenvs/3.6g/bin/python3.6-gdb.py", line 669, in iteritems
entries, nentries = self._get_entries(keys)
  File "/home/a/.virtualenvs/3.6g/bin/python3.6-gdb.py", line 717, in 
_get_entries
except gdb.error:
AttributeError: 'module' object has no attribute 'error'
...

--
assignee: belopolsky
messages: 288730
nosy: belopolsky
priority: normal
severity: normal
status: open
title: gdb/libpython.py does not work with gdb 7.2
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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Jelle Zijlstra

Changes by Jelle Zijlstra :


--
pull_requests: +307

___
Python tracker 

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



[issue29679] Add @contextlib.asynccontextmanager

2017-02-28 Thread Jelle Zijlstra

New submission from Jelle Zijlstra:

An async equivalent of @contextmanager would be an obvious use case for async 
generators and the async with statement. In my own code, I have several async 
context objects that could have been written more concisely if 
@asynccontextmanager was available.

I'll be working on a PR to implement this.

--
components: Library (Lib)
messages: 288729
nosy: Jelle Zijlstra
priority: normal
severity: normal
status: open
title: Add @contextlib.asynccontextmanager
versions: Python 3.7

___
Python tracker 

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



[issue28791] update sqlite to 3.17.0

2017-02-28 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Thanks, Big Stone. Setting the version to 3.7.

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



[issue29414] Change 'the for statement is such an iterator' in Tutorial

2017-02-28 Thread Marco Buttu

Marco Buttu added the comment:

Wolfgang, thanks for your contribution. However, I prefere the chapter as it 
currently is, because IMHO it introduces the concepts more gradually than your 
proposal. In addition the modification of the title section from "for 
Statements" to "for Loops" IMHO makes the title not consistent with the other 
section titles.

> - I don't think range() really deserves its own section
> in a chapter about control flow, so I removed most of it
> and linked to the relevant stdtypes section instead

-1 for me: the range() function is used in several examples in the chapter, 
that is why IMHO it is worth having the range() section as it is now.

> - moved the definition of an iterable up into the for
> loop section

-1 for me: IMHO the current definition/introdution of iterable is easier to 
understand for a beginner.

> - restructured the for loop section to discuss Python for loops
> first and only compare them to Pascal/C afterwards

+0. I think for a reader who is coming from another language is better to have 
the current introduction. But maybe it is not the same for a reader who is 
learning Python as a first programming language.

> - moved the example for modifying a list while iterating
> over it to the datastructures chapter

+0

--

___
Python tracker 

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



[issue9303] Migrate sqlite3 module to _v2 API to enhance performance

2017-02-28 Thread Aviv Palivoda

Aviv Palivoda added the comment:

I opened a PR. This actually is a bugfix in addition to an enhancement as it 
solves issue 26187 as well.

--

___
Python tracker 

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



[issue24905] Allow incremental I/O to blobs in sqlite3

2017-02-28 Thread Aviv Palivoda

Aviv Palivoda added the comment:

Just to make sure when you say "sequence protocol" you thin about the doing 
blob[4:6] = "ab"?

I actually think this is a nice feature. The Blob and the mmap object has a lot 
in common so I think that making the same API will be best. I think that adding 
the sequence protocol in addition to the file protocol is best.

--

___
Python tracker 

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



[issue9303] Migrate sqlite3 module to _v2 API to enhance performance

2017-02-28 Thread Aviv Palivoda

Changes by Aviv Palivoda :


--
pull_requests: +306

___
Python tracker 

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



[issue24905] Allow incremental I/O to blobs in sqlite3

2017-02-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Small discussion is started at pull request [1]. There are doubts about the 
usefulness of incremental I/O API. SQLite is rarely used for storing blobs of 
the size of hundreds of megabytes. For smaller blobs it may be enough to read 
or write all data at once. There are also questions about the support of len(), 
since other file-like objects don't support len().

This discussion remembered me about mmap objects. mmap objects implement two 
protocols: file protocol and sequence protocol (including the support of 
len()). The BLOB object looks similar to the mmap object. sqlite3_blob_write() 
may only modify the contents of the BLOB; it is not possible to increase the 
size of a BLOB using this API. Maybe implement the sequence protocol in the 
BLOB object? Or implement only the sequence protocol and drop away the file 
protocol?

[1] https://github.com/python/cpython/pull/271

--

___
Python tracker 

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



[issue29678] email.Message.get_params decodes only first one header value

2017-02-28 Thread Sergey

Changes by Sergey :


--
type: behavior -> enhancement

___
Python tracker 

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



[issue27645] Supporting native backup facility of SQLite

2017-02-28 Thread Aviv Palivoda

Aviv Palivoda added the comment:

I actually looked at the patch and have a few comments:
1. You need to put Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS before the 
sqlite3 calls (especially the sleep).
2. I think that the `pysqlite_connection_backup` function will look a lot 
better if you will have a cleanup/error label.

I am not a core developer but I think you should open the PR as it will be 
easier for the CR.

--
nosy: +palaviv

___
Python tracker 

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



[issue28425] Python3 ignores __init__.py that are links to /dev/null

2017-02-28 Thread Douglas Greiman

Douglas Greiman added the comment:

Bazel has been updated to no longer create symlinks to /dev/null

https://github.com/bazelbuild/bazel/issues/1458

--

___
Python tracker 

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



[issue29666] Issue in enum documentation

2017-02-28 Thread Kartik

Kartik added the comment:

Hi I've edited the documentation to correct this and submitted a PR.

--
nosy: +exqu17
pull_requests: +305

___
Python tracker 

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



[issue29678] email.Message.get_params decodes only first one header value

2017-02-28 Thread Sergey

New submission from Sergey:

email.Message class has method get_params() that can decode(unquote) header 
values in compliance with RFC2231 and RFC2047. But if in email message exists 
multiple headers with the same key it can't be used to decode other headers 
than first.
In my application I could use: 
   headers = message.items() 
   for key, value in headers:
   cleanValue = message.get_params(value=value)
   print(key, cleanValue)
Also have posted question on stackoverflow:
http://stackoverflow.com/questions/42502312/python-3-email-package-how-decode-given-header-value

--
components: email
messages: 288720
nosy: barry, pi314159, r.david.murray
priority: normal
severity: normal
status: open
title: email.Message.get_params decodes only first one header value
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



[issue27593] Deprecate sys._mercurial and create sys._git

2017-02-28 Thread Steve Dower

Steve Dower added the comment:

Just updated my PR to remove the GITTAG variable, so we'll just go with 
GITBRANCH and GITVERSION.

(Any value in trying to extract the URL of the remote? That's probably going to 
be a bit flimsy, but might help more clearly identify forks.)

--

___
Python tracker 

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



[issue29414] Change 'the for statement is such an iterator' in Tutorial

2017-02-28 Thread Wolfgang Maier

Wolfgang Maier added the comment:

I studied the github PR and thought about it carefully, and that made me come 
to believe that the chapter deserves a larger rewrite not just of one section, 
but of several.
I'm attaching my proposed change as a "classical" patch here for discussion. I 
hope that's still a valid way to do this as I did not want to mess with the 
original PR by Marco and, instead, wanted to see my proposal discussed first.

Some of the changes I made:
- I don't think range() really deserves its own section in a chapter about 
control flow, so I removed most of it and linked to the relevant stdtypes 
section instead
- moved the definition of an iterable up into the for loop section
- restructured the for loop section to discuss Python for loops first and only 
compare them to Pascal/C afterwards
- moved the example for modifying a list while iterating over it to the 
datastructures chapter

I find this new version much clearer, but lets see what people here think.

--
nosy: +wolma
Added file: http://bugs.python.org/file46681/controlflow_datastructures.patch

___
Python tracker 

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



[issue28598] RHS not consulted in `str % subclass_of_str` case.

2017-02-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution: fixed -> 
stage: resolved -> needs patch
status: closed -> open
versions: +Python 2.7 -Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue28598] RHS not consulted in `str % subclass_of_str` case.

2017-02-28 Thread Martijn Pieters

Martijn Pieters added the comment:

> Is 2.7 free from this bug?

No, 2.7 is affected too:

>>> class SubclassedStr(str):
... def __rmod__(self, other):
... return 'Success, self.__rmod__({!r}) was called'.format(other)
...
>>> 'lhs %% %r' % SubclassedStr('rhs')
"lhs % 'rhs'"

Expected output is "Success, self.__rmod__('lhs %% %r') was called"

On the plus side, unicode is not affected:

>>> class SubclassedUnicode(unicode):
... def __rmod__(self, other):
... return u'Success, self.__rmod__({!r}) was called'.format(other)
...
>>> u'lhs %% %r' % SubclassedUnicode(u'rhs')
u"Success, self.__rmod__(u'lhs %% %r') was called"

--

___
Python tracker 

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



[issue29676] verbose output of test_cprofile

2017-02-28 Thread INADA Naoki

INADA Naoki added the comment:

thanks.
for summary, notable changes are:

(print_callers)
+{method 'append' of 'list' objects}   <-   40.0000.000 
 profilee.py:73(helper1)
Stats.print_callees output for Profile doesn't fit expectation!

and

(print_callees)
-profilee.py:73(helper1) ->   40.0000.004  {built-in 
method builtins.hasattr}
- 40.0000.000  {built-in 
method sys.exc_info}
+profilee.py:73(helper1)   ->   40.0000.004 
 {built-in method builtins.hasattr}

--

___
Python tracker 

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



[issue29677] 'round()' accepts a negative integer for ndigits

2017-02-28 Thread Gerrit Holl

Changes by Gerrit Holl :


--
pull_requests: +304

___
Python tracker 

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



[issue29677] 'round()' accepts a negative integer for ndigits

2017-02-28 Thread Mark Dickinson

Mark Dickinson added the comment:

Yes, I think the initial description could be clarified. It currently reads:

> Return the floating point value number rounded to ndigits digits after the 
> decimal point.

... which doesn't make it clear what happens for negative ndigits. 

There's a line in the second paragraph:

> values are rounded to the closest multiple of 10 to the power minus ndigits

which technically *does* cover the case of negative ndigits correctly, but I 
think it would be good to have a clarification in the first paragraph of the 
description.

--

___
Python tracker 

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



[issue29677] 'round()' accepts a negative integer for ndigits

2017-02-28 Thread ChrisRands

ChrisRands added the comment:

Ah yes, you're both completely right of course. Perhaps the docs could still be 
clarified though. I managed to completely overlook this, and perhaps other 
non-expert Python users would too.

--

___
Python tracker 

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



[issue29677] 'round()' accepts a negative integer for ndigits

2017-02-28 Thread Mark Dickinson

Mark Dickinson added the comment:

Yep, it's (genuinely) a feature, not a bug, and being able to round to the 
nearest ten, hundred, thousand, etc. is useful. The docs could perhaps be 
improved to make it clearer that this is supported.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, mark.dickinson

___
Python tracker 

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



[issue27500] ProactorEventLoop cannot open connection to ::1

2017-02-28 Thread Sebastien Bourdeauducq

Sebastien Bourdeauducq added the comment:

This is still a problem with Python 3.5.3 and 3.6.0.

--

___
Python tracker 

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



[issue29677] 'round()' accepts a negative integer for ndigits

2017-02-28 Thread Gerrit Holl

Gerrit Holl added the comment:

>>> round(21345, -2)
21300

Desired and useful to me.

--
nosy: +Gerrit.Holl

___
Python tracker 

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



[issue29677] 'round()' accepts a negative integer for ndigits

2017-02-28 Thread ChrisRands

New submission from ChrisRands:

With a negative integer for ndigits the output from 'round()', for example 
'round(3, -2)', is always zero ('0' for 'int.__round__' and '0.0' or '-0.0' for 
'float.__round__').

I think either it should raise an exception or the docs should be updated to 
reflect the current behavior.

The docs are currently silent on this: 
https://docs.python.org/3/library/functions.html#round

I don't know C, but there appears to be a note in the source about this 
implying it is the desired behavior but without an explanation: "For ndigits < 
NDIGITS_MIN, x always rounds to +-0.0.": 
https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Objects/floatobject.c

Anyway, I can't imagine an actual use case for negative ndigits.

--
messages: 288710
nosy: ChrisRands
priority: normal
severity: normal
status: open
title: 'round()' accepts a negative integer for ndigits

___
Python tracker 

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



[issue29672] `catch_warnings` context manager should reset warning registry to previous state upon exiting, to prevent warnings from being reprinted

2017-02-28 Thread Gerrit Holl

Gerrit Holl added the comment:

To resolve this, the `catch_warnings` context manager upon exiting should not 
only reset `filters`, but also `_filters_version`, and perhaps an associated 
dictionary?  Not sure if I'm understanding the code in `warnings.c` correctly, 
and whether, for this change, it would suffice to change `warnings.py` or 
whether `warnings.c` would need to be updated as well.

--

___
Python tracker 

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



[issue29672] `catch_warnings` context manager should reset warning registry to previous state upon exiting, to prevent warnings from being reprinted

2017-02-28 Thread Gerrit Holl

Changes by Gerrit Holl :


--
title: `catch_warnings` context manager causes warnings to be reprinted -> 
`catch_warnings` context manager should reset warning registry to previous 
state upon exiting, to prevent warnings from being reprinted

___
Python tracker 

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



[issue27144] concurrent.futures.as_completed() memory inefficiency

2017-02-28 Thread Will Vousden

Will Vousden added the comment:

Is there a reason this hasn't been merged yet?

Fixing this bug locally (albeit just by setting Future._result = None when I've 
extracted the result) reduced the memory footprint of my program from 50 GB to 
7 GB, so it seems worth it.

--

___
Python tracker 

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



[issue29110] [patch] Fix file object leak in `aifc.open` when given invalid AIFF file.

2017-02-28 Thread INADA Naoki

Changes by INADA Naoki :


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



[issue27144] concurrent.futures.as_completed() memory inefficiency

2017-02-28 Thread willvousden

Changes by willvousden :


--
nosy: +willvousden

___
Python tracker 

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



[issue29676] verbose output of test_cprofile

2017-02-28 Thread Xiang Zhang

New submission from Xiang Zhang:

Recently when I run the test suite test_cprofile always produces some verbose 
info but won't fail. This is not the case before. I am not sure this is a bug 
or not. git bisect tells me 
https://github.com/python/cpython/commit/5566bbb8d563646d83e8172410fa0c085e8233b1
 is responsible. I also see the verbose info on some buildbots.

[cpython]$ ./python -m test test_cprofile
Run tests sequentially
0:00:00 [1/1] test_cprofile
Stats.print_callers output for Profile doesn't fit expectation!
--- 

+++ 

@@ -1,15 +1,16 @@

-profilee.py:110(__getattr__)<-  160.0160.016  
profilee.py:98(subhelper)
-profilee.py:25(testfunc)<-   10.2701.000  
:1()
-profilee.py:35(factorial)   <-   10.0140.130  
profilee.py:25(testfunc)
-  20/30.1300.147  
profilee.py:35(factorial)
- 20.0060.040  
profilee.py:84(helper2_indirect)
-profilee.py:48(mul) <-  200.0200.020  
profilee.py:35(factorial)
-profilee.py:55(helper)  <-   20.0400.600  
profilee.py:25(testfunc)
-profilee.py:73(helper1) <-   40.1160.120  
profilee.py:55(helper)
-profilee.py:84(helper2_indirect)<-   20.0000.140  
profilee.py:55(helper)
-profilee.py:88(helper2) <-   60.2340.300  
profilee.py:55(helper)
- 20.0780.100  
profilee.py:84(helper2_indirect)
-profilee.py:98(subhelper)   <-   80.0640.080  
profilee.py:88(helper2)
-{built-in method builtins.hasattr}  <-   40.0000.004  
profilee.py:73(helper1)
- 80.0000.008  
profilee.py:88(helper2)
-{built-in method sys.exc_info}  <-   40.0000.000  
profilee.py:73(helper1)
+profilee.py:110(__getattr__)  <-  160.0160.016 
 profilee.py:98(subhelper)
+profilee.py:25(testfunc)  <-   10.2701.000 
 :1()
+profilee.py:35(factorial) <-   10.0140.130 
 profilee.py:25(testfunc)
+20/30.1300.147 
 profilee.py:35(factorial)
+   20.0060.040 
 profilee.py:84(helper2_indirect)
+profilee.py:48(mul)   <-  200.0200.020 
 profilee.py:35(factorial)
+profilee.py:55(helper)<-   20.0400.600 
 profilee.py:25(testfunc)
+profilee.py:73(helper1)   <-   40.1160.120 
 profilee.py:55(helper)
+profilee.py:84(helper2_indirect)  <-   20.0000.140 
 profilee.py:55(helper)
+profilee.py:88(helper2)   <-   60.2340.300 
 profilee.py:55(helper)
+   20.0780.100 
 profilee.py:84(helper2_indirect)
+profilee.py:98(subhelper) <-   80.0640.080 
 profilee.py:88(helper2)
+{built-in method builtins.hasattr}<-   40.0000.004 
 profilee.py:73(helper1)
+   80.0000.008 
 profilee.py:88(helper2)
+{built-in method sys.exc_info}<-   40.0000.000 
 profilee.py:73(helper1)
+{method 'append' of 'list' objects}   <-   40.0000.000 
 profilee.py:73(helper1)
Stats.print_callees output for Profile doesn't fit expectation!
--- 

+++ 

@@ -1,16 +1,16 @@

-:1()->   10.2701.000  
profilee.py:25(testfunc)
-profilee.py:110(__getattr__)->
-profilee.py:25(testfunc)->   10.0140.130  
profilee.py:35(factorial)
- 20.0400.600  
profilee.py:55(helper)
-profilee.py:35(factorial)   ->20/30.1300.147  
profilee.py:35(factorial)
-200.0200.020  
profilee.py:48(mul)
-profilee.py:48(mul) ->
-profilee.py:55(helper)  ->   40.1160.120  
profilee.py:73(helper1)
- 20.0000.140  
profilee.py:84(helper2_indirect)
- 60.2340.300  
profilee.py:88(helper2)
-profilee.py:73(helper1) ->   40.0000.004  {built-in 
method builtins.hasattr}
-profilee.py:84(helper2_indirect)->   20.0060.040  
profilee.py:35(factorial)
- 20.0780.100  
profilee.py:88(helper2)
-profilee.py:88(helper2) ->   80.0640.080  
profilee.py:98(subhelper)
-profilee.py:98(subhelper)   ->  160.0160.016  
pro

[issue16113] Add SHA-3 and SHAKE (Keccak) support

2017-02-28 Thread Michał Górny

Michał Górny added the comment:

Christian, since the code is now integrated in Python 3.6+ (with some bugfixes 
AFAICS), could you consider updating your bitbucket package to match it? It 
would be helpful as a backport package for older Python versions.

--
nosy: +mgorny

___
Python tracker 

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



[issue29110] [patch] Fix file object leak in `aifc.open` when given invalid AIFF file.

2017-02-28 Thread INADA Naoki

INADA Naoki added the comment:

OK, since Aifc_write is harder to test, and the exception is very unlikely 
happens, I fixed only Aifc_read.

--

___
Python tracker 

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



[issue29675] SysLogHandler does not seem to always expand %(loglevel)s properly

2017-02-28 Thread Q

Q added the comment:

PS. I'm not sure if that is a systemd/journald issue, or indeed a Python bug.

However, it would be nice to clear one possibility. 

For a StreamHandler, it all works as it should.

--

___
Python tracker 

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



[issue29110] [patch] Fix file object leak in `aifc.open` when given invalid AIFF file.

2017-02-28 Thread INADA Naoki

Changes by INADA Naoki :


--
pull_requests: +303

___
Python tracker 

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



[issue29675] SysLogHandler does not seem to always expand %(loglevel)s properly

2017-02-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue29675] SysLogHandler does not seem to always expand %(loglevel)s properly

2017-02-28 Thread Q

Q added the comment:

Attaching the other file mentioned.

--
Added file: http://bugs.python.org/file46680/good.py

___
Python tracker 

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



[issue29675] SysLogHandler does not seem to always expand %(loglevel)s properly

2017-02-28 Thread Q

New submission from Q:

On Ubuntu LTS 16.04, SysLogHandler with a custom formatter does not seem to 
expand loglevel/levelno fields properly, when there are square brackets ( see 
the attached examples ). Instead, it seems to replace '[%(loglevel)s]' with a 
'[pid]', and '%(loglevel)s' with 'LOGLEVEL[pid]' .

To test, run 'journalctl -f | grep test_test_test' on one console, and the 
attached files on another. The output for 'bad.py' looks as follows:
===
Feb 28 21:30:05 hostname [7117]: logging was configured for 
process <7117>
===

And should have looked like:
===
Feb 28 21:30:05 hostname [INFO]: logging was configured for 
process <7117>
===

For 'good.py', the output is as follows:
===
Feb 28 21:30:04 hostname INFO[7114]: logging was configured for 
process <7114>
===

and should have probably been: 
===
Feb 28 21:30:04 hostname INFO: logging was configured for 
process <7114>
===

Kind regards, /t13

--
files: bad.py
messages: 288702
nosy: thread13
priority: normal
severity: normal
status: open
title: SysLogHandler does not seem to always expand %(loglevel)s properly
versions: Python 2.7
Added file: http://bugs.python.org/file46679/bad.py

___
Python tracker 

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



[issue7769] SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator

2017-02-28 Thread Xiang Zhang

Xiang Zhang added the comment:

Thanks everyone involved!

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



[issue29673] Some gdb macros are broken in 3.6

2017-02-28 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



[issue29671] Add function to gc module to check if any reference cycles have been reclaimed.

2017-02-28 Thread Mark Dickinson

Mark Dickinson added the comment:

> In a normal program, a class wouldn't generally ever become garbage,

Right; it's only really a problem with dynamically-created classes. Some parts 
of the standard library (like ctypes), generate such classes.

Okay to close this as rejected?

--

___
Python tracker 

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



[issue29674] Use GCC __attribute__((alloc_size(x, y))) on PyMem_Malloc() functions

2017-02-28 Thread STINNER Victor

New submission from STINNER Victor:

GCC allows to get "size" parameters of functions allocating memory to emit 
better warning. For example, GCC 7 will detect implicit cast from signed to 
unsigned integer and emit a warning.

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Example of Python functions that can benefit of this attribute:

* PyMem_RawMalloc(), PyMem_RawCalloc(), PyMem_RawRealloc()
* PyMem_Malloc(), PyMem_Calloc(), PyMem_Realloc()
* PyObject_Malloc(), PyObject_Calloc(), PyObject_Realloc()

--
messages: 288699
nosy: haypo
priority: normal
severity: normal
status: open
title: Use GCC __attribute__((alloc_size(x,y))) on PyMem_Malloc() functions
versions: Python 3.7

___
Python tracker 

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