[issue41401] Using non-ascii that require UTF-8 breaks AIX testing

2020-07-29 Thread Michael Felt


Michael Felt  added the comment:

The 'master' branch bot is working again, the 3.9 branch is still broken, and 
the 3.8 branch seems, as yet, unaffected.

--

___
Python tracker 

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



[issue41411] Improve and consolidate f-strings docs

2020-07-29 Thread Ama Aje My Fren


Ama Aje My Fren  added the comment:

Hi,

Thanks Ezio for the detailed response.

> In the list of proposed solutions in my first message, 1-3 should be quite 
> easy to implement.  This leaves us with 4-5.

To the best of my seeing there are only two places in the documentation that 
have information about f-strings. The tutorial[0] and the reference[1]
I have done PR 21681 that adds index to the tutorial although searching[2][3] 
does not seem to be better now that the reference has an index.

> The lexical analysis is probably fine as is.
I agree.

> The introduction in the tutorial should mention f-strings 

This is there[0] but it _IS_ hard to find, when you don't know it is there.
It may not be very "introduction-y", and if you like I can make a go at trying 
to reword it.

> The stdtypes page is already quite long and crowded ...

True. But is this wrong? In my feeling this is reference documentation. It 
should be accurate, complete and clear. It may not need to be "textbook-like".

Some thoughts:
- There may be benefit in reorganising stdtypes.rst to improve the flow without 
changing the actual content. This could mean breaking it up into a number of 
documents rather than the monolith it is.
- It does feel like printf[4] was plugged in later because str.format()[5] had 
been explained earlier. (Although I believe printf came before str.format()). A 
first time reader of the document will find it hard to know the one way that is 
right when it comes to formatting.
- f-strings should probably also be described here because it _is_ built in, 
no? It may not be accurate to say it is in /Lib/strings. There is no reference 
that a developer can just look at to remind/confirm to themselves how to "do 
it".

> So, unless we add a separate page somewhere

This is why I was thinking of a HOWTO. Going back to your original pain in 
msg371912, someone wanted the f-string documentation and:
-- It was hard to find. (indexing? better table of contents?)
-- It was not very helpful WHEN it was found. (A second entry with f-strings in 
Lib that is easier for a dev to use?)

But now (and this is mainly to me) it appears that another problem is a need to 
consistently, clearly, and in one place describe the various 
elements/nuances/eccentricities of presenting data in Python: 
  - string
  - string.Formatter,
  - string.Template,
  - str.format()
  - f-string
  - Format Specification Mini-Language
  - maybe even __format__ and conversion?
  - etc

I propose one of the following two:
1) A new section in Library documentation just to handle strings, then 
systematically removing them elsewhere.(Built-In Functions, Built-In Types, 
Text Processing Services)
2) We take all that Python history and explain it in a HOWTO, and add a 
developer friendly reference in the Library for f-string. More like Logging 
Cookbook rather than Logging Howto.

!) above is similar to what you propose ... but different-ish.

[0] 
https://docs.python.org/dev/tutorial/inputoutput.html#formatted-string-literals
[1] https://docs.python.org/dev/reference/lexical_analysis.html#f-strings
[2] https://docs.python.org/dev/search.html?q=fstring
[3] https://docs.python.org/dev/search.html?q=f-string
[4] 
https://docs.python.org/dev/library/stdtypes.html#printf-style-bytes-formatting
[5] https://docs.python.org/dev/library/stdtypes.html#str.format

--

___
Python tracker 

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



[issue6143] IDLE - clear and restart the shell window

2020-07-29 Thread Zackery Spytz


Zackery Spytz  added the comment:

I have created PR 21682 to add a "Clear and Restart" item to the "Shell" menu.

--

___
Python tracker 

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



[issue6143] IDLE - clear and restart the shell window

2020-07-29 Thread Zackery Spytz


Change by Zackery Spytz :


--
nosy: +ZackerySpytz
nosy_count: 7.0 -> 8.0
pull_requests: +20826
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/21682

___
Python tracker 

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



[issue41436] BUG a simple "and" and "or"

2020-07-29 Thread Samran

Samran  added the comment:

Thanks a lot. I am beginner and will try stack overflow next time. Depending on 
the error type. Thank you again I learned a lot.

Sent from Mail for Windows 10

From: Karthikeyan Singaravelan
Sent: Wednesday, July 29, 2020 9:57 PM
To: iamsamra...@gmail.com
Subject: [issue41436] BUG a simple "and" and "or"

Karthikeyan Singaravelan  added the comment:

Below is the formatted program for easier reading. In the while clause you ask 
for the user to enter n to exit but you check (ch != n or ch != N) so on 
entering "n" the first condition is false but second clause is true. For "N" 
it's vice-versa. You want to continue the game as long as ch is not 'n' or "N'. 
Hence using not(ch == 'n' or ch == 'N') will help in exiting the program. This 
website is for bugs related to CPython itself. Please refer to stack overflow 
or other mailing lists in future.

Thanks.

from random import randint

num = randint(1, 10)

print(type(num))
print(num)

ch = None  # tried changing this tried converting types
guess = 0
print(type(guess))
print("Welcome to guessing game: ")

while (
ch != "n" or ch != "N"
):  # here is the bug this statement is not running. It works with “and”
while guess != num:
guess = int(input("Enter your guess?  "))
if guess == num:
print("You Guessed Congratz")
ch = input("Enter 'y' to play or 'n' to exit: ")
if ch == "y" or ch == "Y":
guess = 0
num = randint(1, 10)

print("Thankyou for playing.")

Fixed program : 

from random import randint

num = randint(1, 10)

print(type(num))
print(num)

ch = None  # tried changing this tried converting types
guess = 0
print(type(guess))
print("Welcome to guessing game: ")

while not (
ch == "n" or ch == "N"
):  # Play until the ch is not n or N 
while guess != num:
guess = int(input("Enter your guess?  "))
if guess == num:
print("You Guessed Congratz")
ch = input("Enter 'y' to play or 'n' to exit: ")
if ch == "y" or ch == "Y":
guess = 0
num = randint(1, 10)

print("Thankyou for playing.")

--
nosy: +jameshcorbett, xtreak
type: compile error -> behavior

___
Python tracker 

___

--

___
Python tracker 

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



[issue41436] BUG a simple "and" and "or"

2020-07-29 Thread Samran


Samran  added the comment:

Thanks a lot. I am beginner and will try stack overflow next time. Depending on 
the error type. Thank you again I learned a lot.

Sent from Mail for Windows 10

From: James Corbett
Sent: Wednesday, July 29, 2020 9:57 PM
To: iamsamra...@gmail.com
Subject: [issue41436] BUG a simple "and" and "or"

James Corbett  added the comment:

I think this would have been a better fit for a StackOverflow issue: 
https://stackoverflow.com/questions/tagged/python. Also, it's not a compilation 
error and it doesn't have anything to do with CPython's testing framework. 

Anyway, I don't think this is a bug. For a string `ch`, it is always true that 
either `ch != 'n'` or `ch != 'N'`---no string is equal to both `'N'` and `'n'`. 
Therefore your `while` condition will always be true and the loop will always 
continue.

As you already noted, your loop will terminate properly if you used `and`. You 
could also rewrite it as `while ch not in ('n', 'N'):` which I think is clearer.

--
nosy: +jameshcorbett

___
Python tracker 

___

--

___
Python tracker 

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



[issue41411] Improve and consolidate f-strings docs

2020-07-29 Thread Ama Aje My Fren


Change by Ama Aje My Fren :


--
pull_requests: +20825
pull_request: https://github.com/python/cpython/pull/21681

___
Python tracker 

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



[issue9625] argparse: Problem with defaults for variable nargs when using choices

2020-07-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Paul, what is your current thinking on this?

--

___
Python tracker 

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



[issue40841] Provide mimetypes.sniff API as stdlib

2020-07-29 Thread YoSTEALTH


YoSTEALTH  added the comment:

Start and end position of the signature must be accounted for, not all file 
signature start at ``0`` or ``< 512`` bytes

Rather then writing all the signatures manually might be a good idea to use 
already collected resource like 
https://www.garykessler.net/library/file_sigs.html

--
nosy: +YoSTEALTH

___
Python tracker 

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



[issue41438] TimeoutError behavior changes on async.wait_for from python3.7

2020-07-29 Thread Yury Selivanov


Yury Selivanov  added the comment:

> In python 3.8.4 running this script will print:

> asyncio.TimeoutError happened

This is the expected behavior in 3.8.

> This is a breaking change which I didn't see announced in the changelog.

Yeah, looks like this wasn't mentioned in what's new or elsewhere in the docs. 
:(

Do you want to submit a PR to fix that?

--

___
Python tracker 

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



[issue41437] SIGINT blocked by socket operations like recv on Windows

2020-07-29 Thread Eryk Sun


Eryk Sun  added the comment:

Winsock is inherently asynchronous. It implements synchronous functions by 
using an alertable wait for the completion of an asynchronous I/O request. 
Python doesn't implement anything for a console Ctrl+C event to alert the main 
thread when it's blocked in an alterable wait. NTAPI NtAlertThread will alert a 
thread in this case, but it won't help here because Winsock just rewaits when 
alerted. 

You need a user-mode asynchronous procedure call (APC) to make the waiting 
thread cancel all of its pended I/O request packets (IRPs) for the given file 
(socket) handle. Specifically, open a handle to the thread, and call 
QueueUserAPC to queue an APC to the thread that calls WinAPI CancelIo on the 
file handle. (I don't suggest using the newer CancelIoEx function from an 
arbitrary thread context in this case. It would be simpler than queuing an APC 
to the target thread, but you don't have an OVERLAPPED record to cancel a 
specific IRP, so it would cancel IRPs for all threads.)

Here's a context manager that temporarily sets a Ctrl+C handler that implements 
the above suggestion:

import ctypes
import threading
import contextlib

kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)

CTRL_C_EVENT = 0
THREAD_SET_CONTEXT = 0x0010

@contextlib.contextmanager
def ctrl_cancel_async_io(file_handle):
apc_sync_event = threading.Event()
hthread = kernel32.OpenThread(THREAD_SET_CONTEXT, False,
kernel32.GetCurrentThreadId())
if not hthread:
raise ctypes.WinError(ctypes.get_last_error())

@ctypes.WINFUNCTYPE(None, ctypes.c_void_p)
def apc_cancel_io(ignored):
kernel32.CancelIo(file_handle)
apc_sync_event.set()

@ctypes.WINFUNCTYPE(ctypes.c_uint, ctypes.c_uint)
def ctrl_handler(ctrl_event):
# For a Ctrl+C cancel event, queue an async procedure call
# to the target thread that cancels pending async I/O for
# the given file handle.
if ctrl_event == CTRL_C_EVENT:
kernel32.QueueUserAPC(apc_cancel_io, hthread, None)
# Synchronize here in case the APC was queued to the
# main thread, else apc_cancel_io might get interrupted
# by a KeyboardInterrupt.
apc_sync_event.wait()
return False # chain to next handler

try:
kernel32.SetConsoleCtrlHandler(ctrl_handler, True)
yield
finally:
kernel32.SetConsoleCtrlHandler(ctrl_handler, False)
kernel32.CloseHandle(hthread)


Use it as follows in your sample code:

with ctrl_cancel_async_io(sock.fileno()):
sock.sendall(b"hello")
sock.recv(1024)

Note that this requires the value of sock.fileno() to be an NT kernel handle 
for a file opened in asynchronous mode. This is the case for a socket.

HTH

--
nosy: +eryksun

___
Python tracker 

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



[issue41438] TimeoutError behavior changes on async.wait_for from python3.7

2020-07-29 Thread Yerken Tussupbekov


New submission from Yerken Tussupbekov :

```
import asyncio
from concurrent import futures


logging.basicConfig(
level=logging.DEBUG,
format="[%(asctime)s %(name)s %(levelname)s]: %(message)s",
datefmt="%H:%M:%S %d-%m-%y",
)
logger: logging.Logger = logging.getLogger("ideahitme")


async def too_long() -> None:
await asyncio.sleep(2)


async def run() -> None:
try:
await asyncio.wait_for(too_long(), 1)
except futures.TimeoutError:
logger.info("concurrent.futures.TimeoutError happened")
except asyncio.TimeoutError:
logger.info("asyncio.TimeoutError happened")


if __name__ == "__main__":
asyncio.run(run())
```

In python 3.8.4 running this script will print:

asyncio.TimeoutError happened

In python 3.7.5 running this script will print:

concurrent.futures.TimeoutError happened

This is a breaking change which I didn't see announced in the changelog. What 
is the expected behavior here ?

--
components: asyncio
messages: 374589
nosy: Yerken Tussupbekov, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: TimeoutError behavior changes on async.wait_for from python3.7
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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2020-07-29 Thread Steve Dower


Change by Steve Dower :


--
components: +Installation

___
Python tracker 

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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2020-07-29 Thread Steve Dower


Steve Dower  added the comment:

It might help, but it will leave your install broken in a number of other ways.

For other people finding this issue, please share your install logs (look in 
%TEMP% for the most recently created set of "python*.log" files). Also share 
your PATH, PYTHONPATH and PYTHONHOME environment variables (if they are set), 
and any other versions of Python you have installed.

--

___
Python tracker 

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



[issue40075] _tkinter PythonCmd fails to acquire GIL

2020-07-29 Thread Steve Dower


Steve Dower  added the comment:

At a glance, it looks like ENTER_PYTHON will *restore* the GIL on the current 
thread, but it may be coming in on a thread that's never seen the GIL before.

"The GIL" is actually the Python thread state, which is actually a per-thread 
data structure that's either active/locked or inactive/unlocked. If the current 
thread doesn't have a thread state, PyGILState_Ensure will create one, while 
ENTER_PYTHON will not.

So the underlying issue is probably that the callbacks are coming in from a 
thread that they shouldn't be, and really ought to be marshalled back into the 
correct event loop first.

--

___
Python tracker 

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



[issue41355] os.link(..., follow_symlinks=False) without linkat(3)

2020-07-29 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Thanks for the analysis Eryk!  I think you are right, changing the default to 
match the behavior that people have actually been experiencing on `os.link(src, 
dst)` makes sense.

Possible suggestion:

We can go one step further if anyone believes it is likely to be necessary: 
Preserve the exiting buggy behavior regardless of src_dir_fd= value when 
follow_symlinks is not explicitly provided as an argument.  This way the 
behavior for people who did not specify it remains unchanged <= 3.9.  This 
would be the principal of no surprise.  (it'd effectively become a tri-state 
_UNSPECIFIED/True/False value where _UNSPECIFIED depends on the mess of 
conditionals described by Eryk)

Documentation up through 3.9 should be updated to note the oddity.

In 3.8 & 3.9 if it _is_ explicitly specified, fixing the bug so that it 
actually honors that makes sense.

In 3.10 we should honor the new =False default without this tri-state behavior 
bug-compatible-by-default at all.

This is more complicated to implement.  I'd also be happy with the already 
described "just updating the default to False and fixing forward in 3.10 to 
actually honor True properly."

META: Regarding macOS, can we update the macOS version used to build the 
installers for 3.10?

--

___
Python tracker 

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



[issue37586] macOS: posix_spawn(..., setsid=True)

2020-07-29 Thread Steve Dower


Steve Dower  added the comment:

I just started running into a failure that looks like this on some private 
builds (Xcode_11.3.1 on macOS-10.14.6-x86_64-i386-64bit):

==
FAIL: test_setsid (test.test_posix.TestPosixSpawnP)
--
Traceback (most recent call last):
  File "/Users/runner/work/1/s/Lib/test/test_posix.py", line 1692, in 
test_setsid
self.assertNotEqual(parent_sid, child_sid)
AssertionError: 1 == 1

Is that this issue? Or something else?

--
nosy: +steve.dower

___
Python tracker 

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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread Brett Cannon


Change by Brett Cannon :


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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread miss-islington


miss-islington  added the comment:


New changeset 038827d0f59076f52e9797018ead12b1295cddc2 by Miss Islington (bot) 
in branch '3.8':
bpo-41426 Fix grammar in curses.getmouse() documentation (GH-21677)
https://github.com/python/cpython/commit/038827d0f59076f52e9797018ead12b1295cddc2


--

___
Python tracker 

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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread miss-islington


miss-islington  added the comment:


New changeset 607ba9deffacc57983978a28c74282dfabcb455d by Miss Islington (bot) 
in branch '3.9':
bpo-41426 Fix grammar in curses.getmouse() documentation (GH-21677)
https://github.com/python/cpython/commit/607ba9deffacc57983978a28c74282dfabcb455d


--

___
Python tracker 

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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20824
pull_request: https://github.com/python/cpython/pull/21679

___
Python tracker 

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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20823
pull_request: https://github.com/python/cpython/pull/21678

___
Python tracker 

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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread miss-islington


miss-islington  added the comment:


New changeset ba18c0b13ba3c08077ea3db6658328523823a33f by Sebastien 
Williams-Wynn in branch 'master':
bpo-41426 Fix grammar in curses.getmouse() documentation (GH-21677)
https://github.com/python/cpython/commit/ba18c0b13ba3c08077ea3db6658328523823a33f


--
nosy: +miss-islington

___
Python tracker 

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



[issue41426] [curses] Grammar mistake in curses.getmouse() docs

2020-07-29 Thread Sebastien Williams-Wynn


Change by Sebastien Williams-Wynn :


--
keywords: +patch
nosy: +Sebastien Williams-Wynn
nosy_count: 2.0 -> 3.0
pull_requests: +20822
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21677

___
Python tracker 

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



[issue9625] argparse: Problem with defaults for variable nargs when using choices

2020-07-29 Thread James Corbett


James Corbett  added the comment:

I would love to get this issue resolved; it seems like everyone agrees that 
it's a bug. It came up for me recently: https://bugs.python.org/issue41047. 
Judging from the comments above, the consensus is that the relevant line, 
`self._check_value(action, value)` should either be replaced with something 
like `if isinstance(value, collections.abc.Sequence): for v in value: 
self._check_value(action, v)` or be removed entirely.

I think the line should just be removed. I think it's fair to assume that users 
of `argparse` know what they're doing, so I think they should be allowed to 
pass default values that conflict with `choices`. Also, removing the line makes 
the behavior consistent with the optionals, which don't check whether default 
values are in `choices`. See the below script:

```
import argparse


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--foo", nargs="+", default=[-1], choices=range(10))
parser.add_argument("--bar", nargs="*", default=-1, choices=range(10))
parser.add_argument("pos", nargs="?", default=-1, choices=range(10))
args = parser.parse_args()
print(args)


if __name__ == '__main__':
main()
```

Which yields:
```
$ python argparse_test.py 
Namespace(foo=[-1], bar=-1, pos=-1)
```

--
nosy: +jameshcorbett

___
Python tracker 

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



[issue41437] SIGINT blocked by socket operations like recv on Windows

2020-07-29 Thread Zhiming Wang


New submission from Zhiming Wang :

I noticed that on Windows, socket operations like recv appear to always block 
SIGINT until it's done, so if a recv hangs, Ctrl+C cannot interrupt the 
program. (I'm a *nix developer investigating a behavioral problem of my program 
on Windows, so please excuse my limited knowledge of Windows.)

Consider the following example where I spawn a TCP server that stalls 
connections by 5 seconds in a separate thread, and use a client to connect to 
it on the main thread. I then try to interrupt the client with Ctrl+C.

import socket
import socketserver
import time
import threading


interrupted = threading.Event()


class HoneypotServer(socketserver.TCPServer):
# Stall each connection for 5 seconds.
def get_request(self):
start = time.time()
while time.time() - start < 5 and not interrupted.is_set():
time.sleep(0.1)
return self.socket.accept()


class EchoHandler(socketserver.BaseRequestHandler):
def handle(self):
data = self.request.recv(1024)
self.request.sendall(data)


class HoneypotServerThread(threading.Thread):
def __init__(self):
super().__init__()
self.server = HoneypotServer(("127.0.0.1", 0), EchoHandler)

def run(self):
self.server.serve_forever(poll_interval=0.1)


def main():
start = time.time()
server_thread = HoneypotServerThread()
server_thread.start()
sock = socket.create_connection(server_thread.server.server_address)
try:
sock.sendall(b"hello")
sock.recv(1024)
except KeyboardInterrupt:
print(f"processed SIGINT {time.time() - start:.3f}s into the 
program")
interrupted.set()
finally:
sock.close()
server_thread.server.shutdown()
server_thread.join()


if __name__ == "__main__":
main()

On *nix systems the KeyboardInterrupt is processed immediately. On Windows, the 
KeyboardInterrupt is always processed more than 5 seconds into the program, 
when the recv is finished.

I suppose this is a fundamental limitation of Windows? Is there any workaround 
(other than going asyncio)?

Btw, I learned about SIGBREAK, which when unhandled seems to kill the process 
immediately, but that means no chance of cleanup. I tried to handle SIGBREAK 
but whenever a signal handler is installed, the behavior reverts to that of 
SIGINT -- the handler is called only after 5 seconds have passed.

(I'm attaching a socket_sigint_sigbreak.py which is a slightly expanded version 
of my sample program above, showing my attempt at handler SIGBREAK. Both

python .\socket_sigint_sigbreak.py --sigbreak-handler interrupt

and

python .\socket_sigint_sigbreak.py --sigbreak-handler exit

stall for 5 seconds.)

--
components: Windows
files: socket_sigint_sigbreak.py
messages: 374580
nosy: paul.moore, steve.dower, tim.golden, zach.ware, zmwangx
priority: normal
severity: normal
status: open
title: SIGINT blocked by socket operations like recv on Windows
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49348/socket_sigint_sigbreak.py

___
Python tracker 

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



[issue40395] Scripts folder is Empty in python 3.8.2 for Windows 7.

2020-07-29 Thread Why Me


Why Me  added the comment:

I had the same issue (win 10, py 3.8.5, executable installer). The solution 
i've found is to install python to non-standard catalog (D:/ instead of windows 
user folder which is under access protection). In this case, the file 
"easy_install.exe" will be created in the Scripts folder. Then open console 
inside the folder and call "easy_install pip", this will install pip. After 
that just copy everything to the standard catalog and don't forget to change 
the environment variables. Hope this helps.

--
components:  -Installation
nosy: +Why Me

___
Python tracker 

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



[issue41395] pickle and pickletools cli interface doesn't close input and output file.

2020-07-29 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 4.0 -> 5.0
pull_requests: +20821
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21676

___
Python tracker 

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



[issue41436] BUG a simple "and" and "or"

2020-07-29 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


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



[issue41436] BUG a simple "and" and "or"

2020-07-29 Thread James Corbett


James Corbett  added the comment:

I think this would have been a better fit for a StackOverflow issue: 
https://stackoverflow.com/questions/tagged/python. Also, it's not a compilation 
error and it doesn't have anything to do with CPython's testing framework. 

Anyway, I don't think this is a bug. For a string `ch`, it is always true that 
either `ch != 'n'` or `ch != 'N'`---no string is equal to both `'N'` and `'n'`. 
Therefore your `while` condition will always be true and the loop will always 
continue.

As you already noted, your loop will terminate properly if you used `and`. You 
could also rewrite it as `while ch not in ('n', 'N'):` which I think is clearer.

--
nosy: +jameshcorbett, xtreak
type: compile error -> behavior

___
Python tracker 

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



[issue41436] BUG a simple "and" and "or"

2020-07-29 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

Below is the formatted program for easier reading. In the while clause you ask 
for the user to enter n to exit but you check (ch != n or ch != N) so on 
entering "n" the first condition is false but second clause is true. For "N" 
it's vice-versa. You want to continue the game as long as ch is not 'n' or "N'. 
Hence using not(ch == 'n' or ch == 'N') will help in exiting the program. This 
website is for bugs related to CPython itself. Please refer to stack overflow 
or other mailing lists in future.

Thanks.

from random import randint

num = randint(1, 10)

print(type(num))
print(num)

ch = None  # tried changing this tried converting types
guess = 0
print(type(guess))
print("Welcome to guessing game: ")


while (
ch != "n" or ch != "N"
):  # here is the bug this statement is not running. It works with “and”
while guess != num:
guess = int(input("Enter your guess?  "))
if guess == num:
print("You Guessed Congratz")
ch = input("Enter 'y' to play or 'n' to exit: ")
if ch == "y" or ch == "Y":
guess = 0
num = randint(1, 10)

print("Thankyou for playing.")


Fixed program : 

from random import randint

num = randint(1, 10)

print(type(num))
print(num)

ch = None  # tried changing this tried converting types
guess = 0
print(type(guess))
print("Welcome to guessing game: ")


while not (
ch == "n" or ch == "N"
):  # Play until the ch is not n or N 
while guess != num:
guess = int(input("Enter your guess?  "))
if guess == num:
print("You Guessed Congratz")
ch = input("Enter 'y' to play or 'n' to exit: ")
if ch == "y" or ch == "Y":
guess = 0
num = randint(1, 10)

print("Thankyou for playing.")

--
nosy: +jameshcorbett, xtreak
type: compile error -> behavior

___
Python tracker 

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



[issue41436] BUG a simple "and" and "or"

2020-07-29 Thread Samran

New submission from Samran :

#this is the code

from random import randint

num = randint(1,10)

print(type(num))

print(num)

ch = None   
#tried changing this tried converting types

guess = 0

print(type(guess))

print("Welcome to guessing game: ")

 

 

while ch != 'n' or ch != 'N':#here 
is the bug this statement is not running. It works with “and”

while( guess != num):

guess = int(input("Enter your guess?  "))

if guess == num:

print("You Guessed Congratz")

   

 

ch=input("Enter 'y' to play or 'n' to exit: ")

   

 

if ch=='y' or ch == 'Y':

guess= 0

num = randint(1,10)

 

print("Thankyou for playing.")

--
components: Tests
files: Command Prompt - python  test.py 29-Jul-20 9_16_22 PM (2).png
messages: 374576
nosy: Samran
priority: normal
severity: normal
status: open
title: BUG a simple "and" and "or"
type: compile error
versions: Python 3.8
Added file: https://bugs.python.org/file49347/Command Prompt - python  test.py 
29-Jul-20 9_16_22 PM (2).png

___
Python tracker 

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



[issue41435] Allow to retrieve ongoing exception handled by every threads

2020-07-29 Thread Julien Danjou


New submission from Julien Danjou :

In order to do statistical profiling on raised exception, having the ability to 
poll all the running threads for their currently handled exception would be 
fantastic.

There is an exposed function named `sys._current_frames()` that allows to list 
the current frame handled by CPython. Having an equivalent for 
`sys._current_exceptions()` that would return the content of `sys.exc_info()` 
for each running thread would solve the issue.

--
components: Interpreter Core
messages: 374575
nosy: jd
priority: normal
severity: normal
status: open
title: Allow to retrieve ongoing exception handled by every threads
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue7291] urllib2 cannot handle https with proxy requiring auth

2020-07-29 Thread Jessica Ridgley


Change by Jessica Ridgley :


--
nosy: +Jessica Ridgley
versions: +Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue7291] urllib2 cannot handle https with proxy requiring auth

2020-07-29 Thread Alexey Namyotkin


Change by Alexey Namyotkin :


--
nosy: +alexey.namyotkin

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-07-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

Okay, so if you know what to do please do it. ;-)

--

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-07-29 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I was referring to PR https://github.com/python/cpython/pull/19663 
(commit-503de7149d03bdcc671dcbbb5b64f761bb192b4d) that was merged as part of 
this issue. It started emitting PendingDeprecationWarning but was not silenced 
in the test.

--

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-07-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

Which patch are you referring to? Is it already merged?

--

___
Python tracker 

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



[issue41434] IDLE: Option to warn user on "Run Module" if file is not Python source

2020-07-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I disagree.  IDLE already shows a note -- in the editor window -- with the 
first noted divergence from python code marked.  We are trying to keep IDLE 
relatively simple and not clutter it with trivial options.

ispythonsource is just a guess.  The decision is whether turn on the colorizer 
and do python indents.  For a new file, assume that it will be python code.  
Returning True for a directory is an error that is never hit as directories are 
not opened.  Python files do not have to have a .py extensions, and files that 
have a .py extension do not have to be python files.  But IDLE encourages use 
of the convention.

I would consider adding a note to the SyntaxError box when the error is on the 
first line.  Something like "Is this really a Python code file?"

  The only actual running of non-Python files I have seen reported, and I 
believe at least twice, is very beginner beginners running the saved Shell log, 
which begins "Python 3.x...", with the 3 highlighted.  If this were recognized, 
the message might be "If this is a log of an interactive session, you cannot 
run it."

But I am not sure if this would really solve the problem of extreme ignorance.  
And anything added would have to have a test, and would be a possible 
maintenance burden.

--

___
Python tracker 

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



[issue41134] distutils.dir_util.copy_tree FileExistsError when updating symlinks

2020-07-29 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
dependencies: +Add race-free os.link and os.symlink wrapper / helper
versions: +Python 3.10

___
Python tracker 

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



[issue40072] Win7/Python3.8/asyncio IPv6 UDP Server raise OSError when recved any packet

2020-07-29 Thread Alex Grönholm

Alex Grönholm  added the comment:

My repro script also demonstrates that when binding to an interface, the bug is 
not triggered.

--

___
Python tracker 

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



[issue40072] Win7/Python3.8/asyncio IPv6 UDP Server raise OSError when recved any packet

2020-07-29 Thread Alex Grönholm

Alex Grönholm  added the comment:

I just got hit by this bug too. Attached is the repro script I came up with 
before finding this report.

--
nosy: +alex.gronholm
Added file: https://bugs.python.org/file49346/udptest.py

___
Python tracker 

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



[issue41434] IDLE: Option to warn user on "Run Module" if file is not Python source

2020-07-29 Thread E. Paine


E. Paine  added the comment:

I think this sounds like a very good idea. I would recommend using the 
`ispythonsource` method (in the editor class) as it already has all the logic 
you need while also checking for a start line like "#!/usr/bin/env python" 
(rather than relying solely on the extension).

--
nosy: +epaine
title: IDLE: Option to warn user on "Run Module" if file is not .py/.pyw -> 
IDLE: Option to warn user on "Run Module" if file is not Python source

___
Python tracker 

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



[issue24964] Add tunnel CONNECT response headers to httplib / http.client

2020-07-29 Thread Alexey


Change by Alexey :


--
nosy: +Namyotkin

___
Python tracker 

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



[issue40075] _tkinter PythonCmd fails to acquire GIL

2020-07-29 Thread E. Paine


E. Paine  added the comment:

Sorry for taking so long to do something with this issue. Can you please 
explain *why* (mostly because I don't really have a clue) acquiring the GIL 
fixes this crash (I am not disputing that it does - I have compared the current 
3.9 branch against yours and confirmed this). Also, can it be reproduced with 
just the stdlib (so we can write a unittest for this)? Is it an assumption in 
QT about the GIL rather than a problem with _tkinter?

--
nosy: +epaine
versions: +Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue40360] Deprecate lib2to3 (and 2to3) for future removal

2020-07-29 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

After this patch test_lib2to3 generates a PendingDeprecationWarning. It can be 
silenced as it's intentional to avoid test failures while running tests with 
-Werror.

./python.exe -Wall -m test test_lib2to3
0:00:00 load avg: 2.31 Run tests sequentially
0:00:00 load avg: 2.31 [1/1] test_lib2to3
/Users/kasingar/stuff/python/cpython/Lib/test/test_lib2to3.py:1: 
PendingDeprecationWarning: lib2to3 package is deprecated and may not be able to 
parse Python 3.10+
  from lib2to3.tests import load_tests

== Tests result: SUCCESS ==

1 test OK.

Total duration: 9.0 sec
Tests result: SUCCESS

--
nosy: +xtreak

___
Python tracker 

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



[issue41421] Random.paretovariate sometimes raises ZeroDivisionError for small alpha

2020-07-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

+1 for "u ** (-1.0 / alpha)"!

--

___
Python tracker 

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



[issue41421] Random.paretovariate sometimes raises ZeroDivisionError for small alpha

2020-07-29 Thread David MacIver


David MacIver  added the comment:

I should say, I don't actually care about this bug at all: I only ran into it 
because of trying to recreate the random API and testing that my recreation 
worked sensibly. I thought I'd do the good citizen thing and report it, but I'm 
totally fine with any resolution and given that that code has been unchanged 
for at least 18 years I doubt anyone else has ever run into this problem.

I do think it would be beneficial to document the range of reasonable alpha on 
paretovariate - the lack of such documentation is the only reason I hit this at 
all - but I think leaving the behaviour as is would be fine.

--

___
Python tracker 

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



[issue41418] GH-21658: Add snake game to tools/demo!

2020-07-29 Thread Ehsonjon Gadoev


Ehsonjon Gadoev  added the comment:

I knew, but its not support for turtledemo cause, canvas is so small for this 
example! Mr @terry.reedy!!

--

___
Python tracker 

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



[issue41434] IDLE: Option to warn user on "Run Module" if file is not .py/.pyw

2020-07-29 Thread wyz23x2


Change by wyz23x2 :


--
title: IDLE: Warn user on "Run Module" if file is not .py/.pyw -> IDLE: Option 
to warn user on "Run Module" if file is not .py/.pyw

___
Python tracker 

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



[issue41434] IDLE: Warn user on "Run Module" if file is not .py/.pyw

2020-07-29 Thread wyz23x2


wyz23x2  added the comment:

It should be able to turn on/off this feature.

--

___
Python tracker 

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



[issue41434] IDLE: Warn user on "Run Module" if file is not .py/.pyw

2020-07-29 Thread wyz23x2


New submission from wyz23x2 :

It would be great if IDLE shows a note when a non-Python file is attempted to 
run.

--
assignee: terry.reedy
components: IDLE
messages: 374561
nosy: terry.reedy, wyz23x2
priority: normal
severity: normal
status: open
title: IDLE: Warn user on "Run Module" if file is not .py/.pyw
type: enhancement
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41282] Deprecate and remove distutils

2020-07-29 Thread Hugo van Kemenade


Change by Hugo van Kemenade :


--
nosy: +hugovk

___
Python tracker 

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



[issue41433] Logging libraries BufferingHandler flushed twice at shutdown

2020-07-29 Thread Tatsunosuke Shimada


Tatsunosuke Shimada  added the comment:

Found related issue.
https://bugs.python.org/issue901330

--

___
Python tracker 

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