[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Length hints were intentionally omitted from the Python 3 map() and filter() 
which used to be in the itertools module.   I explored that notion of iterator 
length transparency years ago.  While I don't remember all the details, I did 
record some notes at the top of Lib/test/test_iterlen.py.

BTW, I also don't think the list(map(...)) or list(filter(...)) case is worth 
optimizing.  For big inputs, manifesting the whole input into a list is usually 
(but not always) the wrong thing to do if you care about performance (throwing 
away the iterator's superb L1 and L2 cache performance and throwing away the 
memory efficiency).

--

___
Python tracker 

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> In my experience CSV files with fields with embedded newlines 
> are pretty common.  I don't really think we want to support
> invalid CSV files.

I concur with David on both points.   Also, whether common or not, we don't 
want to break existing code that already works.

I recommend marking this as rejected and closing.

--
nosy: +rhettinger

___
Python tracker 

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



[issue30035] [RFC] PyMemberDef.name should be const char *

2017-04-10 Thread Sunyeop Lee

New submission from Sunyeop Lee:

PyMemberDef from Noddy examaple: 
https://docs.python.org/3/extending/newtypes.html

static PyMemberDef Noddy_members[] = {
{"first", T_OBJECT_EX, offsetof(Noddy, first), 0,
 "first name"},
{"last", T_OBJECT_EX, offsetof(Noddy, last), 0,
 "last name"},
{"number", T_INT, offsetof(Noddy, number), 0,
 "noddy number"},
{NULL}  /* Sentinel */
};

When compiling the code with the PyMemberDef above with GCC, it compiles well. 
However, with G++, ISO C++11 complains(warns) it is deprecated to convert 
string literal to 'char *' is deprecated 
[-Wc++11-compat-deprecated-writable-strings]

Should the example code be fixed, or should PyMemberDef fixed? I think 
PyMemberDef.name should bo const char * instead of char *.

Compiled with:
g++ test.cpp 
-I/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/include/python3.6m
 
-L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin
 -lpython3.6m -fPIC -shared

Compiler versions:

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr 
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.38)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr 
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.38)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

--
components: Extension Modules
files: test.cpp
messages: 291459
nosy: Sunyeop Lee
priority: normal
severity: normal
status: open
title: [RFC] PyMemberDef.name should be const char *
type: compile error
versions: Python 3.6
Added file: http://bugs.python.org/file46795/test.cpp

___
Python tracker 

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



[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-10 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue26828] Implement __length_hint__() on map() and filter() to optimize list(map) and list(filter)

2017-04-10 Thread Michael Seifert

Changes by Michael Seifert :


--
pull_requests: +1220

___
Python tracker 

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



[issue29030] argparse: choices override metavar

2017-04-10 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> bethard
nosy: +bethard

___
Python tracker 

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



[issue26860] Make os.walk and os.fwalk yield namedtuple instead of tuple

2017-04-10 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> rejected
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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine

Keith Erskine added the comment:

As you say, David, however much we would like the world to stick to a given CSV 
standard, the reality is that people don't, which is all the more reason for 
making the csv reader flexible and forgiving.

The csv module can and should be used for more than just 
"comma-separated-values" files.  I use it for all sorts of different delimited 
files, and it works very well.  Pandas uses it, as I'm sure do many other 
packages.  It's such a good module, it would be a pity to restrict its scope to 
just Excel-related scenarios.  Parsing delimited files is undoubtedly complex, 
and painfully slow if done with pure Python, so the more that can be done in C 
the better.

I'm no C programmer, but my guesstimate is that the coding changes I'm 
proposing are relatively modest.  In the IN_QUOTED_FIELD section 
(https://github.com/python/cpython/blob/master/Modules/_csv.c#L690), it would 
mean checking for newline characters if the new "multiline" attribute is False 
(and probably "strict" is False too).  Of course there is more to this change 
than just that, but I'm guessing not that much more.

--

___
Python tracker 

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

Well, ETL is semi-standardized.  Try dealing with csv files exported from excel 
spreadsheets written by non-programmers :)

"e"X is not a quoting the csv module will produce, but I don't think it is a 
csv error.  insofar as csv has a standard, it is a defacto standard based on 
what Microsoft tools do.  What does excel, for example, do with either of those 
examples?

--

___
Python tracker 

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine

Keith Erskine added the comment:

The csv reader already handles a certain amount of bad formatting.  For 
example, using default behavior, the following file:

a,b,c
d,"e"X,f
g,h,i

is read as:
['a', 'b', 'c']
['d', 'eX', 'f']
['g', 'h', 'i']

It seems reasonable that csv should be able to handle delimited files that are 
not perfectly formatted.  After all, even the CSV "standard" isn't really a 
standard.  When dealing with large (10GB+) files, it's a pain if csv cannot 
read the file because of just one misplaced quote character.  Besides, data 
files are only going to get bigger.

Also, I have to say, I've been dealing with large ETL jobs for over 15 years 
now and I'm struggling to think of a time when I've ever seen a multiline CSV 
file.  Of course, we've all have different experiences.

--

___
Python tracker 

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

In my experience CSV files with fields with embedded newlines are pretty 
common.  I don't really think we want to support invalid CSV files.

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine

Keith Erskine added the comment:

Perhaps I should add what I would prefer the csv reader to return in my example 
above.  That would be:

['a', 'b', 'c']
['d', 'e,f']
['g', 'h', 'i']

Yes, the second line is still mangled but at least the csv reader would carry 
on and read the third line correctly.

--

___
Python tracker 

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
components: +Library (Lib)
nosy: +Mariatta

___
Python tracker 

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



[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine

New submission from Keith Erskine:

If a csv file has a quote character at the beginning of a field but no closing 
quote, the csv module will keep reading the file until the very end in an 
attempt to close out the field.  It's true this situation occurs only when the 
quoting in a csv file is incorrect, but it would be extremely helpful if the 
csv reader could be told to stop reading each row of fields when it encounters 
a newline character, even if it is within a quoted field at the time.  At the 
moment, with large files, the csv reader will typically error out in this 
situation once it reads the maximum size of a string.  Furthermore, this is not 
an easy situation to trap with custom code.

Here's an example of the what I'm talking about.  For a csv file with the 
following content:
a,b,c
d,"e,f
g,h,i

This code:

import csv
with open('file.txt') as f:
reader = csv.reader(f)
for row in reader:
print(row)

returns:
['a', 'b', 'c']
['d', 'e,f\ng,h,i\n']

Note that the whole of the file after "e", including delimiters and newlines, 
has been added to the second field on the second line. This is correct csv 
behavior but is very unhelpful to me in this situation.

On the grounds that most csv files do not have multiline values within them, 
perhaps a new dialect attribute called "multiline" could be added to the csv 
module, that defaults to True for backwards compatibility.  It would indicate 
whether the csv file has any field values within it that span more than one 
line.  If multiline is False, then the "parse_process_char" function in "_csv" 
would always close out a row of fields when it encounters a newline character.  
It might be best if this multiline attribute were taken into account only when 
"strict" is False.

Right now, I do get badly-formatted files like this, and I cannot ask the 
source for a new file.  I have to manually correct the file using a mixture of 
custom scripts and vi before the csv module will read it. It would be very 
helpful if csv would handle this directly.

--
messages: 291453
nosy: keef604
priority: normal
severity: normal
status: open
title: csv reader chokes on bad quoting in large files
type: enhancement
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



[issue29549] Improve docstring for str.index

2017-04-10 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

There is, however, an issue that if you pass a message with the default policy 
to the generator and specify SMTP as the policy, it doesn't *recode* the line 
endings.  I thought there was an open issue for that, but I can't find it.

One solution would be to do as you suggest and make \r\n what we always use 
when doing base64 encoding.  I'm open to that as a possible fix, but it 
probably needs at least a brief discussion with Barry.

--

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

Huh.  I ran something like that test and thought I saw the reverse.  I guess I 
misread my terminal.  Looking at the code, set_content does take care to fix 
the line ending according to the policy before doing the encoding.

--
resolution:  -> out of date
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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Jon Ribbens

Jon Ribbens added the comment:

So on further investigation, with the new API and policy=SMTP, it does generate 
correct base64 output. So I guess on the basis that the new version can 
generate the right output, and it appears to be a deliberate choice that the 
default policy breaks the RFCs, you can close this issue ;-)

>>> from email.message import EmailMessage
>>> from email.policy import SMTP
>>> import base64
>>> msg = EmailMessage(policy=SMTP)
>>> msg.set_content("hello\nthere", cte="base64")
>>> msg.as_string()
'Content-Type: text/plain; charset="utf-8"\r\nContent-Transfer-Encoding: 
base64\r\nMIME-Version: 1.0\r\n\r\naGVsbG8NCnRoZXJlDQo=\r\n'
>>> base64.b64decode("aGVsbG8NCnRoZXJlDQo=")
b'hello\r\nthere\r\n'

--

___
Python tracker 

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



[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

The API exists in python3.5 and python3.4 as well, it was just provisional.  
Very few things changed between the provisional version and the final version 
in 3.6.

--

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

Changes by R. David Murray :


--
components: +email

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

Changes by R. David Murray :


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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

That is true for text/ types, yes.  The policy is named after the target 
wire protocol, and if you are transmitting an email message over SMTP, that 
implies MIME.  What to do if you are not sending it over SMTP, though, is a 
tougher question. One could argue it either way for the 'default' policy, and 
I'm open to argument.

--
versions: +Python 3.6, Python 3.7 -Python 3.5

___
Python tracker 

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



[issue29870] ssl socket leak

2017-04-10 Thread Alexander Mohr

Alexander Mohr added the comment:

yes, in the gist I created you can switch between the various clients, by 
default right now it uses raw sockets.

--

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Jon Ribbens

Jon Ribbens added the comment:

OK cool, but please note that this is a MIME issue not an SMTP issue - if the 
message has text that is being base64-encoded then it must use CRLF line breaks 
regardless of whether SMTP is involved or not.

--

___
Python tracker 

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



[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread Jon Ribbens

Jon Ribbens added the comment:

Just a note for anyone finding this in searching results: it appears that what 
David means by "python3 API" is actually a new API in Python 3.6 
(email.message.EmailMessage).

--

___
Python tracker 

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



[issue29870] ssl socket leak

2017-04-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I see.  This may mean the leak is in memory that's not managed directly by 
Python (e.g. some OpenSSL structure).

Is there a way to reproduce without third-party libraries such as requests?

--

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

Actually, I think the fix would go in the generator, not in the contentmanager, 
but it's been long enough since I've worked on the code that I'm not sure.

--

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

This appears to be a problem in the new API as well.  I don't think we can 
change the legacy API because its been that way forever and applications might 
be depending on it (that is, the library preserves exactly what it is handed, 
and an application might break if that changes).  In the new API, though, I 
think we could get away with fixing it to do the transformation on text strings 
in the default content manager so that the line endings follow the message 
policy.  (That is, if you use default, you get \n, if you use SMTP, you get 
\r\n).  I think we can get away with it because there aren't that many 
applications using the new API yet.

--
components:  -email

___
Python tracker 

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



[issue29870] ssl socket leak

2017-04-10 Thread Alexander Mohr

Alexander Mohr added the comment:

@pitrou: sys.getallocatedblocks does not seem to increase

--

___
Python tracker 

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

Yeah, I was wondering if part of the demo was to show something that can be 
done with no library support...but that probably isn't the case.

--

___
Python tracker 

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



[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

Yes, this sub-optimal, but it's the way it works in the legacy API, and we 
aren't going to change the legacy (compat32) API at this point.  The new 
policies and the new API in python3 handle this sensibly.

--
resolution:  -> out of date
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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +email
nosy: +barry, r.david.murray

___
Python tracker 

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



[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +email
nosy: +barry, r.david.murray

___
Python tracker 

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-10 Thread Eric V. Smith

Eric V. Smith added the comment:

Oops, yes, __init__.

Plenty of the demos use imports. I think it would be clearer with argparse, but 
I also don't feel strongly about it.

--

___
Python tracker 

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



[issue30024] Treat `import a.b.c as m` as `m = sys.modules['a.b.c']`

2017-04-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It is easy to implement this (just replace LOAD_ATTR with IMPORT_FROM in the 
compiler). The hardest part is writing tests.

--
keywords: +easy (C)
nosy: +serhiy.storchaka
stage:  -> needs patch

___
Python tracker 

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-10 Thread R. David Murray

R. David Murray added the comment:

I'm not sure about using argparse.  Currently the demo uses no imports.  I'm 
not strongly against, though.

Did you mean __init__ instead of __new__?  Also, its value could be made True 
and False instead of 0 and 1.  (Which tells you how old this demo is.)

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



[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread Jon Ribbens

New submission from Jon Ribbens:

The email module, when creating text parts using character encoding utf-8, 
base64-encodes the output even though this is often inappropriate (e.g. if it 
is a Western language it is almost never appropriate).

>>> from email.mime.text import MIMEText
>>> m = MIMEText("hello", _charset="utf-8")
>>> m.as_string()
'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 
1.0\nContent-Transfer-Encoding: base64\n\naGVsbG8=\n'

--
components: Library (Lib)
messages: 291435
nosy: jribbens
priority: normal
severity: normal
status: open
title: email module base64-encodes utf-8 text
type: behavior
versions: Python 2.7, Python 3.5

___
Python tracker 

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



[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Jon Ribbens

New submission from Jon Ribbens:

The email module, when creating base64-encoded text parts, does not process 
line breaks correctly - RFC 2045 s6.8 says that line breaks must be converted 
to CRLF before base64-encoding, and the email module is not doing this.

>>> from email.mime.text import MIMEText
>>> import base64
>>> m = MIMEText("hello\nthere", _charset="utf-8")
>>> m.as_string()
'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 
1.0\nContent-Transfer-Encoding: base64\n\naGVsbG8KdGhlcmU=\n'
>>> base64.b64decode("aGVsbG8KdGhlcmU=")
b'hello\nthere'

You might say that it is the application's job to convert the line endings 
before calling MIMEText(), but I think all application authors would be 
surprised by this. Certainly the MailMan authors would be, as they say this is 
a Python bug not a MailMan bug ;-)

--
components: Library (Lib)
messages: 291434
nosy: jribbens
priority: normal
severity: normal
status: open
title: email module creates base64 output with incorrect line breaks
type: behavior
versions: Python 2.7, Python 3.5

___
Python tracker 

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



[issue29521] Minor warning messages when compiling documentation

2017-04-10 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset e0cba5b45a5c4bafd1ae772be52ca0d69651da24 by Mariatta in branch 
'2.7':
[2.7] bpo-29521: Fix two minor documentation build warnings (GH-41) (GH-670)
https://github.com/python/cpython/commit/e0cba5b45a5c4bafd1ae772be52ca0d69651da24


--

___
Python tracker 

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-10 Thread Eric V. Smith

Eric V. Smith added the comment:

I think these are reasonable improvements. Also, move the initialization of 
"silent" in to __new__.

--
keywords: +easy
nosy: +eric.smith

___
Python tracker 

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



[issue30024] Treat `import a.b.c as m` as `m = sys.modules['a.b.c']`

2017-04-10 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue30024] Treat `import a.b.c as m` as `m = sys.modules['a.b.c']`

2017-04-10 Thread Guido van Rossum

Guido van Rossum added the comment:

OK I won't close it but I'm withdrawing from the issue. If there are devs who 
want to implement this or mentor some contributor into implementing it feel 
free, but it sounds like Nick doesn't think it's important enough to fix (i.e. 
not worth his time) and I feel the same.

--

___
Python tracker 

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



[issue29881] Add a new private API clear private variables, which are initialized once, at Python shutdown

2017-04-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Can you move forward this issue Victor? I'm very interesting in it. It is worth 
to advertise this API on Python-Dev.

_PyArg_Parser also can utilize this API.

--

___
Python tracker 

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



[issue30030] Simplify _RandomNameSequence

2017-04-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The downside of this change:

1. The _RandomNameSequence iterator no longer has the rng field. But it isn't 
used in the stdlib. And since _RandomNameSequence is a private name, it 
shouldn't be used in third-party code.

2. The result of no longer copyable neither pickleable. This could cause a 
problem if it is set as an attribute of copyable of pickleable object. But it 
is used only as function local or module global instances in tempfile and class 
attribute of in multiprocessing.synchronize.SemLock and 
multiprocessing.heap.Arena. All these cases don't involved in copying or 
pickling. And in general copying and pickling the _RandomNameSequence object is 
a doubtful idea.

3. This makes iterating the _RandomNameSequence iterator slightly (about 6%) 
slower. Not a big deal, it isn't used in performance critical code. It is 
possible to speed up the _RandomNameSequence iterator by the same 6% by using 
functools.partial (functools already is imported in tempfile), but this makes 
the code slightly less clear, and I choose the simplicity of the code.

--

___
Python tracker 

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



[issue30031] Improve queens demo (use argparse and singular form)

2017-04-10 Thread Pavlo Kapyshin

New submission from Pavlo Kapyshin:

Currently Tools/demo/queens.py:

 - does manual sys.argv parsing
 - says “Found 1 solutions”

I propose to: 1) use argparse; 2) if q.nfound == 1, use “solution”. I you are 
ok with this, I’ll make a pull request.

--
components: Demos and Tools
messages: 291428
nosy: paka
priority: normal
severity: normal
status: open
title: Improve queens demo (use argparse and singular form)
type: enhancement
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



[issue29870] ssl socket leak

2017-04-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Can you record sys.getallocatedblocks() to see whether it grows continuously?

--
nosy: +pitrou

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> os.getlogin document says `Availability: Unix, Windows.`

Originally this meant "not in Mac OS, DOS, OS/2, VMS". But now the support of 
all these platforms is dropped and the note is outdated.

--

___
Python tracker 

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



[issue30030] Simplify _RandomNameSequence

2017-04-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1219

___
Python tracker 

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



[issue30030] Simplify _RandomNameSequence

2017-04-10 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

_RandomNameSequence was added in issue589982 when generator functions were new 
optional feature. _RandomNameSequence is implemented as an iterator class. 
Proposed patch simplifies _RandomNameSequence by implementing it as a generator 
function.

This is a private name, all uses of _RandomNameSequence() need only the support 
of the iterator protocol.

--
components: Library (Lib)
messages: 291425
nosy: haypo, pitrou, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Simplify _RandomNameSequence
type: enhancement
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



[issue29870] ssl socket leak

2017-04-10 Thread Michael Sghaier

Changes by Michael Sghaier :


--
pull_requests: +1218

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread INADA Naoki

INADA Naoki added the comment:

> Oh. If os.getpid() is not always available, the documentation should be 
> updated.

Yes, but CloudABI is not officially supported platform.
They have many patches to run Python on CloudABI. 
https://github.com/NuxiNL/cloudabi-ports/tree/master/packages/python

How can we document about it?  I hadn't used it.

os.getlogin document says `Availability: Unix, Windows.` [1]
Is it proper way to indicate "there may be some minor platforms which doesn't 
provide this."?
[1] https://docs.python.org/3.6/library/os.html#os.getlogin

--

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread STINNER Victor

STINNER Victor added the comment:

Naoki:
> #28156 added HAVE_GETPID check.
> Maybe, we should have dummy getpid() for CloudABI?

Oh. If os.getpid() is not always available, the documentation should be updated.

--

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread INADA Naoki

INADA Naoki added the comment:

#28156 added HAVE_GETPID check.
Maybe, we should have dummy getpid() for CloudABI?

--
nosy: +inada.naoki

___
Python tracker 

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



[issue19764] subprocess: use PROC_THREAD_ATTRIBUTE_HANDLE_LIST with STARTUPINFOEX on Windows Vista

2017-04-10 Thread Segev Finer

Segev Finer added the comment:

It's been a while since this got any attention...

--

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread STINNER Victor

STINNER Victor added the comment:

I proposed PR 1074 to remove the hasattr(os, 'getpid') from logging.LogRecord 
constructor.

--

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +1217

___
Python tracker 

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



[issue29694] race condition in pathlib mkdir with flags parents=True

2017-04-10 Thread Armin Rigo

Armin Rigo added the comment:

Maybe we should review pathlib.py for this kind of issues and first apply the 
fixes and new tests inside PyPy.  That sounds like a better way to get things 
done for these rare issues, where CPython is understandably reluctant to do 
much changes.

Note that the PyPy version of the stdlib already contains fixes that have not 
been merged back to CPython (or only very slowly), though so far they are the 
kind of issues that trigger more often on PyPy than on CPython, like GC issues.

--

___
Python tracker 

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



[issue29989] subprocess.Popen does not handle file-like objects without file descriptors

2017-04-10 Thread Terry J. Reedy

Changes by Terry J. Reedy :


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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Then LGTM.

--

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread Anselm Kruis

Anselm Kruis added the comment:

I had the same concerns about os.getpid(), but test.support uses it 
unconditionally in various places. See 
https://github.com/python/cpython/blob/master/Lib/test/support/__init__.py#L803 
for an example.

--

___
Python tracker 

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



[issue30024] Treat `import a.b.c as m` as `m = sys.modules['a.b.c']`

2017-04-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Right, this problem only arises with import cycles, and that's why we resisted 
making eager submodule resolution work *at all* for so long (issue 992389 was 
filed way back in 2004).

We only conceded the point (with issue 17636 being implemented for 3.5) 
specifically to address a barrier to adoption for explicit relative imports, as 
it turned out that "from . import bar" could fail in cases where "import 
foo.bar" previously worked.

The best explanation I could find for that rationale in the related python-dev 
thread is PJE's post here: 
https://mail.python.org/pipermail/python-dev/2013-April/125121.html

What Victor's python-ideas thread pointed out is that there are actually *3* 
flavours of import where this particular circular reference problem can come up:

# Has worked as long as Python has had packages,
# as long as you only lazily resolve foo.bar in
# function and method implementations
import foo.bar

# Has worked since 3.5 due to the IMPORT_FROM
# change that falls back to a sys.modules lookup
from foo import bar

# Still gives AttributeError since it
# eagerly resolves the attribute lookup
import foo.bar as bar

While I think the architectural case for allowing this kind of circular 
dependency between different top level namespaces is *much* weaker than that 
for allowing it within packages, I do think there's a reasonable consistency 
argument to be made in favour of ensuring that `from foo import bar` and 
`import foo.bar as bar` are functionally equivalent when `bar` is a submodule 
of `foo`, especially since the latter form makes it clearer to the reader that 
`bar` *is* a submodule, rather than any arbitrary attribute.

I don't think it's a big problem in practice (so I wouldn't spend any time on 
implementing it myself), but the notion of an IMPORT_ATTR opcode for the 
"import x.y.z as m" case that parallels IMPORT_FROM seems architecturally clean 
to me in a way that the proposed resolutions to issue 992389 weren't.

--

___
Python tracker 

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



[issue30028] make test.support.temp_cwd() fork-safe

2017-04-10 Thread Christian Heimes

Christian Heimes added the comment:

The line is from 2006. Some parts of the logging module are much older, maybe 
even from the time Python had DOS support.

--
nosy: +christian.heimes

___
Python tracker 

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