[issue32968] Fraction modulo infinity should behave consistently with other numbers

2018-03-14 Thread Elias Zamaria

Elias Zamaria  added the comment:

Mark, what you described (operator_fallbacks for both __rfloordiv__ and 
__floordiv__, and for both __rmod__ and __mod__) was my initial approach. But 
that broke one test (which floor-divides 1.0 by 1/10 and expects the result to 
be an integer). I thought about fixing it, to make the behavior more 
consistent, but I thought that was a bit risky.

Just now, I tried the change again, as you suggested, but I fixed the test to 
expect a result of 10.0 (a float) instead of 10 (an integer). I got a strange 
result from that test, saying the result was 9.0.

It seems like this is caused by rounding error, since operator_fallbacks 
converts both numbers to floats if one of them is a float, and 1/10 can't be 
represented exactly as a float, so it gets rounded to slightly more than 1/10:

>>> float(Fraction(1, 10)).as_integer_ratio()
(3602879701896397, 36028797018963968)
>>> Decimal.from_float(float(Fraction(1, 10)))
Decimal('0.155511151231257827021181583404541015625')

So yes, I can make that change, but I'm not sure if it would be a good idea. Do 
you have any thoughts?

--

___
Python tracker 

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



Re: urllib.request.urlopen fails with https

2018-03-14 Thread Chris Angelico
On Thu, Mar 15, 2018 at 3:54 PM, Gregory Ewing
 wrote:
> Chris Angelico wrote:
>>
>> That means going back to the original problem: "how do we get a usable
>> stock price API?".
>
>
> Does it have to be stock prices in particular?
> Or just some simple piece of data that demonstrates
> the principles of fetching a url and parsing the
> result?
>

You'd have to ask the OP, but if you make too big a change to the API
used, the rest of the course might have to change too. If the next
thing done with the downloaded data is to graph it, for instance, then
you'll need some other API that gives graphable data. Etcetera,
etcetera, etcetera.

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


[issue33057] logging.Manager.logRecordFactory is never used

2018-03-14 Thread Vinay Sajip

Vinay Sajip  added the comment:

The logRecordFactory attribute was added but never used and is part of an 
internal API (the Manager isn't documented, on purpose). Why do you need a 
manager-specific factory?

--

___
Python tracker 

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



Re: urllib.request.urlopen fails with https

2018-03-14 Thread Gregory Ewing

Chris Angelico wrote:

That means going back to the original problem: "how do we get a usable
stock price API?".


Does it have to be stock prices in particular?
Or just some simple piece of data that demonstrates
the principles of fetching a url and parsing the
result?

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


Re: Enumerating all 3-tuples (Posting On Python-List Prohibited)

2018-03-14 Thread Ben Bacarisse
Lawrence D’Oliveiro  writes:

> On Wednesday, March 14, 2018 at 2:18:24 PM UTC+13, Ben Bacarisse wrote:
>> Lawrence D’Oliveiro writes:
>> 
>> The original problem -- triples of natural numbers -- is
>> not particularly hard, but the general problem -- enumerating n-tuples
>> of some sequence -- is more interesting because it is a bit harder.
>
> It’s not harder--it’s exactly the same difficulty. You iterate the
> naturals, then interpose a function mapping them onto the set that you
> really want to use.

Yes, I said exactly that a couple of messages ago.

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


[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

2018-03-14 Thread Eric V. Smith

Change by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue32987] tokenize.py parses unicode identifiers incorrectly

2018-03-14 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

#24194 is about tokenize failing, including on middle dot.  There is another 
tokenize name issue, already closed.  I referenced Serhiy's analysis there and 
on the two \w issues, and closed one of them.

--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> tokenize fails on some Other_ID_Start or Other_ID_Continue

___
Python tracker 

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



[issue24194] tokenize fails on some Other_ID_Start or Other_ID_Continue

2018-03-14 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I closed #1693050 as a duplicate of #12731 (the /w issue).  I left #9712 closed 
and closed #32987 and marked both as duplicates of this.

In msg313814 of the latter, Serhiy indicates which start and continue 
identifier characters are currently matched by \W for re and regex.  He gives 
there a fix for this that he says requires the /w issue to be fixed. It is 
similar to the posted patch.  He says that without \w fixed, another 2000+ 
chars need to be added.  Perhaps the v0 patch needs more tests (I don't know.)

He also says that re support for properties, #12734,  would make things even 
better.

Three of the characters in the patch are too obscure for Firefox on Window2 and 
print as boxes.  Some others I do not recognize.  And I could not type any of 
them.  I thought we had a policy of using \u or \U escapes even in tests to 
avoid such problems.  (I notice that there are already non-ascii chars in the 
context.)

--
nosy: +terry.reedy
title: tokenize yield an ERRORTOKEN if an identifier uses Other_ID_Start or 
Other_ID_Continue -> tokenize fails on some Other_ID_Start or Other_ID_Continue
versions: +Python 3.7, Python 3.8 -Python 3.5

___
Python tracker 

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



[issue1693050] \w not helpful for non-Roman scripts

2018-03-14 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Whatever I may have said before, I favor supporting the Unicode standard for 
\w, which is related to the standard for identifiers.

This is one of 2 issues about \w being defined too narrowly.  I am somewhat 
arbitrarily closing this as a duplicate of #12731 (fewer digits ;-).

There are 3 issues about tokenize.tokenize failing on valid identifiers, 
defined as \w sequences whose first char is an identifier itself (and therefore 
a start char).  In msg313814 of #32987, Serhiy indicates which start and 
continue identifier characters are matched by \W for re and regex.  I am 
leaving #24194 open as the tokenizer name issue.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> tokenize yield an ERRORTOKEN if an identifier uses 
Other_ID_Start or Other_ID_Continue

___
Python tracker 

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



[issue12731] python lib re uses obsolete sense of \w in full violation of UTS#18 RL1.2a

2018-03-14 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Whatever I may have said before, I favor supporting the Unicode standard for 
\w, which is related to the standard for identifiers.

This is one of 2 issues about \w being defined too narrowly.  I am somewhat 
arbitrarily closing #1693050 as a duplicate of this (fewer digits ;-).

There are 3 issues about tokenize.tokenize failing on valid identifiers, 
defined as \w sequences whose first char is an identifier itself (and therefore 
a start char).  In msg313814 of #32987, Serhiy indicates which start and 
continue identifier characters are matched by \W for re and regex.  I am 
leaving #24194 open as the tokenizer name issue.

--
stage: needs patch -> test needed
versions: +Python 3.6, Python 3.7, Python 3.8 -Python 2.7, Python 3.3, Python 
3.4

___
Python tracker 

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



[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

2018-03-14 Thread Guido van Rossum

Guido van Rossum  added the comment:

Thanks Евгений Махмудов for the report!

The crux is this:

class A(NamedTuple):
value: bool = True

class B(A):
value: bool = False

B(True).value  # Expected True, but is False
B(True)[0]  # True as expected

If we add NamedTuple to B's bases or make its metaclass NamedTupleMeta, it 
works as expected.

Introspecting the classes a bit more suggests a cause: the class variable 
A.value is a , but B.value is just False, and adding the extra 
base class or metaclass corrects this.

Ivan, you can probably tell what's wrong from this.  Maybe it's hard to fix, 
because NamedTuple doesn't appear in A.__mro__?  (IIRC there was a question 
about that somewhere recently too?)

--

___
Python tracker 

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



[issue9712] tokenize yield an ERRORTOKEN if the identifier starts with a non-ascii char

2018-03-14 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Actually, #1693050 and #12731, about \w, are duplicates.

--

___
Python tracker 

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



[issue9712] tokenize yield an ERRORTOKEN if the identifier starts with a non-ascii char

2018-03-14 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Joshua opened #24194 as a duplicate of this because he could not reopen this.  
I am leaving it open as the superseder for this as Serhiy has already added two 
dependencies there, and because this seems to be a duplicate in turn of 
#1693050 (which I will close along with #32987).

--
nosy: +terry.reedy
superseder:  -> tokenize yield an ERRORTOKEN if an identifier uses 
Other_ID_Start or Other_ID_Continue

___
Python tracker 

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



Re: Restore via pip to new OS

2018-03-14 Thread Tim Johnson
* Paul Moore  [180314 15:42]:
> Use pip freeze rather than pip list. That will give you the
> information in  "requirements file" format that pip install -r can
> read.
> 
> On 14 March 2018 at 23:20, Tim Johnson  wrote:
<...>
> > Can I duplicate the same packages on the new OS by
> > pip -r piplist.txt?
  Thank you Paul.
  Cheers
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Restore via pip to new OS

2018-03-14 Thread Paul Moore
Use pip freeze rather than pip list. That will give you the
information in  "requirements file" format that pip install -r can
read.
Paul

On 14 March 2018 at 23:20, Tim Johnson  wrote:
> I'm currently running both python and python3 on ubuntu 14.04.
> Plan is to do a complete re-install of ubuntu 16.04 on a fresh
> hard drive.
>
> I've accumulated a list of pip-install packages via
> pip list > piplist.txt.
>
> Can I duplicate the same packages on the new OS by
> pip -r piplist.txt?
>
> thanks
> --
> Tim
> http://www.akwebsoft.com, http://www.tj49.com
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27984] singledispatch register should typecheck its argument

2018-03-14 Thread Xiang Zhang

Xiang Zhang  added the comment:

It's all right.

--

___
Python tracker 

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



[issue32227] singledispatch support for type annotations

2018-03-14 Thread Łukasz Langa

Change by Łukasz Langa :


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



Re: urllib.request.urlopen fails with https

2018-03-14 Thread Chris Angelico
On Thu, Mar 15, 2018 at 10:27 AM, Gregory Ewing
 wrote:
> Chris Angelico wrote:
>>
>> (Basically,
>> what you're doing is downgrading the protection of HTTPS to something
>> nearer plain HTTP. That's fine for what you're doing, but any code you
>> give to students is likely to be copied and pasted into their
>> production code.)
>>
>> See if you can tie in with your OS's cert store first. If you can't,
>> look at "import ssl" and creating a custom SSL context that doesn't
>> verify.
>
>
> That's likely to distract and confuse students as well.
>
> I would suggest looking for a different example that
> doesn't require interacting with an https site.

That means going back to the original problem: "how do we get a usable
stock price API?".

My preferred solution is to just install 'requests', of course.

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


Re: urllib.request.urlopen fails with https

2018-03-14 Thread Gregory Ewing

Chris Angelico wrote:

(Basically,
what you're doing is downgrading the protection of HTTPS to something
nearer plain HTTP. That's fine for what you're doing, but any code you
give to students is likely to be copied and pasted into their
production code.)

See if you can tie in with your OS's cert store first. If you can't,
look at "import ssl" and creating a custom SSL context that doesn't
verify.


That's likely to distract and confuse students as well.

I would suggest looking for a different example that
doesn't require interacting with an https site.

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


Restore via pip to new OS

2018-03-14 Thread Tim Johnson
I'm currently running both python and python3 on ubuntu 14.04.
Plan is to do a complete re-install of ubuntu 16.04 on a fresh
hard drive.

I've accumulated a list of pip-install packages via 
pip list > piplist.txt.

Can I duplicate the same packages on the new OS by
pip -r piplist.txt?

thanks
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

2018-03-14 Thread Ned Deily

Change by Ned Deily :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue33036] test_selectors.PollSelectorTestCase failing on macOS 10.13.3

2018-03-14 Thread Ned Deily

Ned Deily  added the comment:

I'm not sure what to suggest other than taking a close look at and 
instrumenting that part of test_selectors.  One thing you could try is seeing 
what the call to resource.getrlimit(resource.RLIMIT_NOFILE) is returning.  You 
can also look at the values for your system's kernel by using the sysctl 
utility; see man sysctl.  For example, on my system:

>>> resource.getrlimit(resource.RLIMIT_NOFILE)
(7168, 9223372036854775807)

$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 36864

That may or may not be relevant.

Long shot: are you running under an account that does not have administrator 
privs?

--

___
Python tracker 

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



Re: urllib.request.urlopen fails with https (was: Re: Stock quote APi)

2018-03-14 Thread Chris Angelico
On Thu, Mar 15, 2018 at 9:04 AM, Irv Kalb  wrote:
> ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
> (_ssl.c:749)
>
> Am I doing something wrong?  Is there another way (besides using the requests 
> module which DOES work for me) to get data from an https URL?

So my reading of this is that you have a major issue with root
certificates. Bleh. The normal response is "use pip to install
something that has your certs", but if you really absolutely cannot do
that, you may have to just disable certificate verification. This is
NOT a good thing to do, and you should have a big noisy comment
explaining why you have to make your code insecure. Put that RIGHT
next to the code that disables verification, so that if anyone copies
and pastes it, they'll have a good chance of seeing it. (Basically,
what you're doing is downgrading the protection of HTTPS to something
nearer plain HTTP. That's fine for what you're doing, but any code you
give to students is likely to be copied and pasted into their
production code.)

See if you can tie in with your OS's cert store first. If you can't,
look at "import ssl" and creating a custom SSL context that doesn't
verify.

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


[issue32227] singledispatch support for type annotations

2018-03-14 Thread Xiang Zhang

Change by Xiang Zhang :


--
pull_requests: +5882
stage:  -> patch review

___
Python tracker 

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



[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

2018-03-14 Thread Евгений Махмудов

New submission from Евгений Махмудов :

Overwriting of default values not working, and used default value of base 
class. Unittest file if attachment described a problem.

--
components: Library (Lib)
files: python_test.py
messages: 313843
nosy: Евгений Махмудов
priority: normal
severity: normal
status: open
title: typing: Unexpected result with value of instance of class inherited from 
typing.NamedTuple
type: behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file47487/python_test.py

___
Python tracker 

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



[issue27984] singledispatch register should typecheck its argument

2018-03-14 Thread Łukasz Langa

Łukasz Langa  added the comment:

I'm sorry that you wasted your time on those pull requests, Xiang but:
- we cannot accept any new features for 3.6 and 3.7 anymore;
- the problem described in this issue is fixed, as you noticed yourself, by 
#32227.

The wrapper returned by the `@register` decorator is calling `dispatch()` with 
the first argument's `__class__`. It can only ever be invalid if somebody 
deliberately wrote something invalid to the object's `__class__`. It's 
extremely unlikely.

We should not slow down *calling* of all generic functions on the basis that 
somebody might pass a non-type straigh to `dispatch()`.

Cheryl, thanks for your help triaging the bug tracker! It might be a good idea 
to confirm with people on old issues whether moving the patch to a pull request 
is indeed the missing part of it getting merged. In this case it wasn't, I hope 
Xiang won't feel bad about me rejecting his pull requests after you pinged him 
for them.

--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> singledispatch support for type annotations

___
Python tracker 

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



urllib.request.urlopen fails with https (was: Re: Stock quote APi)

2018-03-14 Thread Irv Kalb
Thanks to Chris A and Roger C for their information.  Very helpful and I am 
working on both of their suggestions.  But now I've run into a new related 
problem.

I still am trying to get stock information using Standard Library calls for now 
(although I understand that the requests module makes this kind of thing very 
easy).

My general approach (Python 3) is to build up a URL by concatenating an 
parameters, and make a call to url.request.urlopen.  I then do a 'read' on what 
was returned. For example, in my class, I use the following code to get weather 
data from weatherman.org:

URL = 'http://api.openweathermap.org/data/2.5/weather?q=' + city + 
'=xml'+ '=' + API_KEY
response = urllib.request.urlopen(URL)
responseString = str(response.read())

I then have some code to parse out the pieces of the returned information.  
This works great and an excellent example of the power of using API's with 
Python.


In looking for a stock data API, Chris suggested  alpha vantage.co (and Roger 
made a nice suggestion as to how to parse it).  But when I use their API, I get 
an error:  

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
(_ssl.c:749)

I have tried a number of different API's and found that if the URL starts with 
'https', it always fails.  Even a simple example that I found here:  
https://pythonspot.com/urllib-tutorial-python-3/ 
  fails the same way.

Here's what I see when I try that example:

>>> import urllib.request
>>> html = urllib.request.urlopen('https://arstechnica.com').read()
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
 line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
 line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
 line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
 line 1026, in _send_output
self.send(msg)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
 line 964, in send
self.connect()
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
 line 1400, in connect
server_hostname=server_hostname)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 
401, in wrap_socket
_context=self, _session=session)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 
808, in __init__
self.do_handshake()
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 
1061, in do_handshake
self._sslobj.do_handshake()
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 
683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
(_ssl.c:749)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
html = urllib.request.urlopen('https://arstechnica.com').read()
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 223, in urlopen
return opener.open(url, data, timeout)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 526, in open
response = self._open(req, data)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 544, in _open
'_open', req)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 504, in _call_chain
result = func(*args)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py",
 line 1320, in do_open
raise URLError(err)
urllib.error.URLError: 
>>> 

All my tests return the same tracebacks.

Am I doing something wrong?  Is there another way (besides using the requests 
module which DOES work for me) to get data from an https URL?

Any help would be appreciated.

Thanks,

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


[issue33076] Trying to cleanly terminate a threaded Queue at exit of program raises an "EOFError"

2018-03-14 Thread Adrien

New submission from Adrien :

Hi.

I use a worker Thread to which I communicate trough a multiprocessing Queue. I 
would like to properly close this daemon thread when my program terminates, so 
I registered a "stop()" function using "atexit.register()".

However, this raises an "EOFError" because the multiprocessing module uses 
"atexit.register()" too and closes the Queue internal pipe connections before 
that my thread ends.

After scratching inside the multiprocessing module, I tried to summarize my 
understanding of the problem here: https://stackoverflow.com/a/49244528/2291710

I joined a demonstration script that triggers the bug with (at least) Python 
3.5/3.6 on both Windows and Linux.

The issue is fixable by forcing multiprocessing "atexit.register()" before mine 
with "import multiprocessing.queues", but this means I would rely on an 
implementation detail, and others dynamic calls made to "atexit.register()" 
(like one I saw in multiprocessing "get_logger()" for example) could break it 
again.
I first thought that "atexit.register()" could accept an optional "priority" 
argument, but every developers would probably want to be first. Could a subtle 
change be made however to guarantee that registered functions are executed 
before Python internal ones? As for now, the atexit statement "The assumption 
is that lower level modules will normally be imported before higher level 
modules and thus must be cleaned up later" is not quite true.

I do not know what to do with it, from what I know there is no way to achieve 
an automatic yet clean closure of such worker, so I would like to know if some 
kind of fix is possible for a future version of Python.

Thanks for your time.

--
components: Library (Lib)
files: bug.py
messages: 313841
nosy: Delgan
priority: normal
severity: normal
status: open
title: Trying to cleanly terminate a threaded Queue at exit of program raises 
an "EOFError"
type: behavior
versions: Python 3.5, Python 3.6
Added file: https://bugs.python.org/file47486/bug.py

___
Python tracker 

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



[issue33036] test_selectors.PollSelectorTestCase failing on macOS 10.13.3

2018-03-14 Thread Nathan Henrie

Nathan Henrie  added the comment:

Hmmm, still failing for me. I wonder if it's something specific to my machine.

```
git reset --hard 3.6 && make clean && git pull && ./configure --with-pydebug && 
make -j && ./python.exe -m unittest -v 
test.test_selectors.PollSelectorTestCase.test_above_fd_setsize
```

Related:

- https://bugs.python.org/issue18963
- https://bugs.python.org/issue21901

--

___
Python tracker 

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



Re: macOS specific - reading calendar information

2018-03-14 Thread Larry Martell
On Wed, Mar 14, 2018 at 4:31 PM, Jan Erik Moström  wrote:
> I've been trying to find some example of how to read calendar info on macOS
> but I haven't found anything ... I'm probably just bad at searching !!
>
> What I want to do is to read calendar info for a date range. Does anyone
> know of an example of how to do this?

What does 'read calendar info' mean? What exactly are you trying to read from?
-- 
https://mail.python.org/mailman/listinfo/python-list


macOS specific - reading calendar information

2018-03-14 Thread Jan Erik Moström
I've been trying to find some example of how to read calendar info on 
macOS but I haven't found anything ... I'm probably just bad at 
searching !!


What I want to do is to read calendar info for a date range. Does anyone 
know of an example of how to do this?


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


Re: TLSServer: certificate one request behind...

2018-03-14 Thread Fabiano Sidler
Thus wrote Fabiano Sidler:
> What's the reason for this? Please find attached my TLSServer.

Oh, sorry...! Apparently, the attachment has been stripped. Here inline:

=== tlsserver.py ===
from socketserver import ThreadingTCPServer,StreamRequestHandler
import ssl

class TLSServer(ThreadingTCPServer):
def __init__(self, *args, **kwargs):
super(TLSServer, self).__init__(*args, **kwargs)
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx.set_servername_callback(self.servername_callback)
ctx.check_hostname = False
self._ctx = ctx
def get_request(self):
s,a = super(TLSServer, self).get_request()
s = self._ctx.wrap_socket(s, server_side=True)
return s,a
def servername_callback(self, sock, req_hostname, cb_context):
return ssl.ALERT_DESCRIPTION_INTERNAL_ERROR


from OpenSSL import crypto as x509
from tempfile import NamedTemporaryFile

class SelfSigningServer(TLSServer):
def servername_callback(self, sock, req_hostname, cb_context):
key = x509.PKey()
key.generate_key(x509.TYPE_RSA, 2048)
cert = x509.X509()
subj = cert.get_subject()
subj.C  = 'CH'
subj.ST = 'ZH'
subj.L  = 'Zurich'
subj.O  = 'ACME Inc.'
subj.OU = 'IT dept.'
subj.CN = req_hostname
cert.set_version(0x02)
cert.set_serial_number(1000)
cert.gmtime_adj_notBefore(0)
cert.gmtime_adj_notAfter(10*365*24*60*60)
cert.set_issuer(subj)
cert.set_pubkey(key)
cert.sign(key, 'sha256')
certfile = NamedTemporaryFile()
keyfile = NamedTemporaryFile()
certfile.write(x509.dump_certificate(x509.FILETYPE_PEM, cert))
keyfile.write(x509.dump_privatekey(x509.FILETYPE_PEM, key))
certfile.seek(0)
keyfile.seek(0)
cb_context.load_cert_chain(certfile=certfile.name, 
keyfile=keyfile.name)
cb_context.set_servername_callback(self.servername_callback)
sock.context = cb_context
certfile.close()
keyfile.close()

class SelfSigningHandler(StreamRequestHandler):
def handle(self):
self.wfile.write(b'Hello World!\r\n')

server = SelfSigningServer(('localhost',1234), SelfSigningHandler)
server.serve_forever()
=== tlsserver.py ===

Thanks again!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25750] tp_descr_get(self, obj, type) is called without owning a reference to "self"

2018-03-14 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +5881

___
Python tracker 

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



[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-14 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

With Benjamin we've decided that this wouldn't happen in 2.7.  Performance 
improvements don't warrant a backport.

Thank you Nir for reporting and posting the patches!

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

___
Python tracker 

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



[issue31974] Cursor misbahavior with Tkinter 3.6.1/tk 8.5 Text on Mac Sierra

2018-03-14 Thread Ned Deily

Ned Deily  added the comment:

Update: for Python 3.6.5 and 3.7.0, there are new python.org 10.9+ installer 
variants that come with a built-in Tcl/Tk 8.6.8.  They are currently both 
available in testing pre-releases (3.6.5rc1 and 3.7.0b2):

https://www.python.org/download/pre-releases/

--

___
Python tracker 

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



[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-14 Thread Antoine Pitrou

Antoine Pitrou  added the comment:


New changeset d6e140466142018ddbb7541185348be2b833a2ce by Antoine Pitrou 
(Zackery Spytz) in branch 'master':
bpo-33021: Fix GCC 7 warning (-Wmaybe-uninitialized) in mmapmodule.c (#6117)
https://github.com/python/cpython/commit/d6e140466142018ddbb7541185348be2b833a2ce


--

___
Python tracker 

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



Re: matplotlib icon

2018-03-14 Thread Terry Reedy

On 3/14/2018 2:30 PM, tedo.vrba...@gmail.com wrote:

I am getting this logging.INFO notice:
Could not load matplotlib icon: bad option "foobar": must be aspect, 
attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, 
geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, 
iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, 
resizable, sizefrom, stackorder, state, title, transient, or withdraw
I even set icon, but this notice remains.
There's nothing on web or in matplotlib documentation.
Python 2.7, Debian


We need more context, such as the code that emits the warning, to be 
sure of anything.  However, some code apparently tries to modify 
non-existent option 'foobar' on, I suspect, a GUI widget.  I have seen 
similar messages from tkinter/tk.


The option mistake prevents the icon load.

--
Terry Jan Reedy

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


[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-14 Thread Zackery Spytz

Zackery Spytz  added the comment:

Commit 4484f9dca9149da135bbae035f10a50d20d1cbbb causes GCC 7.2.0 to emit a 
warning.

cpython/Modules/mmapmodule.c: In function ‘new_mmap_object’:
cpython/Modules/mmapmodule.c:1126:18: warning: ‘fstat_result’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
 if (fd != -1 && fstat_result == 0 && S_ISREG(status.st_mode)) {

A PR is attached.

--
nosy: +ZackerySpytz

___
Python tracker 

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



[issue33021] Some fstat() calls do not release the GIL, possibly hanging all threads

2018-03-14 Thread Zackery Spytz

Change by Zackery Spytz :


--
pull_requests: +5880

___
Python tracker 

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



[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
status: open -> closed

___
Python tracker 

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



[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Ivan Levkivskyi

Change by Ivan Levkivskyi :


--
resolution:  -> not a bug
stage:  -> resolved

___
Python tracker 

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



[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Guido van Rossum

Guido van Rossum  added the comment:

This bug report can be closed.

--

___
Python tracker 

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



matplotlib icon

2018-03-14 Thread tedo . vrbanec
I am getting this logging.INFO notice:
Could not load matplotlib icon: bad option "foobar": must be aspect, 
attributes, client, colormapwindows, command, deiconify, focusmodel, forget, 
frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, 
iconphoto, iconposition, iconwindow, manage, maxsize, minsize, 
overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, 
state, title, transient, or withdraw
I even set icon, but this notice remains.
There's nothing on web or in matplotlib documentation.
Python 2.7, Debian
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33057] logging.Manager.logRecordFactory is never used

2018-03-14 Thread Ben Feinstein

Ben Feinstein  added the comment:

Here is a code that demonstrate the bug:

```python
import logging

class LogRecordTypeFilter(logging.Filter):
def __init__(self, cls):
self.cls = cls

def filter(self, record):
t = type(record)
if t is not self.cls:
msg = 'Unexpected LogRecord type %s, expected %s' % (t, self.cls)
raise TypeError(msg)
return True

class MyLogRecord(logging.LogRecord):
pass

manager = logging.Manager(None)
manager.setLogRecordFactory(MyLogRecord)
logger = manager.getLogger('some_logger')
logger.addFilter(LogRecordTypeFilter(MyLogRecord))

try:
logger.error('bpo-33057')
except TypeError as e:
print(e)  # output: Unexpected LogRecord type , 
expected 
```

--

___
Python tracker 

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



[issue32968] Fraction modulo infinity should behave consistently with other numbers

2018-03-14 Thread Mark Dickinson

Mark Dickinson  added the comment:

Thanks for the PR (and apologies for being slow to look at it). I think we want 
to use the operator_fallbacks approach for both __rfloordiv__ and __floordiv__ 
(and similarly for __rmod__ and __mod__), else we'll get inconsistent results:

>>> Fraction(3) // 5.0  # get float, as expected
0.0
>>> 3.0 // Fraction(5)  # expect a float, get an integer
0

Please could you make that change and add a couple more tests that cover this 
case?

--

___
Python tracker 

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



[issue26450] make html fails on OSX

2018-03-14 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

With the new instructions for building the docs via `make venv` and then `make 
html`, I believe this issue can be closed.

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



[issue27910] Doc/library/traceback.rst — references to tuples should be replaced with new FrameSummary object

2018-03-14 Thread Tomas Orsava

Tomas Orsava  added the comment:

Hey Cheryl,
here is the pull request: https://github.com/python/cpython/pull/6116

--

___
Python tracker 

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



[issue27910] Doc/library/traceback.rst — references to tuples should be replaced with new FrameSummary object

2018-03-14 Thread Tomas Orsava

Change by Tomas Orsava :


--
pull_requests: +5879
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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2018-03-14 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 6e65e4462692cbf4461c307a411af7cf40a1ca4a by Christian Heimes 
(Miss Islington (bot)) in branch '3.7':
[3.7] bpo-32885: Tools/scripts/pathfix.py: Add -n option for no backup~ 
(GH-5772) (#6103)
https://github.com/python/cpython/commit/6e65e4462692cbf4461c307a411af7cf40a1ca4a


--

___
Python tracker 

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



[issue32885] Tools/scripts/pathfix.py leaves bunch of ~ suffixed files around with no opt-out

2018-03-14 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset a954919788f2130076e4f9dd91e9eccf69540f7a by Christian Heimes 
(Miss Islington (bot)) in branch '3.6':
[3.6] bpo-32885: Tools/scripts/pathfix.py: Add -n option for no backup~ 
(GH-5772) (#6104)
https://github.com/python/cpython/commit/a954919788f2130076e4f9dd91e9eccf69540f7a


--

___
Python tracker 

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



[issue1647489] zero-length match confuses re.finditer()

2018-03-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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



[issue25054] Capturing start of line '^'

2018-03-14 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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



Re: Python gotcha of the day

2018-03-14 Thread Brian Oney via Python-list
explicit is better than implicit.

That gives me an idea for a module with the following debugging command line 
functionality.

import sass

>>> "" ":p"
Traceback: 
Are you telling me that ' ' is supposed to an operator? (Rock thrown)




On March 14, 2018 10:40:38 AM GMT+01:00, Thomas Jollans  wrote:
>On 2018-03-14 05:08, Steven D'Aprano wrote:
>> Explain the difference between these two triple-quoted strings:
>> 
>> Here is a triple-quoted string containing spaces and a triple-quote:
>> 
>> py> """ \""" """
>> ' """ '
>> 
>> 
>> But remove the spaces, and two of the quotation marks disappear:
>> 
>> py> """\""
>> '"'
>> 
>> 
>> If nobody gets the answer, I shall reveal all later.
>> 
>> (Hint: it is not a bug.)
>> 
>
>Ah, subtle!
>
>Initially I thought the first one was being interpreted as
>
>''' """ '''
>
>and the second one as
>
>"" '"' "" ""
>
>which left me rather puzzled as to why the first wasn't being
>interpreted as
>
>"" ' "' " " ""
>
>but of course that's not what's going on at all. The second one is
>
>'''"''' ""
>
>As to WHY - in both your examples, the literal can be interpreted as a
>triple-quoted string, so it is (rather than some combination of
>single-quoted strings). And, in both cases, the SHORTEST possible
>reading as a triple-quoted string is used.
>
>There, now I can go back to work.
>
>- Thomas
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

This is actually an intended behaviour. Moreover, the implicit optionality of 
arguments that default to `None` is deprecated and will be removed in one of 
the future versions. (Note that since typing module is still provisional, this 
will likely happen without any additional notice.)

--

___
Python tracker 

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



[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Ned Deily

Change by Ned Deily :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue33069] Maintainer information discarded when writing PKG-INFO

2018-03-14 Thread Paul Ganssle

Paul Ganssle  added the comment:

One thing that's unclear to me is whether PKG-INFO metadata spec should be 
considered exhaustive or whether you can add additional fields and still be 
considered compliant with the spec. If the latter is true, I think there's some 
case to be made for populating Maintainer: and Maintainer-Email: even in a 
purely Metadata-Version: 1.1 PKG-INFO file.

--

___
Python tracker 

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



[issue33069] Maintainer information discarded when writing PKG-INFO

2018-03-14 Thread Éric Araujo

Éric Araujo  added the comment:

I think that the proposed change is a good thing in itself, but if distutils 
only supports metadata 1.1 then it should comply with that spec.

I expect most projects to be using setuptools these days (to support wheels for 
one thing), so keeping distutils unchanged and fixing setuptools may be the 
best path.

--

___
Python tracker 

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



[issue5441] Convenience API for timeit.main

2018-03-14 Thread Jeremy Metz

Jeremy Metz  added the comment:

More specifically, #6422 also mentions at least in part this functionality, but 
the main focus there seems to be the autorange function. 

Propose splitting these two by reopening this use.

--

___
Python tracker 

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



[issue33069] Maintainer information discarded when writing PKG-INFO

2018-03-14 Thread Paul Ganssle

Paul Ganssle  added the comment:

@ncoghlan Yes, setuptools is affected. I've reported it there as well: 
https://github.com/pypa/setuptools/issues/1288

I have patches for both distutils and setuptools prepared. The distutils patch 
is more controversial because this is apparently the documented behavior of PEP 
314's Metadata Version 1.1, and distutils doesn't really have support for any 
of the *other* features of Version 1.2. You can see the concern (mostly on my 
side, frankly) on the PR, GH PR #6106.

--

___
Python tracker 

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



[issue33042] New 3.7 startup sequence crashes PyInstaller

2018-03-14 Thread Nick Coghlan

Nick Coghlan  added the comment:

While I haven't definitely narrowed it down yet, I suspect it isn't your 
changes that are the problem: since the reported crash relates to attempting to 
access a not-yet-created thread state, `warnoptions` and `_xoptions` likely 
need to become C level globals again for 3.7 (along with anything needed to 
create list and Unicode objects).

We can then transfer them from there into Eric's new runtime state objects in 
_PyRuntime_Initialize (or potentially _Py_InitializeCore).

--

___
Python tracker 

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



[issue5441] Convenience API for timeit.main

2018-03-14 Thread Jeremy Metz

Jeremy Metz  added the comment:

Don't understand how #6422 addresses this - would also like to see a more 
convenient API for timing; at present CLI gives a nice formatted output, and 
timeit.timeit gives just the raw timing in seconds. 

Would be easy to implement by simply refactoring main() in to the command line 
parsing component (first ~ 50 lines from 
https://github.com/python/cpython/blob/master/Lib/timeit.py#L256 to 
~https://github.com/python/cpython/blob/master/Lib/timeit.py#L312 ) and actual 
timing and printing component, which could then be called via API. 

Am happy to work this up if this can be reopened...?

--
nosy: +Jeremy Metz

___
Python tracker 

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



[issue33069] Maintainer information discarded when writing PKG-INFO

2018-03-14 Thread Nick Coghlan

Nick Coghlan  added the comment:

Thanks for the report and pull request. Do you happen to know if setuptools is 
also affected?

If yes, the problem will need to be reported & fixed there as well (otherwise 
the maintainer metadata will still be missing for many publishers), if no, then 
using it instead of plain distutils is a potential workaround in advance of the 
distutils fix rolling it.

--

___
Python tracker 

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



[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Vlad Shcherbina

Vlad Shcherbina  added the comment:

If the maintainers agree that it's desirable to automatically deduce 
optionality, I'll implement it.

--

___
Python tracker 

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




[issue33075] typing.NamedTuple does not deduce Optional[] from using None as default field value

2018-03-14 Thread Vlad Shcherbina

New submission from Vlad Shcherbina :

from typing import *

def f(arg: str = None):
pass
print(get_type_hints(f))

# {'arg': typing.Union[str, NoneType]}
# as expected


class T(NamedTuple):
field: str = None
print(get_type_hints(T))

# {'field': }
# but it should be
# {'field': typing.Union[str, NoneType]}
# for consistency

--
components: Library (Lib)
messages: 313819
nosy: vlad
priority: normal
severity: normal
status: open
title: typing.NamedTuple does not deduce Optional[] from using None as default 
field value
type: behavior
versions: Python 3.6, Python 3.7

___
Python tracker 

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



[issue27984] singledispatch register should typecheck its argument

2018-03-14 Thread Xiang Zhang

Change by Xiang Zhang :


--
pull_requests: +5878

___
Python tracker 

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



[issue27984] singledispatch register should typecheck its argument

2018-03-14 Thread Xiang Zhang

Change by Xiang Zhang :


--
pull_requests: +5877

___
Python tracker 

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



[issue27984] singledispatch register should typecheck its argument

2018-03-14 Thread Xiang Zhang

Xiang Zhang  added the comment:

Revising the patch, register() is fixed by feature in #32227. So I will only 
fix dispatch() in 3.7 and 3.8, the whole patch to 3.6.

--
versions: +Python 3.6

___
Python tracker 

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



TLSServer: certificate one request behind...

2018-03-14 Thread Fabiano Sidler
Hi folks!

I have written a TLSServer for testing purposes that generates
self-signed certificates upon request. This works pretty well
except that the certificates are always supplied one request too
late:

# gets no cert, but a handshake failure instead
$ openssl s_client -connect localhost:1234 -servername server1

# gets the cert for server1
$ openssl s_client -connect localhost:1234 -servername server2

# gets the cert for server2
$ openssl s_client -connect localhost:1234 -servername server3

What's the reason for this? Please find attached my TLSServer.

Best wishes,
Fabiano
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 2.7 EOL = 2020 January 1

2018-03-14 Thread Mark Lawrence

On 13/03/18 18:30, Tim Chase wrote:

On 2018-03-13 10:58, Terry Reedy wrote:

Two days later, Benjamin Peterson, the 2.7 release manager, replied
"Sounds good to me. I've updated the PEP to say 2.7 is completely
dead on Jan 1 2020." adding "The final release may not literally be
on January 1st".


Am I the only one saddened by this announcement?  I mean, it could
have been something like

"""
"VOOM"?!?  Mate, 2.7 wouldn't "voom" if you put four million volts
through it!  It's bleedin' demised!  It's not pinin'!  It's passed on!
This 2.x series is no more!  It has ceased to be!  It's expired and
gone to meet its maker!  It's a stiff!  Bereft of life, it rests in
peace!  If you hadn't nailed it to your dependencies it'd be pushing
up the daisies!  Its metabolic processes are now 'istory!  It's off
the twig!  It's kicked the bucket, it's shuffled off its mortal coil,
run down the curtain and joined the bleedin' choir invisible!!
THIS IS AN EX-VERSION!!
"""

Pythonically-yers,

-tkc




I'd still like to know what the core developers have ever done for us. 
Apart from .


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Enumerating all 3-tuples

2018-03-14 Thread Denis Kasak

On 2018-03-10 02:13, Steven D'Aprano wrote:


But I've stared at this for an hour and I can't see how to extend the
result to three coordinates. I can lay out a grid in the order I want:

1,1,1   1,1,2   1,1,3   1,1,4   ...
2,1,1   2,1,2   2,1,3   2,1,4   ...
1,2,1   1,2,2   1,2,3   1,2,4   ...
3,1,1   3,1,2   3,1,3   3,1,4   ...
2,2,1   2,2,2   2,2,3   2,2,4   ...
...

and applying Cantor's diagonal order will give me what I want, but 
damned

if I can see how to do it in code.


If you want this exact order, it can be reproduced in the following way.

The triples can be viewed as a pair of a pair and a natural number:

(1,1),1 (1,1),2 (1,1),3 ...
(2,1),1 (2,1),2 (2,1),3 ...
(1,2),1 (1,2),2 (1,2),3 ...
   .   .   .
   .   .   .
   .   .   .

Decomposing this by the diagonals yields

1: (1,1),1
2: (2,1),1  (1,1),2
3: (1,2),1  (2,1),2  (1,1),3
.
.
.

Notice that the first elements of each pair (i.e. the inner pairs) are 
given by the (inverse of the) original Cantor pairing function, in 
decreasing order. The second elements are just the natural numbers. 
Naming the inverse c, we can rewrite the above like this:


1: c(1),1
2: c(2),1  c(1),2
3: c(3),1  c(2),2  c(1),3
.
.
.

Rewriting this to spell out the mapping between the natural numbers and 
the pairs, we get


1 -> c(1),1
2 -> c(2),1
3 -> c(1),2
4 -> c(3),1
5 -> c(2),2
6 -> c(1),3
.
.
.

Squinting a bit, this might seem familiar. This is exactly the same as 
the original pairing function, except for an additional application of c 
to the first element of the pair!


1 -> 1,1
2 -> 2,1
3 -> 1,2
4 -> 3,1
5 -> 2,2
6 -> 1,3

This leads fairly naturally to the implementation.

from itertools import accumulate, count

def c(i):
"""
Inverse of the Cantor pairing function, mapping N → N×N.
"""
assert i >= 1

# partial sums of the series 1 + 2 + 3 + ...
sums = accumulate(count(1))
n = 0

while True:
m = next(sums)
if m < i:
n += 1
else:
r = m - i
break

return r + 1, n - r + 1


def c3(i):
"""
Inverse of the Cantor pairing function generalization to 
triples,

mapping N → N×N×N.
"""
n, m = c(i)
return c(n) + (m,)

Applying c3 to the natural numbers gives the sequence you wanted:


s = map(c3, count(1))
pprint([next(s) for _ in range(10)])

[(1, 1, 1),
 (2, 1, 1),
 (1, 1, 2),
 (1, 2, 1),
 (2, 1, 2),
 (1, 1, 3),
 (3, 1, 1),
 (1, 2, 2),
 (2, 1, 3),
 (1, 1, 4)]

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


[RELEASE] Python 3.6.5rc1 is now available for testing

2018-03-14 Thread Ned Deily
Announcing the immediate availability of Python 3.6.5 release candidate 1!

Python 3.6.5rc1 is the first release candidate for Python 3.6.5, the next
maintenance release of Python 3.6.  While 3.6.5rc1 is a preview release and,
thus, not intended for production environments, we encourage you to explore
it and provide feedback via the Python bug tracker (https://bugs.python.org).
3.6.5 is planned for final release on 2018-03-26 with the next maintenance
release expected to follow in about 3 months.  You can find Python 3.6.5rc1
and more information here:
https://www.python.org/downloads/release/python-365rc1/

Attention macOS users: as of 3.6.5rc1, there is a new additional installer
variant for macOS 10.9+ that includes a built-in version of Tcl/Tk 8.6.
This variant is expected to become the default variant in future releases.
Check it out!

--
  Ned Deily
  n...@python.org -- []

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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue33042] New 3.7 startup sequence crashes PyInstaller

2018-03-14 Thread STINNER Victor

STINNER Victor  added the comment:

I suggest to revert my changes on PySys_AddWarnOption*() and "just" re-use the 
code from Python 3.6.

Previously, I made the code more complex since I had to expose a private 
function to add manually warning options. But later, the code changed again, so 
the private function is gone.

--

___
Python tracker 

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



[issue33042] New 3.7 startup sequence crashes PyInstaller

2018-03-14 Thread Nick Coghlan

Nick Coghlan  added the comment:

After reworking the patch to backport the pre-initialization embedding tests to 
3.7.0a1, they *both* failed, as that was before Victor fixed Py_DecodeLocale to 
work prior to initialization again.

As a result, I tried 
https://github.com/python/cpython/commit/43605e6bfa8d49612df4a38460d063d6ba781906
 in November, after the initial merge of the PEP 432 working branch, but just 
before the start of Victor's follow on refactoring to really take advantage of 
the new internal structures: double failure there as well.

https://github.com/python/cpython/commit/f5ea83f4864232fecc042ff0d1c2401807b19280
 is the next point I checked (just before Eric's September changes to global 
state management), and it looks like we have a new chief suspect, as applying 
the attached "earlier-tree" version of the patch at this point in the history 
gives two passing test cases :)

Next I'll work out a git bisect run based on those two start and end commits 
and the "earlier-tree" patch, and attempt to narrow the failure down to a 
specific commit (probably tomorrow).


(Even without that bisect run though, the warnoptions changes in 
https://github.com/python/cpython/commit/2ebc5ce42a8a9e047e790aefbf9a94811569b2b6#diff-f38879f4833a6b6847e556b9a07bf4ed
 are now looking *very* suspicious)

--
Added file: 
https://bugs.python.org/file47485/bpo-33042-earlier-tree-test-case.diff

___
Python tracker 

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



[issue33042] New 3.7 startup sequence crashes PyInstaller

2018-03-14 Thread Nick Coghlan

Nick Coghlan  added the comment:

https://github.com/python/cpython/commit/b4d1e1f7c1af6ae33f0e371576c8bcafedb099db
 (the first attempted fix for bpo-20891) is the last commit where the draft 
test case patch applies cleanly.

That still segfaults, so I'll jump all the way back to 3.7.0a1, rework the 
patch to apply there, and see if pre-init use of these APIs were still working 
back then.

--

___
Python tracker 

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



Re: Python gotcha of the day

2018-03-14 Thread Thomas Jollans
On 2018-03-14 05:08, Steven D'Aprano wrote:
> Explain the difference between these two triple-quoted strings:
> 
> Here is a triple-quoted string containing spaces and a triple-quote:
> 
> py> """ \""" """
> ' """ '
> 
> 
> But remove the spaces, and two of the quotation marks disappear:
> 
> py> """\""
> '"'
> 
> 
> If nobody gets the answer, I shall reveal all later.
> 
> (Hint: it is not a bug.)
> 

Ah, subtle!

Initially I thought the first one was being interpreted as

''' """ '''

and the second one as

"" '"' "" ""

which left me rather puzzled as to why the first wasn't being interpreted as

"" ' "' " " ""

but of course that's not what's going on at all. The second one is

'''"''' ""

As to WHY - in both your examples, the literal can be interpreted as a
triple-quoted string, so it is (rather than some combination of
single-quoted strings). And, in both cases, the SHORTEST possible
reading as a triple-quoted string is used.

There, now I can go back to work.

- Thomas

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


[issue32987] tokenize.py parses unicode identifiers incorrectly

2018-03-14 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

This issue and issue12486 doesn't have any common except that both are related 
to the tokenize module.

There are two bugs: a too narrow definition of \w in the re module (see  
issue12731 and issue1693050) and a too narrow definition of Name in the 
tokenize module.


>>> allchars = list(map(chr, range(0x11)))
>>> start = [c for c in allchars if c.isidentifier()]
>>> cont = [c for c in allchars if ('a'+c).isidentifier()]
>>> import re, regex, unicodedata

>>> for c in regex.findall(r'\W', ''.join(start)): print('%r  U+%04X  %s' % (c, 
>>> ord(c), unicodedata.name(c, '?')))
... 
'℘'  U+2118  SCRIPT CAPITAL P
'℮'  U+212E  ESTIMATED SYMBOL
>>> for c in regex.findall(r'\W', ''.join(cont)): print('%r  U+%04X  %s' % (c, 
>>> ord(c), unicodedata.name(c, '?')))
... 
'·'  U+00B7  MIDDLE DOT
'·'  U+0387  GREEK ANO TELEIA
'፩'  U+1369  ETHIOPIC DIGIT ONE
'፪'  U+136A  ETHIOPIC DIGIT TWO
'፫'  U+136B  ETHIOPIC DIGIT THREE
'፬'  U+136C  ETHIOPIC DIGIT FOUR
'፭'  U+136D  ETHIOPIC DIGIT FIVE
'፮'  U+136E  ETHIOPIC DIGIT SIX
'፯'  U+136F  ETHIOPIC DIGIT SEVEN
'፰'  U+1370  ETHIOPIC DIGIT EIGHT
'፱'  U+1371  ETHIOPIC DIGIT NINE
'᧚'  U+19DA  NEW TAI LUE THAM DIGIT ONE
'℘'  U+2118  SCRIPT CAPITAL P
'℮'  U+212E  ESTIMATED SYMBOL
>>> for c in re.findall(r'\W', ''.join(start)): print('%r  U+%04X  %s' % (c, 
>>> ord(c), unicodedata.name(c, '?')))
... 
'ᢅ'  U+1885  MONGOLIAN LETTER ALI GALI BALUDA
'ᢆ'  U+1886  MONGOLIAN LETTER ALI GALI THREE BALUDA
'℘'  U+2118  SCRIPT CAPITAL P
'℮'  U+212E  ESTIMATED SYMBOL
>>> for c in re.findall(r'\W', ''.join(cont)): print('%r  U+%04X  %s' % (c, 
>>> ord(c), unicodedata.name(c, '?')))
... 
'·'  U+00B7  MIDDLE DOT
'̀'  U+0300  COMBINING GRAVE ACCENT
'́'  U+0301  COMBINING ACUTE ACCENT
'̂'  U+0302  COMBINING CIRCUMFLEX ACCENT
'̃'  U+0303  COMBINING TILDE
...
[total 2177 characters]

The second bug can be solved by adding 14 more characters in the pattern for 
Name.

Name = r'[\w\xb7\u0387\u1369-\u1371\u19da\u2118\u212e]+'

or

Name = r'[\w\u2118\u212e][\w\xb7\u0387\u1369-\u1371\u19da\u2118\u212e]*'

But first the issue with \w should be resolved (if we don't want to add 2177 
characters).

The other solution is implementing property support in re (issue12734).

--

___
Python tracker 

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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-14 Thread Nathan Henrie

Nathan Henrie  added the comment:

Awesome, I'm really excited to have contributed something, no matter how small.

--

___
Python tracker 

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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-14 Thread Ned Deily

Ned Deily  added the comment:

Thanks for the fix, Nathan.  Yury has already committed the fix for 3.6.5 and 
for 3.7.0.  I've just pushed PR 6112 and PR 6113 to forward port to the master 
branch (for 3.8) and to re-enable the failing tests on 3.7 and master.  Once 
they are merged, I think we can close this.

--
priority: release blocker -> 
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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-14 Thread Ned Deily

Change by Ned Deily :


--
pull_requests: +5876

___
Python tracker 

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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-14 Thread Ned Deily

Change by Ned Deily :


--
pull_requests: +5875

___
Python tracker 

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



[issue30622] Fix NPN guard for OpenSSL 1.1

2018-03-14 Thread Christian Heimes

Christian Heimes  added the comment:


New changeset 0ec0290a075ad3ac7d9990efd701c81da16293c0 by Christian Heimes in 
branch '3.6':
bpo-30622: Fix backport of NPN fix (#6102)
https://github.com/python/cpython/commit/0ec0290a075ad3ac7d9990efd701c81da16293c0


--

___
Python tracker 

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



[issue33074] dbm corrupts index on macOS (_dbm module)

2018-03-14 Thread Ned Deily

Change by Ned Deily :


--
components: +macOS
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

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



[issue33074] dbm corrupts index on macOS (_dbm module)

2018-03-14 Thread Robert Xiao

Robert Xiao  added the comment:

(Note: the contextlib stuff is just for Python 2 compatibility, it's not 
necessary on Python 3).

--

___
Python tracker 

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



[issue33074] dbm corrupts index on macOS (_dbm module)

2018-03-14 Thread Robert Xiao

New submission from Robert Xiao :

Environment: Python 3.6.4, macOS 10.12.6

Python 3's dbm appears to corrupt the key index on macOS if objects >4KB are 
inserted.

Code:

<<<
import dbm
import contextlib

with contextlib.closing(dbm.open('test', 'n')) as db:
for k in range(128):
db[('%04d' % k).encode()] = b'\0' * (k * 128)

with contextlib.closing(dbm.open('test', 'r')) as db:
print(len(db))
print(len(list(db.keys(
>>>

On my machine, I get the following:

<<<
94
Traceback (most recent call last):
  File "test.py", line 10, in 
print(len(list(db.keys(
SystemError: Negative size passed to PyBytes_FromStringAndSize
>>>

(The error says PyString_FromStringAndSize on Python 2.x but is otherwise the 
same). The expected output, which I see on Linux (using gdbm), is

128
128

I get this error with the following Pythons on my system:

/usr/bin/python2.6 - Apple-supplied Python 2.6.9
/usr/bin/python - Apple-supplied Python 2.7.13
/opt/local/bin/python2.7 - MacPorts Python 2.7.14
/usr/local/bin/python - Python.org Python 2.7.13
/usr/local/bin/python3.5 - Python.org Python 3.5.1
/usr/local/bin/python3.6 - Python.org Python 3.6.4

This seems like a very big problem - silent data corruption with no warning. It 
appears related to issue30388, but in that case they were seeing sporadic 
failures. The deterministic script above causes failures in every case.

This was discovered after running some code which used shelve (which uses dbm 
under the hood) in Python 3, but the bug clearly applies to Python 2 as well.

--
files: test.db
messages: 313809
nosy: nneonneo
priority: normal
severity: normal
status: open
title: dbm corrupts index on macOS (_dbm module)
versions: Python 2.7, Python 3.5, Python 3.6
Added file: https://bugs.python.org/file47484/test.db

___
Python tracker 

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



[issue30697] segfault in PyErr_NormalizeException() after memory exhaustion

2018-03-14 Thread Ned Deily

Ned Deily  added the comment:

It's been three months since Anthony raised the question about whether this was 
an acceptable ABI change in 3.6.4.  Since then, I am not aware of any reports 
of problems this has caused and there has been no agreement that it is a 
critical problem.  Since 3.6.5rc1 has now been released without this being 
resolved, I'm going to close this issue and hope for the best.  Thanks, 
everyone!  Feel free to reopen if a real life problem can be demonstrated.

--
priority: deferred blocker -> 
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



[issue33062] ssl_renegotiate() doesn't seem to be exposed

2018-03-14 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

> an OpenSSL cop-out

Perhaps, but they've been doing it this way for a decade+, and we're living in 
a time when other libraries like BoringSSL are flat-out removing renegotiation 
support, so good luck convincing them to fix things. Anyway, it's nothing to do 
with Python, just a friendly heads-up; I ran into this when trying to do 
renegotiation tests on my non-blocking code using the 'ssl' module and was 
*very* confused for a while until I realized it wasn't my code's fault at all.

--

___
Python tracker 

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