[issue33018] Improve issubclass() error checking and message

2018-03-06 Thread Joshua Bronson

New submission from Joshua Bronson :

Creating this issue by request of INADA Naoki to discuss my proposed patch in 
https://github.com/python/cpython/pull/5944.

Copy/pasting from that PR:

If you try something like issubclass('not a class', str), you get a helpful 
error message that immediately clues you in on what you did wrong:

>>> issubclass('not a class', str)
TypeError: issubclass() arg 1 must be a class
("AHA! I meant isinstance there. Thanks, friendly error message!")

But if you try this with some ABC, the error message is much less friendly!

>>> from some_library import SomeAbc
>>> issubclass('not a class', SomeAbc)
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/abc.py",
 line 230, in __subclasscheck__
cls._abc_negative_cache.add(subclass)
  File 
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_weakrefset.py",
 line 84, in add
self.data.add(ref(item, self._remove))
TypeError: cannot create weak reference to 'str' object

("WTF just went wrong?" Several more minutes of head-scratching ensues. Maybe a 
less experienced Python programmer who hits this hasn't seen weakrefs before 
and gets overwhelmed, maybe needlessly proceeding down a deep rabbit hole 
before realizing no knowledge of weakrefs was required to understand what they 
did wrong.)

Or how about this example:

>>> from collections import Reversible
>>> issubclass([1, 2, 3], Reversible)
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/abc.py",
 line 207, in __subclasscheck__
ok = cls.__subclasshook__(subclass)
  File 
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_collections_abc.py",
 line 305, in __subclasshook__
return _check_methods(C, "__reversed__", "__iter__")
  File 
"/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_collections_abc.py",
 line 73, in _check_methods
mro = C.__mro__
AttributeError: 'list' object has no attribute '__mro__'
Here you don't even get the same type of error (AttributeError rather than 
TypeError), which seems unintentionally inconsistent.

This trivial patch fixes this, and will hopefully save untold numbers of future 
Python programmers some time and headache.

Let me know if any further changes are required, and thanks in advance for 
reviewing.

--
messages: 313376
nosy: inada.naoki, izbyshev, jab, serhiy.storchaka
priority: normal
pull_requests: 5781
severity: normal
status: open
title: Improve issubclass() error checking and message
type: enhancement
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread Joshua Bronson

Change by Joshua Bronson :


--
nosy: +jab

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread INADA Naoki

Change 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



[issue30008] OpenSSL 1.1.0 deprecated functions

2018-03-06 Thread devurandom

Change by devurandom :


--
nosy: +devurandom

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread miss-islington

miss-islington  added the comment:


New changeset d824b4e4afbe9cf02310e39b14402fb2aa271f8f by Miss Islington (bot) 
in branch '3.7':
bpo-32999: Fix ABC.__subclasscheck__ crash (GH-6002)
https://github.com/python/cpython/commit/d824b4e4afbe9cf02310e39b14402fb2aa271f8f


--
nosy: +miss-islington

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread Joshua Bronson

Change by Joshua Bronson :


--
pull_requests: +5780

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5779

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread INADA Naoki

INADA Naoki  added the comment:


New changeset fc7df0e664198cb05cafd972f190a18ca422989c by INADA Naoki in branch 
'master':
bpo-32999: Fix ABC.__subclasscheck__ crash (GH-6002)
https://github.com/python/cpython/commit/fc7df0e664198cb05cafd972f190a18ca422989c


--

___
Python tracker 

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



Re: Layers of abstraction, was Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Ooomzay
On Wednesday, 7 March 2018 06:43:10 UTC, Ooomzay  wrote:
> On Tuesday, 6 March 2018 14:12:38 UTC, Peter Otten  wrote:
> > Chris Angelico wrote:
> > 
> > > On Tue, Mar 6, 2018 at 10:04 AM, Steven D'Aprano
> > >  wrote:
> > >> # Later.
> > >> if __name__ = '__main__':
> > >> # Enter the Kingdom of Nouns.
> > > 
> > > Don't you need a NounKingdomEnterer to do that for you?
> > 
> > No, for some extra flexibility there should be a NounKingdomEntererFactory 
> 
> For example open().
> 
> > -- which of course has to implement the AbstractNounKingdomEntererFactory 
> > interface. 
> 
> For example a PEP 343 "Context Manager".
> 
> In the swamplands of the pythonistas the one-eyed man is BDFL!
> 
> Amen.

Damn. That should have read:-

In the swamplands of the pythonistas the man with a badly leaking boat is BDFL.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Layers of abstraction, was Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Ooomzay
On Tuesday, 6 March 2018 14:12:38 UTC, Peter Otten  wrote:
> Chris Angelico wrote:
> 
> > On Tue, Mar 6, 2018 at 10:04 AM, Steven D'Aprano
> >  wrote:
> >> # Later.
> >> if __name__ = '__main__':
> >> # Enter the Kingdom of Nouns.
> > 
> > Don't you need a NounKingdomEnterer to do that for you?
> 
> No, for some extra flexibility there should be a NounKingdomEntererFactory 

For example open().

> -- which of course has to implement the AbstractNounKingdomEntererFactory 
> interface. 

For example a PEP 343 "Context Manager".

In the swamplands of the pythonistas the one-eyed man is BDFL!

Amen.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32969] Add more constants to zlib module

2018-03-06 Thread Xiang Zhang

Change by Xiang Zhang :


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



[issue32969] Add more constants to zlib module

2018-03-06 Thread miss-islington

miss-islington  added the comment:


New changeset 7592c0a686a80b9fbe2e6d519a486aca58b3260b by Miss Islington (bot) 
in branch '3.6':
bpo-32969: Expose some missing constants in zlib and fix the doc (GH-5988)
https://github.com/python/cpython/commit/7592c0a686a80b9fbe2e6d519a486aca58b3260b


--

___
Python tracker 

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



Re: LXML: can't register namespace

2018-03-06 Thread Steven D'Aprano
On Tue, 06 Mar 2018 23:03:15 -0500, Andrew Z wrote:

> Hello,
>  with 3.6 and latest greatest lxml:
> 
> from lxml import etree
> 
> tree = etree.parse('Sample.xml')
> etree.register_namespace('','http://www.example.com')

> it seems to not be happy with the empty tag . But i'm not sure why and
> how to go about it.

Have you tried using something other than the empty string?

In the interactive interpreter, what does 

help(etree.register_namespace) 

say?



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32969] Add more constants to zlib module

2018-03-06 Thread miss-islington

miss-islington  added the comment:


New changeset c4d77a661138debbbe584b8b08410afc8719a9b1 by Miss Islington (bot) 
in branch '3.7':
bpo-32969: Expose some missing constants in zlib and fix the doc (GH-5988)
https://github.com/python/cpython/commit/c4d77a661138debbbe584b8b08410afc8719a9b1


--
nosy: +miss-islington

___
Python tracker 

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



[issue32969] Add more constants to zlib module

2018-03-06 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5778

___
Python tracker 

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



[issue32969] Add more constants to zlib module

2018-03-06 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5777

___
Python tracker 

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



[issue32969] Add more constants to zlib module

2018-03-06 Thread Xiang Zhang

Xiang Zhang  added the comment:


New changeset bc3f2289b9007396bfb7f986bee477b6176c1822 by Xiang Zhang in branch 
'master':
bpo-32969: Expose some missing constants in zlib and fix the doc (GH-5988)
https://github.com/python/cpython/commit/bc3f2289b9007396bfb7f986bee477b6176c1822


--

___
Python tracker 

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



LXML: can't register namespace

2018-03-06 Thread Andrew Z
Hello,
 with 3.6 and latest greatest lxml:

from lxml import etree

tree = etree.parse('Sample.xml')
etree.register_namespace('','http://www.example.com')

causes:
Traceback (most recent call last):
  File "/home/az/Work/flask/tutorial_1/src/xml_oper.py", line 16, in

etree.register_namespace('','http://www.example.com')
  File "src/lxml/etree.pyx", line 203, in lxml.etree.register_namespace
(src/lxml/etree.c:11705)
  File "src/lxml/apihelpers.pxi", line 1631, in lxml.etree._tagValidOrRaise
(src/lxml/etree.c:35382)
ValueError: Invalid tag name ''

partial Sample.xml:


http://www.example.com;>
 
  



it seems to not be happy with the empty tag .
But i'm not sure why and how to go about it.

thank you
AZ
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33017] Special set-cookie setting will bypass Cookielib

2018-03-06 Thread LCatro

New submission from LCatro :

PoC (PHP Version):

 header('Set-Cookie: test=123; max-age=a');  //  PoC 1
 header('Set-Cookie: test=123; domain=;');  //  PoC 2
 header('Set-Cookie: test=123; version=a;');  //  PoC 3

PoC 1 will trigger int() convert string to number from max-age 
(lib/cookielib.py:1429).I give this value a string ,it will make except 

try:
v = int(v) #  lib/cookielib.py:1429
except ValueError:
_debug("   missing or invalid (non-numeric) value for "
  "max-age attribute")
bad_cookie = True
break  #  lib/cookielib.py:1434

PoC 2 is a domain None value (lib/cookielib.py:1412).Cookielib will discard 
current cookie record.
if k == "domain":  #  lib/cookielib.py:1411
if v is None:  #  lib/cookielib.py:1412
_debug("   missing value for domain attribute")
bad_cookie = True
break  #  lib/cookielib.py:1415

PoC 3 will trigger a int() convert except(lib/cookielib.py:1472).Cookielib will 
discard current cookie record too.
version = standard.get("version", None)  #  lib/cookielib.py:1469
if version is not None:
try:
version = int(version)  #  lib/cookielib.py:1472
except ValueError:
return None  # invalid version, ignore cookie

There are PoCs involve urllib and requests library .

Full Code Analysis (Chinese Version): 
https://github.com/lcatro/Python_CookieLib_0day

--
components: Library (Lib)
files: poc.php
messages: 313370
nosy: LCatro
priority: normal
severity: normal
status: open
title: Special set-cookie setting will bypass Cookielib
versions: Python 2.7
Added file: https://bugs.python.org/file47472/poc.php

___
Python tracker 

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



Re: Subprocess Startup Error

2018-03-06 Thread Terry Reedy

On 3/6/2018 6:00 PM, Jeremy Jamar St. Julien wrote:

Whenever I try to open the python shell it says IDLE’s subprocess didn’t make a 
connection.


You must be referring to IDLE's GUI Shell, not Python's normal console 
text (TUI?) shell or REPL.


IDLE normally runs its GUI in one process and your code in another 
process, connected by a socket.  The message means that the socket 
connection failed.


Everything worked fine yesterday and I haven’t done anything I think 
would cause this problem.


Something has done something somewhere.

Any way to fix this? I’ve tried repairing and redownloading

Start IDLE in a console with python -m idlelib (idlelib.idle on 2.7) and 
you *may* get an exception or other error message that explains the 
situation.  There are 5 to 10 known possible reasons.


What python binary are you running IDLE with?  (It is displayed on the 
first line of output when you start.)  Start normally and look, then 
start in the console and look, to make sure you are running the same 
Python both times.


--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


[issue8840] truncate() semantics changed in 3.1.2

2018-03-06 Thread A.M. Kuchling

Change by A.M. Kuchling :


--
keywords: +patch
pull_requests: +5776

___
Python tracker 

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



[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread INADA Naoki

INADA Naoki  added the comment:

> BTW, do TypeErrors related to weak references deserve any treatment? Isn't it 
> a kind of coincidence that the error raised due to usage of WeakSet in 
> issubclass(obj, ABC) is what we expect? (Sorry, I'm not familiar with 
> WeakSets).

Sorry, I can't get what is your point.
I don't want to change ABC behavior for now.  I want to make C implementation 
consistent with Python implementation, except some (unrealistic) corner cases.

--

___
Python tracker 

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



[issue33001] Buffer overflow vulnerability in os.symlink on Windows (CVE-2018-1000117)

2018-03-06 Thread Steve Dower

Steve Dower  added the comment:

FYI, the CVE number for this issue is CVE-2018-1000117.

--
title: Buffer overflow vulnerability in os.symlink on Windows -> Buffer 
overflow vulnerability in os.symlink on Windows (CVE-2018-1000117)

___
Python tracker 

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



[issue22674] RFE: Add signal.strsignal(): string describing a signal

2018-03-06 Thread Chris Rebert

Change by Chris Rebert :


--
nosy: +cvrebert

___
Python tracker 

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



Subprocess Startup Error

2018-03-06 Thread Jeremy Jamar St. Julien
Whenever I try to open the python shell it says IDLE’s subprocess didn’t make a 
connection. Everything worked fine yesterday and I haven’t done anything I 
think would cause this problem. Any way to fix this? I’ve tried repairing and 
redownloading
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33016] nt._getfinalpathname may use uninitialized memory

2018-03-06 Thread Eryk Sun

Eryk Sun  added the comment:

The inconsistent use of VOLUME_NAME_NT and VOLUME_NAME_DOS was addressed 
incidentally in issue 29734, but that issue is primarily about the handle 
leaked when GetFinalPathNameByHandleW fails. That said, you've cleanly 
addressed the handle leak in your PR also. I prefer the common cleanup approach 
that you've used here, rather than spreading the cleanup tasks around in 
blocks, where it can easily be overlooked.

The PR for issue 29734 also fixes some handle leaks related to 
win32_xstat_impl. Those leaks still need to be addressed for 3.7, and 
backported to 3.6.

--
nosy: +eryksun

___
Python tracker 

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



[issue33016] nt._getfinalpathname may use uninitialized memory

2018-03-06 Thread Alexey Izbyshev

Change by Alexey Izbyshev :


--
keywords: +patch
pull_requests: +5775
stage:  -> patch review

___
Python tracker 

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



Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Steven D'Aprano
On Tue, 06 Mar 2018 14:09:53 -0800, Ooomzay wrote:

> Unfortunately, despite having conquered it, without a _guarantee_ of
> this behaviour from the language, or at least one mainstream
> implementation, I will not invest in python again.

Oh well, so sad. See you later.


-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Chris Angelico
On Wed, Mar 7, 2018 at 9:09 AM, Ooomzay  wrote:
>> I'm not trying to dissuade you from using RAII in your own applications,
>> if it works for you, great.
>
> Unfortunately, despite having conquered it, without a _guarantee_ of this
> behaviour from the language, or at least one mainstream implementation,
> I will not invest in python again. Nor recommend any one else with a serious
> real world resource management application to do so. This was the original
> motive for my PEP.

What a pity Python will have to lose someone whose sole goal was to
write C++ code. Had you but chosen to write Python code instead, you
could have saved us all a hundred emails or so and just used the
'with' statement, same as the rest of us do. Considering that "real
world resource management" is *exactly* the purpose of the 'with'
statement, I honestly don't see what the problem is.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33016] nt._getfinalpathname may use uninitialized memory

2018-03-06 Thread Alexey Izbyshev

New submission from Alexey Izbyshev :

The first call of GetFinalPathNameByHandleW requests the required buffer size 
for the NT path (VOLUME_NAME_NT), while the second call receives the DOS path 
(VOLUME_NAME_DOS) in the allocated buffer. Usually, NT paths are longer than 
DOS ones, for example:

 NT path: \Device\HarddiskVolume2\foo
DOS path: \\?\C:\foo

Or, for UNC paths:

 NT path: \Device\Mup\server\share\foo
DOS path: \\?\UNC\server\share\foo

However, it is not always the case. A volume can be mounted to an arbitrary 
path, and if a drive letter is not assigned to such a volume, 
GetFinalPathNameByHandle will use the mount point path instead of C: above. 
This way, a DOS path can be longer than an NT path. Since the result of the 
second call is not checked properly, this condition won't be detected, 
resulting in an out-of-bounds access and use of uninitialized memory later.

Moreover, the path returned by GetFinalPathNameByHandle may change between the 
first and the second call, for example, because an intermediate directory was 
renamed. If the path becomes longer than buf_size, the same issue will occur.

--
components: Extension Modules, Windows
messages: 313366
nosy: izbyshev, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: nt._getfinalpathname may use uninitialized memory
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



Re: Bitstream -- Binary Data for Humans

2018-03-06 Thread Roel Schroeven

Sébastien Boisgérault schreef op 6/03/2018 10:23:
I had a look at the AIS message format from your link(https://en.wikipedia.org/wiki/Automatic_identification_system#Message_format) and this seems to be a nice use case; all the data components seem to be nicely aligned on the byte boundary ... until you see that the payload uses ASCII6(*), which I didn't know about. 


Thanks again for the info!


ASCII6 is only the first layer where your Bitstream could be useful. 
It's the easy part :).


The main work comes after that: decoding ASCII6 results in binary data 
which we need to decode into AIS messages. You can see the most 
important ones at https://navcen.uscg.gov/?pageName=AISMessagesA and 
https://navcen.uscg.gov/?pageName=AISMessagesAStatic but there are many 
more.


So for each message we first extract the first 6 bits, which tells us 
the message identifier. What we need to do afterwards depends on that 
message identifier. The links above describe how to deal with messages 
1, 2 and 3 (they are identical except for the message identifier; I 
don't know why there are 3 instead of just one) and 5. Basically it's 
things like 2 bits for this, next 30 bits for that, etc. That's where 
I'm hoping your Bitstream can really shine.


Also note, but now I'm getting off topic,  that we don't have to deal 
with the low-level data as is described in your link: that is handled by 
the AIS transponder or AIS receiver, from which we receive it using 
simple NMEA 0183 serial sentences: see 
https://en.wikipedia.org/w/index.php?title=NMEA_0183=828034316#Message_structure


--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

--
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Ooomzay

On Monday, 5 March 2018 23:06:53 UTC, Steven D'Aprano  wrote:
> On Mon, 05 Mar 2018 09:22:33 -0800, Ooomzay wrote:
> [...]
> > If you would like to have a shot at coding this without RAII, but
> > preserving the OO design, you will find that it is considerably
> > simpler than the with/context manager approach.
> 
> Preserving the OO design, you say? Okay, since my application apparently 
> isn't allowed to know that it is processing two files, I'll simply 
> delegate that to the object:
> 
> class C(A, B):
> def run(self):
> with open(self.a) as a:
> with open(self.b) as b:
> process(a, b)
> 
> # Later.
> if __name__ = '__main__':
> # Enter the Kingdom of Nouns.
> c = C()
> c.run()
> 
> There you go. Encapsulation and OO design.

1. This does not execute. It is only when you actually flesh out 
these deliberately minimal classes A, B & C with PEP232 paraphernalia
that we all be able to see clearly how much cleaner or messier 
things are with PEP232. 

2. Your Class C breaks A & B's encapsulation by inheriting rather than 
composing them. Apart from increasing coupling and preventing 
substitution, C contained A & B in this example to illustrate that there is 
no RAII related burden whatever_on this intermediate class as 
it manages no external resources directly. It does not even 
need to implement __del__.

3. You have assumed a single threaded application. Please imagine 
that A and B are classes managing some remote valves and maintain 
their own threads as well as a serial port for comms. And C is there to 
coordinate them towards some greater purpose.

If you would like to try and add PEP232 support to
classes A,B & C to the point that you can create
and destroy c = C() in an exception-safe way we may 
all learn something.

> I'm not trying to dissuade you from using RAII in your own applications, 
> if it works for you, great.

Unfortunately, despite having conquered it, without a _guarantee_ of this 
behaviour from the language, or at least one mainstream implementation, 
I will not invest in python again. Nor recommend any one else with a serious 
real world resource management application to do so. This was the original 
motive for my PEP.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33010] os.path.isdir() returns True for broken directory symlinks or junctions

2018-03-06 Thread Eryk Sun

Eryk Sun  added the comment:

Thanks for the quick feedback and pushing back on this. We just have a broken 
mount point, unlike in Unix where it's a regular directory. so you're right to 
just query the basic info for all directory reparse points, without 
special-casing mount points.

However, I do think a valid mount point is a directory. I don't see why 
os.path.ismount() returns true for a non-existent mount point, drive letter, or 
share. Is this just to avoid network access delays with unavailable mapped 
drives and shares? Also, because of the hard-coded UNC check in ismount(), we 
aren't supporting mount points in directories on shares. I think this needs 
work.

--

___
Python tracker 

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



[issue33000] IDLEX GUI consumes all RAM for scrollback buffer, uses 161Bytes / character stored

2018-03-06 Thread John Brearley

John Brearley  added the comment:

Hi Terry: The icon on my Win 7 desktop points to: "C:\WinPython\IDLEX (Python 
GUI).exe".

This was part of the 430MB installer file WinPython-64bit-3.6.4.0Qt5b4.exe from 
https://sourceforge.net/projects/winpython.

I attached a screen shot of IDLEX window & help about.

--
Added file: https://bugs.python.org/file47471/Python_IDLEX.png

___
Python tracker 

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



[issue33010] os.path.isdir() returns True for broken directory symlinks or junctions

2018-03-06 Thread Alexey Izbyshev

Alexey Izbyshev  added the comment:

Hmm, actually, my NFS example is probably bad. I've run an experiment, and 
stat() simply hangs in the case if the NFS server is down.

--

___
Python tracker 

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



[issue33010] os.path.isdir() returns True for broken directory symlinks or junctions

2018-03-06 Thread Alexey Izbyshev

Alexey Izbyshev  added the comment:

Thank you for the detailed response, Eryk!

> A mount point is always a directory, even if the volume isn't currently 
> available.

Do I understand correctly that you propose to additionally change 
os.path.exists() to return True for mount points with unavailable volumes? 
Сurrently, os.path.exists() (i.e, the underlying os.stat()) attempts to 
traverse them, and this would be consistent with os.path.isdir() if the latter 
were changed to traverse directory reparse points too (both would return False 
for such mount points). Is your idea to change the behavior to match POSIX in a 
similar case when, for example, the remote NFS server is down but stat() still 
works on the local mount point? If so, is this a new idea compared to the first 
paragraph of [1] where you say that non-link reparse points should always be 
traversed?

[1] https://github.com/python/cpython/pull/5998#discussion_r172402233

--

___
Python tracker 

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



[issue30235] Validate shutil supports path-like objects, update docs accordingly

2018-03-06 Thread Marco Rougeth

Change by Marco Rougeth :


--
keywords: +patch
pull_requests: +5774
stage: test needed -> patch review

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

> Doesn't that break when, for example, test methods are decorated with 
> unittest.mock.patch?

No, it shouldn't break them if you wrap async methods carefully.

Here's a metaclass that I wrote recently doing just that: 
https://github.com/Azure/azure-functions-python-worker/blob/9ed3f8acd45a264927ce11af64f5b495f0404032/azure/worker/testutils.py#L44-L63

--

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Petter S

Petter S  added the comment:

> Also, I personally subclassed TestCase in many of my projects specifically to 
> add async support.  To do that you have to use a metaclass to scan class' 
> namespace for 'async def' functions.

Doesn't that break when, for example, test methods are decorated with 
unittest.mock.patch?

--

___
Python tracker 

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



[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.

2018-03-06 Thread Berker Peksag

Change by Berker Peksag :


--
pull_requests:  -966

___
Python tracker 

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



[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.

2018-03-06 Thread Berker Peksag

Change by Berker Peksag :


--
pull_requests:  -594

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

> How is a separate base class better? :)

It's very explicit that way.

Also, I personally subclassed TestCase in many of my projects specifically to 
add async support.  To do that you have to use a metaclass to scan class' 
namespace for 'async def' functions.

Currently, unittest.TestCase doesn't have a metaclass.  If you add one to it, 
it might break all packages that were subclassing TestCase with a metaclass.


> If you accidentally add `async` to the front of a test method in a 
> TestCase-derived test class, you get mostly-silent success with an 
> easily-ignored warning about a coroutine not being awaited.

Well, what if you use trio or curio?  You add an 'async' keyword and get a 
cryptic error that some framework internals just broke.

So I'm strong -1 on the coroutine_runner attribute idea.

--

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Petter S

Petter S  added the comment:

It's good to see others with the same idea as me. I just wrote 
https://github.com/python/cpython/pull/6005/commits/4d7e1837f235687c875e985e97701609fc1ac458
 .

In my opinion, there is no need for another test class. I completely agree with 
Zachary Ware that the current TestCase class is more or less broken (or at 
least easily misused) with respect to coroutines.

Fixing TestCase would not break existing code. The customization of event loop 
would not be hard to add.

--
nosy: +Petter S

___
Python tracker 

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



[issue33015] Fix function cast warning in thread_pthread.h

2018-03-06 Thread Siddhesh Poyarekar

Change by Siddhesh Poyarekar :


--
keywords: +patch
pull_requests: +5773
stage:  -> patch review

___
Python tracker 

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



[issue33015] Fix function cast warning in thread_pthread.h

2018-03-06 Thread Siddhesh Poyarekar

New submission from Siddhesh Poyarekar :

The PyThread_start_new_thread function takes a void (*)(void *) as the function 
argument, which does not match with the pthread_create callback which has type 
void *(*)(void *).  I've got a fix for this that adds a wrapper function of the 
right type that subsequently calls the function passed to 
PyThread_start_new_thread.

PR coming up.

--
components: Build
messages: 313357
nosy: siddhesh
priority: normal
severity: normal
status: open
title: Fix function cast warning in thread_pthread.h
type: compile error

___
Python tracker 

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread Yury Selivanov

Change by Yury Selivanov :


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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread miss-islington

miss-islington  added the comment:


New changeset 387a055261267f5fafd2c12eafef49759c94704f by Miss Islington (bot) 
in branch '3.6':
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. 
(GH-6004)
https://github.com/python/cpython/commit/387a055261267f5fafd2c12eafef49759c94704f


--

___
Python tracker 

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



[issue33010] os.path.isdir() returns True for broken directory symlinks or junctions

2018-03-06 Thread Eryk Sun

Eryk Sun  added the comment:

Yes, it makes sense to call GetFileAttributes as the fast path, and then fall 
back on a slow path (i.e. create, query, close) for a directory reparse point. 
With GetFileInformationByHandleEx, the equivalent query is FileBasicInfo, which 
is available starting with Vista, so this could be backported to 3.5 if 
necessary. 

However, to be more consistent with POSIX, we need to first query 
FileAttributeTagInfo on the reparse point to get the reparse tag. If it's 
IO_REPARSE_TAG_MOUNT_POINT (junction) and the target is a volume name (i.e. 
"Volume{GUID}"), then we should return true. This can also be checked via 
GetVolumePathName, after normalizing the path, like how os.path.ismount() works 
on Windows (ntpath.py). A mount point is always a directory, even if the volume 
isn't currently available. OTOH, sometimes junctions are used as links instead, 
which is being addressed more generally by Vidar Fauske in issue 31226. There's 
potentially overlap here with Vidar's proposed _Py_is_reparse_link function.

More info on GetFileAttributes, if you're curious:

GetFileAttributes and GetFileAttributesEx are relatively cheap I/O calls. 
They're implemented by translating to a native NT path and calling 
NtQueryAttributesFile and NtQueryFullAttributesFile, respectively. These two 
system calls are optimized for network access. They use an open packet that 
that's query-only without reparsing. The I/O Manager's parse routine can thus 
use a local (fake) File object, the file system's corresponding fast I/O 
routine, and skip the normal cruft of working with an I/O request (i.e. 
IRP_MJ_CREATE, IRP_MJ_QUERY_INFORMATION, IRP_MJ_CLEANUP, and IRP_MJ_CLOSE). In 
the sample fastfat driver, these routines are respectively 
FatFastQueryBasicInfo [1] and FatFastQueryNetworkOpenInfo [2].

[1]: 
https://github.com/Microsoft/Windows-driver-samples/blob/aa6e0b36eb932099fa4eb950a6f5e289a23b6d6e/filesys/fastfat/fatdata.c#L933

[2]: 
https://github.com/Microsoft/Windows-driver-samples/blob/aa6e0b36eb932099fa4eb950a6f5e289a23b6d6e/filesys/fastfat/fatdata.c#L1272

--

___
Python tracker 

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread miss-islington

miss-islington  added the comment:


New changeset 112f799666bac1bdbb320840d5fda3132255eb5e by Miss Islington (bot) 
in branch '3.7':
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. 
(GH-6004)
https://github.com/python/cpython/commit/112f799666bac1bdbb320840d5fda3132255eb5e


--
nosy: +miss-islington

___
Python tracker 

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



[issue4173] PDF documentation: long verbatim lines are cut off at right hand side

2018-03-06 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

I just tested the PDF on the current version of the docs and this is no longer 
an issue.  The original example given wraps correctly on the PDF output.

--
nosy: +csabella
resolution:  -> works for me
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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Zachary Ware

Zachary Ware  added the comment:

How is a separate base class better? :)

Having a default coroutine runner on the standard TestCase means all you have 
to do to add async tests is tack an `async` onto the front of your method 
definition, and everything just works as it always has.  Making it a separate 
base class means you have to know about that base class, what it's called, and 
remember to derive your test class from it.  If you accidentally add `async` to 
the front of a test method in a TestCase-derived test class, you get 
mostly-silent success with an easily-ignored warning about a coroutine not 
being awaited.

--

___
Python tracker 

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



[issue32388] Remove cross-version binary compatibility

2018-03-06 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Yes, let's retarget to 3.8.

--
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

> Instead of a separate base class, what about an overridable 
> `coroutine_runner` attribute that defaults to `asyncio.run`?

How is that better?

--

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Zachary Ware

Zachary Ware  added the comment:

Instead of a separate base class, what about an overridable `coroutine_runner` 
attribute that defaults to `asyncio.run`?

--
nosy: +zach.ware

___
Python tracker 

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



[issue33000] IDLEX GUI consumes all RAM for scrollback buffer, uses 161Bytes / character stored

2018-03-06 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I did not close either window before looking at the Task Manager number.

Once your program is debugged, I cannot think of any advantage of running it 
through IDLE instead of directly with the Python interpreter.

Since you repeat 'IDLEX' I still do not know whether you are running IDLEX or 
IDLE itself.

--

___
Python tracker 

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



[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

I think the right approach would be to add an new base TestCase class: 
AsyncioTestCase.  There other frameworks that have different event loop 
implementations, so we can't assume that an `async def` test should always be 
executed by asyncio.

And you should use the `asyncio.run` function to run the coroutine.

--

___
Python tracker 

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



[issue32992] unittest: Automatically run coroutines in a loop

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

This is a duplicate of issue 32972. Let's move the discussion there.

--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> unittest.TestCase coroutine support

___
Python tracker 

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5772

___
Python tracker 

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:


New changeset 8a387219bdfb6ee34928d6168ac42ca559f11c9a by Yury Selivanov in 
branch 'master':
bpo-33009: Fix inspect.signature() for single-parameter partialmethods. 
(GH-6004)
https://github.com/python/cpython/commit/8a387219bdfb6ee34928d6168ac42ca559f11c9a


--

___
Python tracker 

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5771

___
Python tracker 

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



[issue32992] unittest: Automatically run coroutines in a loop

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

I think the right approach would be to add an new base TestCase class: 
AsyncioTestCase.

And you should use the `asyncio.run` function to run the coroutine.

--
nosy: +yselivanov

___
Python tracker 

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



[issue32992] unittest: Automatically run coroutines in a loop

2018-03-06 Thread Petter S

Change by Petter S :


--
keywords: +patch
pull_requests: +5770
stage:  -> patch review

___
Python tracker 

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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2018-03-06 Thread Steve Dower

Steve Dower  added the comment:

(That said, I didn't try again 3.7, so it may already be fixed there. But since 
we're still fixing problems with 3.6, we should do that one too.)

--

___
Python tracker 

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



[issue31349] Embedded initialization ignores Py_SetProgramName()

2018-03-06 Thread Steve Dower

Steve Dower  added the comment:

I just hit this myself (and embarrassingly, I recently touched this code 
everyone and forgot to fix this).

Hopefully I get a chance to get to it, but patches are certainly welcome and 
I'll happily aim to get them into 3.6 onwards.

--
versions: +Python 3.6, Python 3.8

___
Python tracker 

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



[issue33011] Embedded 3.6.4 distribution does not add script parent as sys.path[0]

2018-03-06 Thread Steve Dower

Steve Dower  added the comment:

This is the intentional design of the embedded distribution. You need to update 
the ._pth file to include the directories that have files that are part of your 
app - it's not meant for running random scripts, that's the job of the normal 
distribution.

The build script files are in Tools/msi with the other installer files, 
primarily make_zip.py, though that also gets used for the Nuget packages.

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread Yury Selivanov

Yury Selivanov  added the comment:

Yeah, that assertion needs to be tweaked a little bit.  Created a PR.

--

___
Python tracker 

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



[issue33009] Assertion failure in inspect.signature on unbound partialmethods

2018-03-06 Thread Yury Selivanov

Change by Yury Selivanov :


--
keywords: +patch
pull_requests: +5769
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



[issue33013] Underscore in str.format with x option

2018-03-06 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Thanks guys.

I really thought I tried '{0:_x}'.format(123456789), but I guess I hadn't.  
Good to know that using format(123456879, '_x) is better.

--

___
Python tracker 

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



[issue33014] Clarify doc string for str.isidentifier()

2018-03-06 Thread Sanyam Khurana

Sanyam Khurana  added the comment:

Hey David,

I'm working on this issue. Will submit a PR in a while :)

--
nosy: +CuriousLearner

___
Python tracker 

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



[issue32642] add support for path-like objects in sys.path

2018-03-06 Thread Brett Cannon

Brett Cannon  added the comment:

'make regen-all' should do it (but so will just running 'make -s -j' like
any old build of CPython).

On Mon, Mar 5, 2018, 12:43 Jay Yin,  wrote:

>
> Jay Yin  added the comment:
>
> I'm unsure how to regenerate the files that interact with the code for
> sys.path as travisCI states
> "
> Generated files not up to date
>  M Python/importlib_external.h
> "
> since my code changes some of how the importing is handled
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue32991] AttributeError in doctest.DocTestFinder.find

2018-03-06 Thread Jason R. Coombs

Change by Jason R. Coombs :


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



[issue33013] Underscore in str.format with x option

2018-03-06 Thread Eric V. Smith

Eric V. Smith  added the comment:

The format specifier (here, 'x') always goes last.

>>> '{0:_x}'.format(123456789)
'75b_cd15'

See https://docs.python.org/3/library/string.html#formatstrings for the details.

Serhiy is correct that it's often easier to use format() instead of ''.format() 
for testing things like this.

--
nosy: +eric.smith

___
Python tracker 

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



[issue33014] Clarify doc string for str.isidentifier()

2018-03-06 Thread David Beazley

New submission from David Beazley :

This is a minor nit, but the doc string for str.isidentifier() states:

Use keyword.iskeyword() to test for reserved identifiers such as "def" and 
"class".

At first glance, I thought that it meant you'd do this (doesn't work):

'def'.iskeyword()

As opposed to this:

import keyword
keyword.iskeyword('def')

Perhaps a clarification that "keyword" refers to the keyword module could be 
added.   Or better yet, just make 'iskeyword()` a string method ;-).

--
assignee: docs@python
components: Documentation
messages: 313335
nosy: dabeaz, docs@python
priority: normal
severity: normal
status: open
title: Clarify doc string for str.isidentifier()
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



[issue33013] Underscore in str.format with x option

2018-03-06 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

>>> format(123456789, '_x')
'75b_cd15'

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



Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Peter Otten
Chris Angelico wrote:

> On Wed, Mar 7, 2018 at 2:12 AM, Kirill Balunov 
> wrote:
>>
>>
>> 2018-03-06 17:55 GMT+03:00 Chris Angelico :
>>>
>>> On Wed, Mar 7, 2018 at 1:48 AM, Kirill Balunov 
>>> wrote:
>>> > Note: For some historical reasons as the first argument you can use
>>> > None instead of function, in this case the identity function is
>>> > assumed. That is, all elements of iterable that are false are removed
>>> > which is equivalent
>>> > to (item for item in iterable if item). Currently, for the same
>>> > purpose the
>>> > preferred form is `filter(bool, iterable)`.
>>> >
>>>
>>> I'd prefer to word it something like:
>>>
>>> If the first argument is None, the identity function is assumed. That
>>> is, all elements of the iterable that are false are removed; it is
>>> equivalent to (item for item in iterable if item). It is approximately
>>> equivalent to (but faster than) filter(bool, iterable).
>>>
>>> ChrisA
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>
>>
>> I do not want to seem rude and stubborn, but how much faster is it to
>> highlight or emphasize it:
>>
> 
> Timings mean little. Why do we write:
> 
> if lst:
> 
> instead of:
> 
> if bool(lst):
> 
> ? Because it's unnecessary and pointless to call bool() on something
> before using it in a boolean context. If that concept causes you
> problems, it's not the fault of the filter function; filter simply
> uses something in a boolean context.
> 
> So "the identity function" is more correct than "the bool() function".

Fun fact: CPython handles filter(bool) and filter(None) the same way, it 
sets the checktrue flag and chooses the fast path:

static PyObject *
filter_next(filterobject *lz)
{
PyObject *item;
PyObject *it = lz->it;
long ok;
PyObject *(*iternext)(PyObject *);
int checktrue = lz->func == Py_None || lz->func == (PyObject 
*)_Type;

iternext = *Py_TYPE(it)->tp_iternext;
for (;;) {
item = iternext(it);
if (item == NULL)
return NULL;

if (checktrue) {
ok = PyObject_IsTrue(item);
} else {
PyObject *good;
good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
if (good == NULL) {
Py_DECREF(item);
return NULL;
}
ok = PyObject_IsTrue(good);
Py_DECREF(good);
}
if (ok > 0)
return item;
Py_DECREF(item);
if (ok < 0)
return NULL;
}
}

If there were a built-in identity() function it could be treated the same 
way.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Chris Angelico
On Wed, Mar 7, 2018 at 2:33 AM, Kirill Balunov  wrote:
>
>
> 2018-03-06 17:55 GMT+03:00 Chris Angelico :
>>
>> If the first argument is None, the identity function is assumed. That
>> is, all elements of the iterable that are false are removed; it is
>> equivalent to (item for item in iterable if item). It is approximately
>> equivalent to (but faster than) filter(bool, iterable).
>>
>> ChrisA
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
>
> If you look in C source for `filter_next`
> https://github.com/python/cpython/blob/5d92647102fac9e116b98ab8bbc632eeed501c34/Python/bltinmodule.c#L593,
> there is a line:
>
> int checktrue = lz->func == Py_None || lz->func == (PyObject *)_Type;
>
> So the only difference between `filter(None, ls`) and `filter(bool, ls)` is
> LOAD_NAME vs LOAD_CONST and that `None` is checked before than `bool`.
>

Assuming that nobody's shadowed the name 'bool' anywhere, which has to
be checked for at run time. (Which is the job of LOAD_NAME.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Kirill Balunov
2018-03-06 17:55 GMT+03:00 Chris Angelico :

> If the first argument is None, the identity function is assumed. That
> is, all elements of the iterable that are false are removed; it is
> equivalent to (item for item in iterable if item). It is approximately
> equivalent to (but faster than) filter(bool, iterable).
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

If you look in C source for `filter_next`
https://github.com/python/cpython/blob/5d92647102fac9e116b98ab8bbc632eeed501c34/Python/bltinmodule.c#L593,
there is a line:

int checktrue = lz->func == Py_None || lz->func == (PyObject
*)_Type;

So the only difference between `filter(None, ls`) and `filter(bool, ls)` is
LOAD_NAME vs LOAD_CONST and that `None` is checked before than `bool`.


With kind regards,
-gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Chris Angelico
On Wed, Mar 7, 2018 at 2:12 AM, Kirill Balunov  wrote:
>
>
> 2018-03-06 17:55 GMT+03:00 Chris Angelico :
>>
>> On Wed, Mar 7, 2018 at 1:48 AM, Kirill Balunov 
>> wrote:
>> > Note: For some historical reasons as the first argument you can use None
>> > instead of function, in this case the identity function is assumed. That
>> > is, all elements of iterable that are false are removed which is
>> > equivalent
>> > to (item for item in iterable if item). Currently, for the same purpose
>> > the
>> > preferred form is `filter(bool, iterable)`.
>> >
>>
>> I'd prefer to word it something like:
>>
>> If the first argument is None, the identity function is assumed. That
>> is, all elements of the iterable that are false are removed; it is
>> equivalent to (item for item in iterable if item). It is approximately
>> equivalent to (but faster than) filter(bool, iterable).
>>
>> ChrisA
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
>
> I do not want to seem rude and stubborn, but how much faster is it to
> highlight or emphasize it:
>

Timings mean little. Why do we write:

if lst:

instead of:

if bool(lst):

? Because it's unnecessary and pointless to call bool() on something
before using it in a boolean context. If that concept causes you
problems, it's not the fault of the filter function; filter simply
uses something in a boolean context.

So "the identity function" is more correct than "the bool() function".

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32999] issubclass(obj, abc.ABC) causes a segfault

2018-03-06 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Could you please show examples with __suclasscheck__ returning True for 
non-class objects?

--

___
Python tracker 

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



[issue32991] AttributeError in doctest.DocTestFinder.find

2018-03-06 Thread Jason R. Coombs

Jason R. Coombs  added the comment:


New changeset 5a0c3987abd6a71b4fadeb525477eb5f560e8514 by Jason R. Coombs (Miss 
Islington (bot)) in branch '3.7':
bpo-32991: Restore expectation that inspect.getfile raises TypeError on 
namespace package (GH-5980) (GH-5997)
https://github.com/python/cpython/commit/5a0c3987abd6a71b4fadeb525477eb5f560e8514


--

___
Python tracker 

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



Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Kirill Balunov
2018-03-06 17:55 GMT+03:00 Chris Angelico :

> On Wed, Mar 7, 2018 at 1:48 AM, Kirill Balunov 
> wrote:
> > Note: For some historical reasons as the first argument you can use None
> > instead of function, in this case the identity function is assumed. That
> > is, all elements of iterable that are false are removed which is
> equivalent
> > to (item for item in iterable if item). Currently, for the same purpose
> the
> > preferred form is `filter(bool, iterable)`.
> >
>
> I'd prefer to word it something like:
>
> If the first argument is None, the identity function is assumed. That
> is, all elements of the iterable that are false are removed; it is
> equivalent to (item for item in iterable if item). It is approximately
> equivalent to (but faster than) filter(bool, iterable).
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I do not want to seem rude and stubborn, but how much faster is it to
highlight or emphasize it:

from random import randint
for i in [1, 10, 100, 1000, 1, 10]:
ls = [randint(0,1) for _ in range(i)]
%timeit [*filter(None, ls)]
%timeit [*filter(bool, ls)]
print()

272 ns ± 0.0346 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)
282 ns ± 0.0714 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)

283 ns ± 0.0645 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)
296 ns ± 0.116 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)

1.4 µs ± 1.32 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)
1.41 µs ± 4.05 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)

14.7 µs ± 40.1 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)
14.7 µs ± 23.2 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)

137 µs ± 186 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
137 µs ± 24.7 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)

1.32 ms ± 285 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
1.32 ms ± 908 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)

With kind regards,
-gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue20150] API change in string formatting with :s option should be documented in What's New.

2018-03-06 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

I believe this has been added to the 3.4 What's New already:

object.__format__() no longer accepts non-empty format strings, it now raises a 
TypeError instead. Using a non-empty string has been deprecated since Python 
3.2. This change has been made to prevent a situation where previously working 
(but incorrect) code would start failing if an object gained a __format__ 
method, which means that your code may now raise a TypeError if you are using 
an 's' format code with objects that do not have a __format__ method that 
handles it. See bpo-7994 for background

Closing as resolved.

--
nosy: +csabella
resolution:  -> fixed
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



[issue33013] Underscore in str.format with x option

2018-03-06 Thread Cheryl Sabella

New submission from Cheryl Sabella :

>From the doc 
>(https://docs.python.org/3/library/string.html#format-specification-mini-language):

> The '_' option signals the use of an underscore for a thousands separator for 
> floating point presentation types and for integer presentation type 'd'. For 
> integer presentation types 'b', 'o', 'x', and 'X', underscores will be 
> inserted every 4 digits. For other presentation types, specifying this option 
> is an error.

>>> '{0:_}'.format(123456789)
'123_456_789'
>>> '{0:x}'.format(123456789)
'75bcd15'
>>> '{0:x_}'.format(123456789)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: Invalid format specifier

What am I doing wrong?  I read the doc as saying that using `type` of `x` would 
result in the `_` separator to be inserted every 4 characters, so I was 
expecting the output to be '75b_cd15'.

Thanks!

--
messages: 313330
nosy: csabella
priority: normal
severity: normal
status: open
title: Underscore in str.format with x option
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue33005] 3.7.0b2 Interpreter crash in dev mode (or with PYTHONMALLOC=debug) with 'python -X dev -c 'import os; os.fork()'

2018-03-06 Thread STINNER Victor

STINNER Victor  added the comment:

> Thank you! I can confirm that git commit 
> 31e2b76f7bbcb8278748565252767a8b7790ff27 on the 3.7 branch fixes the issue 
> for me.

Cool. You can now continue your gevent tests using -X dev ;-)

--

___
Python tracker 

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



[issue33005] 3.7.0b2 Interpreter crash in dev mode (or with PYTHONMALLOC=debug) with 'python -X dev -c 'import os; os.fork()'

2018-03-06 Thread Jason Madden

Jason Madden  added the comment:

Thank you! I can confirm that git commit 
31e2b76f7bbcb8278748565252767a8b7790ff27 on the 3.7 branch fixes the issue for 
me.

--

___
Python tracker 

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



[issue33000] IDLEX GUI consumes all RAM for scrollback buffer, uses 161Bytes / character stored

2018-03-06 Thread John Brearley

John Brearley  added the comment:

Hi Terry: I am exploring the value of a language specific editor and runtime 
environment. Its definitely a large step up from Windows Notepad and Gnome 
Gedit. Perhaps some notes in the IDLEX documentation regarding the development 
versus production runtime usages would be in order?

Perhaps in your Win10 environment you get the memory back when you close the 
shell window. In Win7, you dont get the memory back until you close both 
windows.

--

___
Python tracker 

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



Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Chris Angelico
On Wed, Mar 7, 2018 at 1:48 AM, Kirill Balunov  wrote:
> Note: For some historical reasons as the first argument you can use None
> instead of function, in this case the identity function is assumed. That
> is, all elements of iterable that are false are removed which is equivalent
> to (item for item in iterable if item). Currently, for the same purpose the
> preferred form is `filter(bool, iterable)`.
>

I'd prefer to word it something like:

If the first argument is None, the identity function is assumed. That
is, all elements of the iterable that are false are removed; it is
equivalent to (item for item in iterable if item). It is approximately
equivalent to (but faster than) filter(bool, iterable).

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Kirill Balunov
2018-03-06 16:58 GMT+03:00 Jason Friedman :

>
> as a ordinary Python user I'd be interested in improvements to the
> documentation, including suggestions on real-world usage.
>

I'm just an ordinary user, just like you :)


> Kirill, taking deprecation/removal off the table, what changes would you
> recommend to the documentation?
>

My English is about basic level, so you may need to fix the spelling. But I
would write as follows:


filter(function, iterable)
Construct an iterator from those elements of iterable for which function
returns truthy values. iterable may be either a sequence, a container which
supports iteration, or an iterator.

Note that filter(function, iterable) is equivalent to the generator
expression (item for item in iterable if function(item)). In cases when
function corresponds to a simple lambda function a generator expression
should be preferred. For example, when it is necessary to eliminate all
multiples of three (x for x in range(100) if x % 3) should be used, instead
of filter(lambda x: x % 3, range(100))

See itertools.filterfalse() for the complementary function that returns
elements of iterable for which function returns false.

Note: For some historical reasons as the first argument you can use None
instead of function, in this case the identity function is assumed. That
is, all elements of iterable that are false are removed which is equivalent
to (item for item in iterable if item). Currently, for the same purpose the
preferred form is `filter(bool, iterable)`.

p.s.:
maybe _function_ should be changed to _callable_.

With kind regards,
-gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33008] urllib.request.parse_http_list incorrectly strips backslashes

2018-03-06 Thread Ned Deily

Change by Ned Deily :


--
nosy: +barry, orsenthil, r.david.murray

___
Python tracker 

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



[issue33005] 3.7.0b2 Interpreter crash in dev mode (or with PYTHONMALLOC=debug) with 'python -X dev -c 'import os; os.fork()'

2018-03-06 Thread STINNER Victor

STINNER Victor  added the comment:

Thanks Jason Madden for your bug report! I should now be fixed.

You might want to try the 3.7 or master branch until the next 3.7 release: PEP 
537 ("3.7.0 beta 3: 2018-03-26").

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8

___
Python tracker 

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



"except" and "subclasscheck" changed between CPython2 and 3

2018-03-06 Thread Youta TAKAOKA
Thank you, Steven.

> There is a feature-request to support that (as Python 2.7 does):
>
> https://bugs.python.org/issue12029
>
> but it is stalled.

I passed over the ticket.

Now, I know that this is a bug, but has not fixed yet.
There are (or ware ?) problems about performance and integrity for handling
exceptions.

It seems that a narrow range of use-cases cause the stalling.
Someday we have a type-focused VERY NICE library, (I hope that) it will be
resolved.

Thanks.

--
yout...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Layers of abstraction, was Re: RFC: Proposal: Deterministic Object Destruction

2018-03-06 Thread Peter Otten
Chris Angelico wrote:

> On Tue, Mar 6, 2018 at 10:04 AM, Steven D'Aprano
>  wrote:
>> # Later.
>> if __name__ = '__main__':
>> # Enter the Kingdom of Nouns.
> 
> Don't you need a NounKingdomEnterer to do that for you?

No, for some extra flexibility there should be a NounKingdomEntererFactory 
-- which of course has to implement the AbstractNounKingdomEntererFactory 
interface. Instantiating the right NounKingdomEntererFactory can easily be 
delegated to a NounKingdomEntererFactoryProducer. It's turtles^Wfactories 
all the way down...

I don't know how this will ever do anything -- my theory is that some good 
soul managed to sneak a few lines of javascript into the giant xml 
configuration file ;)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Kirill Balunov
2018-03-06 16:35 GMT+03:00 Chris Green :

> It's 'deprecation', depreciation is something quite different.  People
> replying have spelt it correctly so you might possibly have noticed I
> thought/hoped.
>
> ... and it does matter a bit because it's not just a mis-spelling, the
> word you are using has its own meaning and could thus cause confusion.
>
> ... and, yes, I know it's a very common and easily made mistake. :-)
>
>
I did not ;) Thank you!

With kind regards,
-gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Kirill Balunov
2018-03-06 16:51 GMT+03:00 Chris Angelico :

> On Wed, Mar 7, 2018 at 12:23 AM, Kirill Balunov 
> wrote:
> > Filter is generally faster than list comprehension or generators.
> >
> > %timeit [*filter(lambda x: x % 3, range(1000))]
> > 100 µs ± 16.4 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
> >
> > f = lambda x: x % 3
> >
> > %timeit [*(f(i) for i in range(1000))]
> > 132 µs ± 73.5 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
> >
> > %timeit [f(i) for i in range(1000)]
> > 107 µs ± 179 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
> >
>
> These don't do the same thing, though. A more comparable comprehension is:
>
> [i for i in range(1000) if i % 3]
>
> rosuav@sikorsky:~$ python3 -m timeit '[i for i in range(1000) if i % 3]'
> 1 loops, best of 5: 34.5 usec per loop
> rosuav@sikorsky:~$ python3 -m timeit '[*filter(lambda x: x % 3,
> range(1000))]'
> 5000 loops, best of 5: 81.1 usec per loop
>
> And my point about comprehensions was that you do NOT use a pointless
> function for them - you just have inline code. If there is a
> pre-existing function, sure! Use it. But when you use filter or map
> with a lambda function, you should probably use a comprehension
> instead.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Thank you, I did not understand you at first, now everything is clear. In
this sense of `x % 3`, I fully agree with you.

With kind regards,
-gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Jason Friedman
On Tue, Mar 6, 2018 at 1:52 AM, Kirill Balunov 
wrote:

>
> I propose to delete all references in the `filter` documentation that the
> first argument can be `None`, with possible depreciation of `None` as the
> the first argument - FutureWarning in Python 3.8+ and deleting this option
> in Python 4. Personally, regarding the last point - depreciation, I do not
> see this as a great necessity, but I do not find that the option with
> `None`
> should be offered and suggested through the documentation. Instead, it is
> better to show an example with using `filter(bool, iterable)` which is
> absolutely
> equivalent, more readable, but a little bit slower.
>
> Currently documentation for `None` case uses `identity function is
> assumed`, what is this `identity` and how it is consistent with
> truthfulness?
>
> In addition, this change makes the perception of `map` and `filter` more
> consistent,with the rule that first argument must be `callable`.
>
> I see only one moment with `None`, since `None` is a keyword, the behavior
> of `filter(None, iterable)` is alsways guaranteed, but with `bool` it is
> not. Nevertheless, we are all adults here.
>

I won't pretend I am qualified to debate the technical aspects here, but
regarding this snippet:

... Instead, it is better to show an example with using `filter(bool,
iterable)` which is absolutely equivalent, more readable ...

as a ordinary Python user I'd be interested in improvements to the
documentation, including suggestions on real-world usage.  For example,
Chris Angelico below says in part:

... that said, though, any use of filter() that involves a lambda
function should
probably become list comps or genexps, so filter itself should only be used
when ...

Kirill, taking deprecation/removal off the table, what changes would you
recommend to the documentation?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Chris Angelico
On Wed, Mar 7, 2018 at 12:23 AM, Kirill Balunov  wrote:
> Filter is generally faster than list comprehension or generators.
>
> %timeit [*filter(lambda x: x % 3, range(1000))]
> 100 µs ± 16.4 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
>
> f = lambda x: x % 3
>
> %timeit [*(f(i) for i in range(1000))]
> 132 µs ± 73.5 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
>
> %timeit [f(i) for i in range(1000)]
> 107 µs ± 179 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)
>

These don't do the same thing, though. A more comparable comprehension is:

[i for i in range(1000) if i % 3]

rosuav@sikorsky:~$ python3 -m timeit '[i for i in range(1000) if i % 3]'
1 loops, best of 5: 34.5 usec per loop
rosuav@sikorsky:~$ python3 -m timeit '[*filter(lambda x: x % 3, range(1000))]'
5000 loops, best of 5: 81.1 usec per loop

And my point about comprehensions was that you do NOT use a pointless
function for them - you just have inline code. If there is a
pre-existing function, sure! Use it. But when you use filter or map
with a lambda function, you should probably use a comprehension
instead.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Chris Green
Kirill Balunov  wrote:
> 
> As I wrote, __possible depreciation__, I also do not see the point of just

It's 'deprecation', depreciation is something quite different.  People
replying have spelt it correctly so you might possibly have noticed I
thought/hoped.

... and it does matter a bit because it's not just a mis-spelling, the
word you are using has its own meaning and could thus cause confusion.

... and, yes, I know it's a very common and easily made mistake. :-)

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33005] 3.7.0b2 Interpreter crash in dev mode (or with PYTHONMALLOC=debug) with 'python -X dev -c 'import os; os.fork()'

2018-03-06 Thread miss-islington

miss-islington  added the comment:


New changeset 31e2b76f7bbcb8278748565252767a8b7790ff27 by Miss Islington (bot) 
in branch '3.7':
bpo-33005: Fix _PyGILState_Reinit() (GH-6001)
https://github.com/python/cpython/commit/31e2b76f7bbcb8278748565252767a8b7790ff27


--
nosy: +miss-islington

___
Python tracker 

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



[issue33005] 3.7.0b2 Interpreter crash in dev mode (or with PYTHONMALLOC=debug) with 'python -X dev -c 'import os; os.fork()'

2018-03-06 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5768

___
Python tracker 

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



[issue33005] 3.7.0b2 Interpreter crash in dev mode (or with PYTHONMALLOC=debug) with 'python -X dev -c 'import os; os.fork()'

2018-03-06 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 5d92647102fac9e116b98ab8bbc632eeed501c34 by Victor Stinner in 
branch 'master':
bpo-33005: Fix _PyGILState_Reinit() (#6001)
https://github.com/python/cpython/commit/5d92647102fac9e116b98ab8bbc632eeed501c34


--

___
Python tracker 

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



  1   2   >