[issue36047] socket file handle does not support stream write

2019-02-19 Thread Windson Yang


Windson Yang  added the comment:

>From the docs 
>https://docs.python.org/3/library/socket.html#socket.socket.makefile, the 
>default mode for makefile() is 'r' (only readable). In your example, just use 
>S = s.makefile(mode='w') instead.

--
nosy: +Windson Yang

___
Python tracker 

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



[issue36045] builtins.help function is not much help with async functions

2019-02-19 Thread Dan Rose


Dan Rose  added the comment:

Note to future self: whatever solution should also play nice with 
functools.partial

--

___
Python tracker 

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



[issue36045] builtins.help function is not much help with async functions

2019-02-19 Thread Dan Rose

Dan Rose  added the comment:

Thanks for the suggestion, Raymond. I was toying with the idea of a PR, but 
wasn’t sure what the resolution should be, and it’s a rather subtle decision 
for my first contribution.

It seems to me that this might be an oversight in PEP-0484, and the purest 
resolution is that either Generator and Coroutine should both be part of the 
type signature or neither should be.

If the PEP is indeed correct, the help output *could* look like:

async the_answer2() -> int

Which would be equivalent to the (functionally identical) wrapper:

the_answer3() -> Awaitable[int]


Philosophically, does asyncness belong on the left or right of the arrow? 
Should it change just because of how the function is expressed?

--

___
Python tracker 

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



[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2019-02-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue33039.

--

___
Python tracker 

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



[issue33039] int() and math.trunc don't accept objects that only define __index__

2019-02-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See also issue33039.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue36048] Deprecate implicit truncating when convert Python numbers to C integers

2019-02-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue36030] add internal API function to create tuple without items array initialization

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Zeroing memory is usually not expensive relative to the cost of filling it in.  
Also, the timing loop is unrealistic.  We mostly care about small tuples.  


For long term maintenance of the project, I recommend filling the code with 
these unsafe variants which will segfault whenever someone follows the normal 
practice of decreffing when an error is encountered.  This would be yet another 
special case a person would have to learn to do maintenance or code review for 
CPython.

In general, there are a lot of small optimizations to be had if we were to 
forgo principles of loose coupling, defensive programming, and ease of 
maintenance.  Once in a while, we find one that actually is worth it, but 
usually it is a best practice sprinkle these special cases all over the code 
(see MS Code Complete for more discussion on the long term costs of this kind 
of coding).

--
nosy: +rhettinger

___
Python tracker 

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



[issue36021] [Security][Windows] webbrowser: WindowsDefault uses os.startfile() and so can be abused to run arbitrary commands

2019-02-19 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Hi @eryk, @vstinner and @steve,

I think I could not work on this issue today, but will continue to fix it asap 
(tomorrow or on this evening).

--

___
Python tracker 

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



[issue36048] Deprecate implicit truncating when convert Python numbers to C integers

2019-02-19 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Currently, C API functions that convert a Python number to a C integer like 
PyLong_AsLong() and argument parsing functions like PyArg_ParseTuple() with 
integer converting format units like 'i' use the __int__() special method for 
converting objects which are not instances of int or int subclasses. This leads 
to dropping the fractional part if the object is not integral number (e.g. 
float, Decimal or Fraction). In some cases, there is a special check for float, 
but it does not prevent truncation for Decimal, Fraction and other numeric 
types.

For example:

>>> chr(65.5)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: integer argument expected, got float
>>> chr(Decimal('65.5'))
'A'

The proposed PR makes all these functions using __index__() instead of 
__int__() if available and emit a deprecation warning when __int__() is used 
for implicit conversion to a C integer.

>>> chr(Decimal('65.5'))
:1: DeprecationWarning: an integer is required (got type decimal.Decimal)
'A'

In future versions only __index__() will be used for the implicit conversion, 
and __int__() will be used only in the int constructor.

--
components: Interpreter Core
messages: 336041
nosy: mark.dickinson, serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Deprecate implicit truncating when convert Python numbers to C integers
type: enhancement
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



[issue36031] add internal API function to effectively convert just created list to tuple

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

-1 This technique has a low payoff (possibly even zero due to memcpy() 
overhead) but is likely to create future maintenance issues (risk of bugs due 
to the fragility of assuming a refcnt of one, awkwardness of maintenance if we 
have to alter the surrounding code).

--
nosy: +rhettinger

___
Python tracker 

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



[issue36021] [Security][Windows] webbrowser: WindowsDefault uses os.startfile() and so can be abused to run arbitrary commands

2019-02-19 Thread Eryk Sun

Eryk Sun  added the comment:

> os.access(path, os.X_OK) is specific to Unix. It doesn't make sense 
> on Windows. 

It doesn't make sense with the current implementation of os.access, and not as 
Stéphane used it. Even if we completely implemented os.access, the problem is 
that most files grant execute access to the owner, "Users", or "Authenticated 
Users". Typically we have to override inheritance to prevent granting execute 
access, or add an entry that denies execute access.

However, it's not that it makes no sense in general. CreateProcess does require 
execute access on a file. This includes both DACL discretionary access and SACL 
mandatory access. ShellExecuteEx ultimately calls CreateProcess if it's running 
a "file:" URL, so execute access certainly matters in this case. For example, 
I've denied execute access on the following file:

>>> os.startfile('file:///C:/Temp/test/test.exe')
Traceback (most recent call last):
  File "", line 1, in 
PermissionError: [WinError 5] Access is denied: 
'file:///C:/Temp/test/test.exe'

On the other hand, if we're talking about data files and scripts, 
ShellExecute[Ex] doesn't check for execute access because it's generally used 
to "open" files. It wouldn't be a security barrier, anyway. It's easy enough 
for a program to call AssocQueryString to get the command-line template for a 
protocol or file type, manually replace template parameters, and execute the 
command directly via CreateProcess. 

> os.access() is implemented with GetFileAttributesW() on Windows. The
> mode argument is more or less ignored.

The readonly file attribute denies W_OK access, similar to how the [i]mmutable 
file attribute works in some Unix systems (e.g. Linux lsattr and chattr +i).

--
nosy: +eryksun

___
Python tracker 

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



[issue32528] Change base class for futures.CancelledError

2019-02-19 Thread Chris Jerdonek


Change by Chris Jerdonek :


--
nosy: +chris.jerdonek

___
Python tracker 

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



[issue35925] test_httplib test_nntplib test_ssl fail on ARMv7 Debian buster bot (OpenSSL 1.1.1a)

2019-02-19 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

It's okay with me if you want to backport minimum_version (and I suppose 
maximum_version).

--

___
Python tracker 

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



[issue31904] Python should support VxWorks RTOS

2019-02-19 Thread Peixing Xin


Change by Peixing Xin :


--
pull_requests: +11976

___
Python tracker 

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



[issue35945] Cannot distinguish between subtask cancellation and running task cancellation

2019-02-19 Thread twisteroid ambassador


twisteroid ambassador  added the comment:

I wrote a recipe on this idea:

https://gist.github.com/twisteroidambassador/f35c7b17d4493d492fe36ab3e5c92202

Untested, feel free to use it at your own risk.

--

___
Python tracker 

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



[issue35885] configparser: indentation

2019-02-19 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

> I already have some example code for it

Do you have a patch?

--
nosy: +eamanu

___
Python tracker 

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



[issue36045] builtins.help function is not much help with async functions

2019-02-19 Thread Emmanuel Arias


Change by Emmanuel Arias :


--
nosy: +eamanu

___
Python tracker 

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



[issue34793] Remove support for "with (await asyncio.lock):"

2019-02-19 Thread Emmanuel Arias


Change by Emmanuel Arias :


--
nosy: +eamanu

___
Python tracker 

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



[issue36047] socket file handle does not support stream write

2019-02-19 Thread wang xuancong


New submission from wang xuancong :

Python3 programmers have forgotten to convert/implement the socket file 
descriptor for IO stream operation. Would you please add it? Thanks!

import socket
s = socket.socket()
s.connect('localhost', 5432)
S = s.makefile()

# on Python2, the following works
print >>S, 'hello world'
S.flush()

# on Python3, the same thing does not work
print('hello world', file=S, flush=True)

It gives the following error:
Traceback (most recent call last):
  File "", line 1, in 
io.UnsupportedOperation: not writable

Luckily, the stream read operation works, S.readline()

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 336035
nosy: xuancong84
priority: normal
severity: normal
status: open
title: socket file handle does not support stream write
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue35224] PEP 572: Assignment Expressions

2019-02-19 Thread Kubilay Kocak


Change by Kubilay Kocak :


--
nosy: +koobs

___
Python tracker 

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



[issue33935] shutil.copyfile throws incorrect SameFileError on Google Drive File Stream

2019-02-19 Thread Eryk Sun


Eryk Sun  added the comment:

> I don't see any value in testing the drive name separately. 

If the file number is non-zero, then the volume is the only question. I limited 
the comparison to just the drives in case the volume supports hardlinks. We can 
change the check to `s1.st_ino and s1.st_nlink > 1`, so we only incur the 
expense when necessary. Maybe that's never in practice, but I'd rather error on 
the side of caution.

Anyway, it turns out we can't use splitdrive(). It doesn't handle UNC device 
paths the same way as regular UNC paths. It returns "\\?\UNC" as the drive for 
"\\?\UNC\server\share", whereas for a regular UNC path the drive is 
"\\server\share". 

> Would it make sense to add a parameter to _getfinalpathname that 
> specifies the type of the path? For same[open]file(), we can 
> probably just go to the most unreadable but broadly supported 
> type

That's probably the simplest change we can make here, in addition to 
file-descriptor support. The non-normalized NT path (VOLUME_NAME_NT | 
FILE_NAME_OPENED) is the most broadly supported and cheapest path to get. It's 
just two system calls: NtQueryObject and NtQueryInformationFile.

--

___
Python tracker 

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



[issue36046] support dropping privileges when running subprocesses

2019-02-19 Thread Patrick McLean


Change by Patrick McLean :


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

___
Python tracker 

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



[issue36046] support dropping privileges when running subprocesses

2019-02-19 Thread Patrick McLean


New submission from Patrick McLean :

Currently when using python to automate system administration tasks, it is 
useful to drop privileges sometimes. Currently the only way to do this is via a 
preexec_fn, which has well-documented problems. It would be useful to be able 
to pass a user and groups arguments to subprocess.popen.

--
components: Library (Lib)
messages: 336033
nosy: patrick.mclean
priority: normal
severity: normal
status: open
title: support dropping privileges when running subprocesses
type: enhancement
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



[issue23428] Use the monotonic clock for thread conditions on POSIX platforms

2019-02-19 Thread INADA Naoki


Change by INADA Naoki :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +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



[issue12822] NewGIL should use CLOCK_MONOTONIC if possible.

2019-02-19 Thread INADA Naoki


INADA Naoki  added the comment:


New changeset 001fee14e0f2ba5f41fb733adc69d5965925a094 by Inada Naoki in branch 
'master':
bpo-12822: use monotonic clock for condvar if possible (GH-11723)
https://github.com/python/cpython/commit/001fee14e0f2ba5f41fb733adc69d5965925a094


--

___
Python tracker 

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



[issue12822] NewGIL should use CLOCK_MONOTONIC if possible.

2019-02-19 Thread INADA Naoki


Change by INADA Naoki :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue30717] Add unicode grapheme cluster break algorithm

2019-02-19 Thread Bert JW Regeer


Change by Bert JW Regeer :


--
nosy: +Bert JW Regeer

___
Python tracker 

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



[issue36012] Investigate slow writes to class variables

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks Neil.  The tooling does indeed look nice.

I added your PyUnicode_InternInPlace() suggestion to the PR.

At this point, the PR looks ready-to-go unless any of you think we've missed 
some low-hanging fruit.

--

___
Python tracker 

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



[issue35689] IDLE: Docstrings and test for colorizer

2019-02-19 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

> I have thought about merging delegator and colorizer into one module, 
> possibly with percolator included, and adding a module docstring that 
> explains how they work together.  This would still be only a few hundred 
> lines.  (And multiple htests in one file are not an issue.)  What do you 
> think?

undo also uses delegator.Delegator as a base class.  It might be odd for it to 
come from colorizer.delegator.  I like the idea of explaining how they all work 
together though.

> I have not seriously looked at that idea yet.
Neither have I.  There are other things I'd like to get done (in this and other 
modules) before thinking about that one though.

> In the first code comment I mentioned a follow-up code change.

OK, I'll create an issue for that.  I *really* want to rename the `any` 
function too.  It took a lot of willpower to not touch it when writing the 
tests.  :-)

> Did you have anything in mind to work on or did you pick this for the fun and 
> challenge?

:-)  Since the goal is to add tests for everything, I figured I'd tackle this 
one.  But, I specifically thought it would be good to have tests in place in 
order to work on #29287.

--

___
Python tracker 

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



[issue36018] Add a Normal Distribution class to the statistics module

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I'll work up a PR for this.  

We can continue to tease-out the best method names. I've has success with 
"examples" and "from_samples" when developing this code in the classroom.  Both 
names had the virtue of being easily understood and never being misunderstood.

Intellectually, the name fit() makes sense because we are using data to create 
best fit model parameters.  So, technically this is probably the most accurate 
terminology.  However, it doesn't match how I think about the problem though -- 
that is more along the lines of "use sampling data to make a random variable 
with a normal distribution".  Another minor issue is that class methods are 
typically (but not always) recognizable by their from-prefix (e.g. 
dict.fromkeys, datetime.fromtimestamp, etc).

"NormalDist" seems more self explanatory to me that just "Normal".  Also, the 
noun form seems "more complete" than a dangling adjective (reading "normal" 
immediately raises the question "normal what?").  FWIW, MS Excel also calls 
their variant NORM.DIST (formerly spelled without the dot).

--

___
Python tracker 

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



[issue36027] Support negative exponents in pow() where a modulus is specified.

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Changing the title to reflect a focus on building-out pow() instead of a 
function in the math module.

--
title: Consider adding modular multiplicative inverse to the math module -> 
Support negative exponents in pow() where a modulus is specified.

___
Python tracker 

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



[issue36045] builtins.help function is not much help with async functions

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This would be a reasonable addition to help(). Would you like to make a PR?

An "async def" can be detected with inspect.iscoroutinefunction(the_answer2).

--
keywords: +easy
nosy: +rhettinger
stage:  -> needs patch
type:  -> enhancement
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> CPython only makes these methods class method when a class created.
> If you set __class_getitem__ method after the creation it 
> doesn't work unless you use classmethod decorator manually.

Give the intended use case for __class_getitem__ and that it was replacement 
for metaclass code with the same effect, the current behavior doesn't seem 
unreasonable.  That said, I don't see any downside to allowing the method to 
attach after class creation.

Assigning to Ivan to make the call on this one.

--
assignee:  -> levkivskyi
components: +Interpreter Core
nosy: +rhettinger
type: behavior -> enhancement
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



[issue36045] builtins.help function is not much help with async functions

2019-02-19 Thread Dan Rose


Change by Dan Rose :


--
title: Help function is not much help with async functions -> builtins.help 
function is not much help with async functions

___
Python tracker 

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



[issue36045] Help function is not much help with async functions

2019-02-19 Thread Dan Rose


New submission from Dan Rose :

It is very important when using a callable to know whether it is async or not. 
It is expected that `builtins.help` function should provide the information 
needed to properly use the function, but it omits whether it is an async 
function or not.

```
import asyncio

def the_answer():
return 42

async def the_answer2():
await asyncio.sleep(100)
return the_answer()
```

```
>>> help(the_answer)
Help on function the_answer in module __main__:

the_answer()

>>> help(the_answer2)
Help on function the_answer2 in module __main__:

the_answer2()
```

Note there is no way to tell whether the result of the function needs to be 
awaited.

In the similar case of generator functions versus regular functions, one 
obvious solution is to add a type annotation. That doesn't work here, since 
PEP-0484 indicates that the correct annotation for a coroutine function is the 
type that is awaited, not the coroutine object created when the function is 
called.

```
import typing
def non_answers() -> typing.Iterable[int]:
yield from range(42)

>>> help(non_answers)
Help on function non_answers in module __main__:

non_answers() -> Iterable[int]
```

One awkward workaround is to wrap the coroutine function in a regular function:

```
def the_answer3() -> typing.Awaitable[int]:
return the_answer2()

>>> help(the_answer3)
Help on function the_answer3 in module __main__:

the_answer3() -> Awaitable[int]
```

--
components: asyncio
messages: 336025
nosy: Dan Rose, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Help function is not much help with async functions
versions: Python 3.7

___
Python tracker 

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



[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-19 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

i'm curious if this _ever_ comes up so i'd like to leave it in at least through 
some betas.  I don't believe it should be possible.  If it is, it'd probably be 
a restricted execution environment that fails all signal() calls.  all perror 
will do is emit an error message to that effect before continuing so we still 
exit with an error code as the final fallback.

--

___
Python tracker 

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



[issue36040] Python\ast.c(3875): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int'

2019-02-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Fixed with commit 
https://github.com/python/cpython/commit/46a97920feaf4094436b2cdb32d2bd2fab3b59a5

--
nosy: +pablogsal
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



[issue36040] Python\ast.c(3875): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int'

2019-02-19 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue30717] Add unicode grapheme cluster break algorithm

2019-02-19 Thread Jens Troeger


Change by Jens Troeger :


--
nosy: +_savage

___
Python tracker 

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



[issue35945] Cannot distinguish between subtask cancellation and running task cancellation

2019-02-19 Thread Nic Watson


Nic Watson  added the comment:

Excellent answer by twisteroid Ambassador.

Resolved

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



[issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.

2019-02-19 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Is this an issue though? Shouldn't methods be defined in the class definition, 
we don't expect setting a function as an attribute to a class to transform it 
automatically to a method.

Why would we special case __class_getitem__ and not __init_subclass__?

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue36044] PROFILE_TASK for PGO build is not a good workload

2019-02-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Also, the test suite exercises a lot of branches (like passing incorrect types 
to function to check errors) that will hurt the branch prediction that PGO 
generates.

--
nosy: +pablogsal

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

To stop the discussion from happening in two places (sorry, Yury), I started a 
broader discussion on Async-sig with thread starting here: 
https://mail.python.org/pipermail/async-sig/2019-February/000548.html

--

___
Python tracker 

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



[issue36044] PROFILE_TASK for PGO build is not a good workload

2019-02-19 Thread Neil Schemenauer


New submission from Neil Schemenauer :

I was doing some 'perf' profiling runs of Python.  I decided to try running 
PROFILE_TASK to see what the profile looks like.  I was surprised that 
gc_collect dominated runtime:

  Children  Self  Symbol
+   93.93% 6.00%  [.] _PyEval_EvalFrameDefault
+   76.19% 0.12%  [.] function_code_fastcall  
+   70.65% 0.31%  [.] _PyMethodDef_RawFastCallKeywords
+   63.24% 0.13%  [.] _PyCFunction_FastCallKeywords   
+   58.67% 0.36%  [.] _PyEval_EvalCodeWithName
+   57.45%23.84%  [.] collect 
+   52.89% 0.00%  [.] gc_collect  
+   52.10% 0.08%  [.] _PyFunction_FastCallDict
+   41.99% 0.02%  [.] _PyObject_Call_Prepend  
+   36.37% 0.18%  [.] _PyFunction_FastCallKeywords
+   20.94% 0.07%  [.] _PyObject_FastCallDict  
+   19.64% 0.00%  [.] PyObject_Call   
+   17.74% 0.11%  [.] _PyObject_FastCallKeywords  
+   12.45% 0.00%  [.] slot_tp_call
+   12.27% 4.05%  [.] dict_traverse   
+   11.45%11.04%  [.] visit_reachable 
+   11.18%10.76%  [.] visit_decref
+9.65% 0.11%  [.] type_call   
+8.80% 0.83%  [.] func_traverse   
+7.78% 0.08%  [.] _PyMethodDescr_FastCallKeywords 

Part of the problem is that we run full cyclic GC for every test.  I.e. 
cleanup_test_droppings() calls gc.collect().  Maybe we could make these calls 
conditional on the --pgo flag of regtest.  Or, maybe we need to re-evaluate if 
running the unit test suite is the best way to generate PGO trace data.

Based on a tiny bit of further investigation, it looks like gc_collect() is 
getting called quite a lot of times, in addition to cleanup_test_droppings().  
Maybe there is some low-hanging fruit here for optimization.  Full GC is pretty 
expensive.

--
messages: 336018
nosy: nascheme
priority: normal
severity: normal
status: open
title: PROFILE_TASK for PGO build is not a good workload
type: performance

___
Python tracker 

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



[issue36034] Suprise halt caused by -Werror=implicit-function-declaration in ./Modules/posixmodule.c

2019-02-19 Thread Alexey Izbyshev


Alexey Izbyshev  added the comment:

I don't know what you mean by "in-line" pre-processing output, but you can use 
-E option to get the normal preprocessor output. Line directives will tell you 
where those functions come from on a system where there is no compilation error.

Of course, if those functions are defined in some other headers on AIX 6.1, it 
won't help you, so you might as well just grep /usr/include :)

--
nosy: +izbyshev

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 6ee41793d2204c54bdf8f477ae61d016a7eca932 by Raymond Hettinger 
(Miss Islington (bot)) in branch '2.7':
bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11948)
https://github.com/python/cpython/commit/6ee41793d2204c54bdf8f477ae61d016a7eca932


--

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset bb9ddee3d4e293f0717f8c167afdf5749ebf843d by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.7':
bpo-35584: Clarify role of caret in a class class (GH-11946) (GH-11947)
https://github.com/python/cpython/commit/bb9ddee3d4e293f0717f8c167afdf5749ebf843d


--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

I agree with Yuri.

`Task.set_exception()` (let's assume it works) is very dangerous: if 
cancellation exception doesn't bubble up from coroutine code there is a very 
high chance to get broken invariants and not-released resources.

The same situation is possible with classic threads: killing a thread without 
unwinding a call stack leads to locked mutexes etc.

Regarding distinguishing explicit cancellation from timeout exhausting: it can 
be done with current asyncio design by using a flag. Take a look on 
async_timeout context manager, __aexit__() implementation: 
https://github.com/aio-libs/async-timeout/blob/master/async_timeout/__init__.py#L88-L97

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

> Well, if you want to unconditionally end tasks you shouldn't write coroutines 
> that ignore CancelledErrors.

Well, of course. But code can have bugs, and maybe you didn't write the 
coroutine because it's from a library that you don't control. In that case, you 
should still be able to end the task. Also, maybe the coroutine doesn't have a 
bug but the cancellation is just taking longer than you have time for, so you 
want to end it early.

> So what are those real-world cases that can explain why asyncio should 
> support this functionality?

The case I had in mind was the one I referenced above -- being able to 
distinguish a normal CancelledError from one where you had interrupt the 
cancellation (i.e. cancellation timing out). I would like the caller to be able 
to know when the latter are happening.

--

___
Python tracker 

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



[issue36027] Consider adding modular multiplicative inverse to the math module

2019-02-19 Thread Tim Peters


Tim Peters  added the comment:

Raymond, I doubt we can do better (faster) than straightforward egcd without 
heroic effort anyway.  We can't even know whether a modular inverse exists 
without checking whether the gcd is 1, and egcd builds on what we have to do 
for the latter anyway.  Even if we did know in advance that a modular inverse 
exists, using modular exponentiation to find it requires knowing the totient of 
the modulus, and computing the totient is believed to be no easier than 
factoring.

The only "optimization" I'd be inclined to _try_ for Python's use is an 
extended binary gcd algorithm (which requires no bigint multiplies or divides, 
the latter of which is especially sluggish in Python):

https://www.ucl.ac.uk/~ucahcjm/combopt/ext_gcd_python_programs.pdf

For the rest:

- I'd also prefer than negative exponents other than -1 be supported.  It's 
just that -1 by itself gets 95% of the value.

- It's fine by me if `pow(a, -1, m)` is THE way to spell modular inverse.  
Adding a distinct `modinv()` function too strikes me as redundnt clutter, but 
not damaging enough to be worth whining about.  So -0 on that.

--

___
Python tracker 

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



[issue35941] ssl.enum_certificates() regression

2019-02-19 Thread nr


nr  added the comment:

Adjusted the code to conform with PEP 7.

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Yury Selivanov


Yury Selivanov  added the comment:

>> There's no clear reason to complicate the Task<->coroutine relationship by 
>> allowing to inject arbitrary exceptions into running coroutines.

> My comment was more about CancelledError rather than arbitrary exceptions. 
> You didn't reply to the part of my response saying that Task.cancel() doesn't 
> let you communicate why the task was ended, [..]

I didn't reply because you didn't clearly articulate why the cancellation 
reason is important :)  AFAIK no other async framework allows you to do this.  
So what are those real-world cases that can explain why asyncio should support 
this functionality?

> [..] which is something the removed API's let you do.

Unfortunately they didn't.  They never worked properly; IIRC Task.set_exception 
had never worked at all.  The fact they were available at all was a simple 
oversight.

> Task.set_exception() and Task.set_result() both give you a way to 
> unconditionally end a task. With cancel() though, the docs say, 
> "Task.cancel() does not guarantee that the Task will be cancelled." [1]

Yes, because Task can only signal its coroutine that it was requested to be 
cancelled.  The coroutine may choose to ignore that by swallowing 
CancelledError.

> The reason you might want to unconditionally end a task is if e.g. you 
> already called Task.cancel() and it is still running after waiting a certain 
> amount of time.

Well, if you want to unconditionally end tasks you shouldn't write coroutines 
that ignore CancelledErrors.  If you do, then you clearly *do not want* the 
coroutine to be cancelled, and thus there's no use case for set_exception.

Finally, asyncio has queues, which can be used to build two-way communication 
channels between coroutines and implement whatever advanced cancellation 
mechanism you want.

--

___
Python tracker 

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



[issue36041] email: folding of quoted string in display_name violates RFC

2019-02-19 Thread R. David Murray


R. David Murray  added the comment:

Since Address itself renders it correctly (str(address)), the problem is going 
to take a bit of digging to find.  I'm guessing the quoted_string atom is 
getting transformed incorrectly into something else at some point during the 
folding.

--

___
Python tracker 

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



[issue36018] Add a Normal Distribution class to the statistics module

2019-02-19 Thread Michael Selik


Michael Selik  added the comment:

+1, This would be useful for quick analyses, avoiding the overhead of 
installing scipy and looking through its documentation.

Given that it's in the statistics namespace, I think the name can be simply 
``Normal`` rather than ``NormalDist``.  Also, instead of ``.from_examples`` 
consider naming the classmethod ``.fit``.

--
nosy: +selik

___
Python tracker 

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



[issue35892] Fix awkwardness of statistics.mode() for multimodal datasets

2019-02-19 Thread Francis MB


Francis MB  added the comment:

>> [...] This keeps the signature simple (Iterable -> Scalar). [...]
>>
>> Categorical, binned, or ordinal data:
>>
>>   mode(data: Iterable, *, first_tie=False) -> object
>>   multimode(data: Iterable) -> List[object]

This seems reasonable to me due legacy (although I really thing that
multimode is just the real thing :-) )

>> Continuous data:
>>   mode(data: Iterable[Real]) -> Real

What should return in that case: E.g.: mode([42.0, 42.0, 42.0, 1.0, 1.0, 1.0]) ?

42.0 ? or 1.0 ? or [42.0, 1.0] ? or do I have misunderstood something ? 


Thanks!

--

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11972

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11971

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread miss-islington


miss-islington  added the comment:


New changeset 3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772 by Miss Islington (bot) 
(Raymond Hettinger) in branch 'master':
bpo-35584: Clarify role of caret in a class class (GH-11946)
https://github.com/python/cpython/commit/3bacf6126522a9b3bcb6be0c4f3ee6a895dfe772


--
nosy: +miss-islington

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

> There's no clear reason to complicate the Task<->coroutine relationship by 
> allowing to inject arbitrary exceptions into running coroutines.

My comment was more about CancelledError rather than arbitrary exceptions. You 
didn't reply to the part of my response saying that Task.cancel() doesn't let 
you communicate why the task was ended, which is something the removed API's 
let you do.

--

___
Python tracker 

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



[issue36021] [Security][Windows] webbrowser: WindowsDefault uses os.startfile() and so can be abused to run arbitrary commands

2019-02-19 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

@vstinner

With the last commit, I don't test if the file is an executable but just if the 
extension is a .html file.

For example, if you rename calc.exe by calc.html and you try to execute it in 
the default browser (via os.startfile()), you will get the content of the file 
in the browser.

--

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +11970

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

A second reason why Task.cancel() seems to be an incomplete replacement:

Task.set_exception() and Task.set_result() both give you a way to 
unconditionally end a task. With cancel() though, the docs say, "Task.cancel() 
does not guarantee that the Task will be cancelled." [1]

The reason you might want to unconditionally end a task is if e.g. you already 
called Task.cancel() and it is still running after waiting a certain amount of 
time.

[1]: https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Yury Selivanov


Yury Selivanov  added the comment:

> One reason why Task.cancel() is an incomplete replacement for 
> Task.set_exception() is that you don't have an easy way to communicate why 
> the task was ended.


The result of the Task is bound to the result of the coroutine it wraps.  If 
the coroutine raises an exception -- that's the exception of the Task object.  
If the coroutine returns a value -- that's the result value of the Task object. 
 If the coroutine is cancelled via the "Task.cancel()" call -- 
asyncio.CancelledError is likely the result of the Task.

Key rule: the wrapped coroutine dictates the result of the Task, not the other 
way around.  The Task can signal cancellation, but even then, the final result 
is up to the coroutine.

There's no clear reason to complicate the Task<->coroutine relationship by 
allowing to inject arbitrary exceptions into running coroutines.

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

Correction: that should have been bpo-31033.

--

___
Python tracker 

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



[issue32363] Deprecate task.set_result() and task.set_exception()

2019-02-19 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

> Use Task.cancel() or use a Queue to communicate with the task.

One reason why Task.cancel() is an incomplete replacement for 
Task.set_exception() is that you don't have an easy way to communicate why the 
task was ended.

With set_exception() and set_result(), you could. Task.cancel(), though, 
doesn't let you e.g. specify a CancelledError subclass or "reason" string (see 
the related bpo-35674, "Add argument to .cancel() of Task and Future").

--
nosy: +chris.jerdonek

___
Python tracker 

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



[issue36033] logging.makeLogRecord should update "rv" using a dict defined with bytes instead of strings

2019-02-19 Thread Vinay Sajip


Vinay Sajip  added the comment:

If the arguments are retrieved from a byte source, why can't they be converted 
to strings before passing to logging? This may be an issue for OpenStack. It's 
not logging's job to convert bytes passed to APIs that expect strings.

--

___
Python tracker 

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



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-19 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

in fact, I have published my PR because I have already the tests and I have 
another approach for this issue.

--
stage: patch review -> 

___
Python tracker 

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



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-19 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


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

___
Python tracker 

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



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-19 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

@xtreak

sorry, but I have already worked on this issue :/

can I publish my PR?

--
nosy: +matrixise
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



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-19 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This seems like a good change to me. GitHub PRs are accepted please see 
https://devguide.python.org/ . Since this is an enhancement it can only go as 
part of Python 3.8 if accepted.

--
nosy: +xtreak
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



[issue36012] Investigate slow writes to class variables

2019-02-19 Thread Neil Schemenauer


Neil Schemenauer  added the comment:

BTW, 'perf report [...]' has a really neat annotated assembly view.  Scroll to 
the function you are interested in and press 'a'.  Press 't' to toggle the time 
units (left side numbers).  I'm attaching a screenshot of the disassembly of 
the lookdict function.  The time units are sample accounts.  Each count is a 
point where the profiler woke up on that specific instruction.

--
Added file: https://bugs.python.org/file48157/perf-screenshot.png

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread Louis Michael


Change by Louis Michael :


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

___
Python tracker 

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



[issue29515] socket module missing IPPROTO_IPV6, IPPROTO_IPV4 on Windows

2019-02-19 Thread Gregory P. Smith


Change by Gregory P. Smith :


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

___
Python tracker 

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



[issue36027] Consider adding modular multiplicative inverse to the math module

2019-02-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> +1 for the pow(value, -1, modulus) spelling. It should raise
> `ValueError` if `value` and `modulus` are not relatively prime.

> It would feel odd to me _not_ to extend this to 
> `pow(value, n, modulus)` for all negative `n`, again
> valid only only if `value` is relatively prime to `modulus`.

I'll work up a PR using the simplest implementation.  Once that's in with tests 
and docs, it's fair game for someone to propose algorithmic optimizations.

--

___
Python tracker 

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



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-19 Thread Alexander Kapshuna


New submission from Alexander Kapshuna :

FileCookieJar and it's subclasses don't accept Paths and DirEntrys.
Minimal code to reproduce:

===

import pathlib
from http.cookiejar import FileCookieJar

saved_cookies = pathlib.Path('my_cookies.txt')
jar = FileCookieJar(saved_cookies)

===

Results in: "ValueError: filename must be string-like".
Workaround is to convert Path explicitly or call load() which doesn't check for 
type, but it would be nice to see all APIs in standard library consistent.

I also did quick and dirty patch which silently converts filename argument 
using os.fspath(). This way it won't break any existing code relying on 
FileCookieJar.filename being string.

--
components: Library (Lib)
files: cookiejar_straightforward_convert.patch
keywords: patch
messages: 335993
nosy: Alexander Kapshuna
priority: normal
severity: normal
status: open
title: FileCookieJar constructor don't accept PathLike
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8
Added file: 
https://bugs.python.org/file48156/cookiejar_straightforward_convert.patch

___
Python tracker 

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



[issue36012] Investigate slow writes to class variables

2019-02-19 Thread Neil Schemenauer


Neil Schemenauer  added the comment:

Some profiling using 'perf'.  This is for cpython 
63fa1cfece4912110ce3a0ff11fb3ade3ff5e756.

  children  self
  [...]
+   97.27% 0.00%  run_mod (inlined)
+   88.53% 6.33%  PyObject_SetAttr
+   79.34% 6.80%  type_setattro
+   43.92%43.92%  update_slot
+   26.87% 5.84%  _PyObject_GenericSetAttrWithDict
+   14.62% 6.52%  insertdict
+8.80% 8.80%  lookdict_unicode_nodummy
+6.57% 0.00%  _Py_DECREF (inlined)
+5.19% 5.19%  PyUnicode_InternInPlace
+3.57% 3.57%  _PyObjectDict_SetItem
+3.38% 3.38%  _PyType_Lookup
+1.71% 0.00%  _Py_INCREF (inlined)
+1.42% 0.00%  _Py_XDECREF (inlined)
  [...]

After applying PR 11907:

  children  self
  [...]
+   94.76% 0.00%  run_mod (inlined)
+   75.22% 6.77%  PyObject_SetAttr
+   64.65%13.08%  type_setattro
+   47.51%11.96%  _PyObject_GenericSetAttrWithDict
+   22.99%13.95%  insertdict
+   10.10%10.10%  lookdict_unicode_nodummy
+9.47% 9.47%  PyUnicode_InternInPlace
+7.10% 7.10%  _PyObjectDict_SetItem
+7.02% 7.02%  _PyType_Lookup
+6.52% 0.00%  _Py_DECREF (inlined)
+3.17% 0.00%  _Py_INCREF (inlined)
+3.16% 0.00%  _Py_XDECREF (inlined)
+2.59% 0.00%  PyDict_SetItem (inlined)
+1.50% 0.00%  is_dunder_name (inlined)
  [...]

The PyUnicode_InternInPlace() can mostly be eliminated by testing 
PyUnicode_CHECK_INTERNED() first (we already have called PyUnicode_Check() on 
it).  That only gives a 7% speedup on my machine though.  The is_dunder_name() 
is a much bigger optimization.

--

___
Python tracker 

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



[issue36019] test_urllib fail in s390x buildbots: http://www.example.com/

2019-02-19 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

@vstinner I have fixed some URLs but we need to update pythontest.net for some 
tests.

For example: test.test_urllib2.MiscTests.test_issue16464 raises a HTTP 405 and 
pythontest.net does not support the requested method.

test_networked_trusted_by_default_cert (test.test_httplib.HTTPSTest) ... 
skipped "Resource 'www.python.org' is not available"
test_logincapa (test.test_imaplib.RemoteIMAPTest) ... skipped "Resource 
'cyrus.andrew.cmu.edu' is not available"
test_logout (test.test_imaplib.RemoteIMAPTest) ... skipped "Resource 
'cyrus.andrew.cmu.edu' is not available"
test_logincapa (test.test_imaplib.RemoteIMAP_SSLTest) ... skipped "Resource 
'cyrus.andrew.cmu.edu' is not available"
test_logout (test.test_imaplib.RemoteIMAP_SSLTest) ... skipped "Resource 
'cyrus.andrew.cmu.edu' is not available"
test_logincapa (test.test_imaplib.RemoteIMAP_STARTTLSTest) ... skipped 
"Resource 'cyrus.andrew.cmu.edu' is not available"
test_logout (test.test_imaplib.RemoteIMAP_STARTTLSTest) ... skipped "Resource 
'cyrus.andrew.cmu.edu' is not available"
skipped "Resource 'news.trigofacile.com' is not available"
skipped "Resource 'nntp.aioe.org' is not available"
test_connect (test.test_smtpnet.SmtpSSLTest) ... skipped "Resource 
'smtp.gmail.com' is not available"
test_connect_default_port (test.test_smtpnet.SmtpSSLTest) ... skipped "Resource 
'smtp.gmail.com' is not available"
test_connect_using_sslcontext (test.test_smtpnet.SmtpSSLTest) ... skipped 
"Resource 'smtp.gmail.com' is not available"
test_connect_using_sslcontext_verified (test.test_smtpnet.SmtpSSLTest) ... 
skipped "Resource 'smtp.gmail.com' is not available"
test_connect_starttls (test.test_smtpnet.SmtpTest) ... skipped "Resource 
'smtp.gmail.com' is not available"
test_get_server_certificate_ipv6 (test.test_ssl.NetworkedTests) ... skipped 
"Resource 'ipv6.google.com' is not available"
test_idna (test.test_socket.GeneralModuleTests) ... skipped "Resource 
'python.org' is not available"
testAcceptTimeout (test.test_timeout.TCPTimeoutTestCase) ... skipped "Resource 
'www.python.org.' is not available"
testConnectTimeout (test.test_timeout.TCPTimeoutTestCase) ... skipped "Resource 
'www.python.org.' is not available"
testRecvTimeout (test.test_timeout.TCPTimeoutTestCase) ... skipped "Resource 
'www.python.org.' is not available"
testSend (test.test_timeout.TCPTimeoutTestCase) ... skipped "Resource 
'www.python.org.' is not available"
testSendall (test.test_timeout.TCPTimeoutTestCase) ... skipped "Resource 
'www.python.org.' is not available"
testSendto (test.test_timeout.TCPTimeoutTestCase) ... skipped "Resource 
'www.python.org.' is not available"
test_issue16464 (test.test_urllib2.MiscTests) ... skipped "Resource 
'http://www.example.com/' is not available"

--

___
Python tracker 

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



[issue35584] Wrong statement about ^ in howto/regex.rst

2019-02-19 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee: docs@python -> rhettinger

___
Python tracker 

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



[issue35155] Clarify Protocol Handlers in urllib.request Docs

2019-02-19 Thread Denton Liu


Denton Liu  added the comment:

If there aren't anymore comments, I think this PR is ready for a second round 
of reviews.

Thanks!

--

___
Python tracker 

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



[issue36033] logging.makeLogRecord should update "rv" using a dict defined with bytes instead of strings

2019-02-19 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Sorry, I don't get the report. Can you please add a short reproducer script 
with a description of the current behavior and the expected behavior?

--
nosy: +xtreak

___
Python tracker 

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



[issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.

2019-02-19 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue36037] test_ssl fails on RHEL8 strict OpenSSL configuration

2019-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, Python 3.7 and 3.8 (master) have been fixed.

See bpo-35925 (and bpo-36005) for discussions on Python 2.7 and 3.6.

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

___
Python tracker 

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



[issue36037] test_ssl fails on RHEL8 strict OpenSSL configuration

2019-02-19 Thread miss-islington


miss-islington  added the comment:


New changeset e8bf04de4ba045029aa8964126d8cdd2d7c282a6 by Miss Islington (bot) 
in branch '3.7':
bpo-36037: Fix test_ssl for strict OpenSSL policy (GH-11940)
https://github.com/python/cpython/commit/e8bf04de4ba045029aa8964126d8cdd2d7c282a6


--
nosy: +miss-islington

___
Python tracker 

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



[issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.

2019-02-19 Thread BTaskaya


Change by BTaskaya :


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

___
Python tracker 

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



[issue36027] Consider adding modular multiplicative inverse to the math module

2019-02-19 Thread Berry Schoenmakers


Berry Schoenmakers  added the comment:

> Is there a clear reason for your expectation that the xgcd-based algorithm 
> should be faster?

Yeah, good question. Maybe I'm assuming too much, like assuming that it should 
be faster;) It may depend a lot on the constants indeed, but ultimately the 
xgcd style should prevail.

So the pow-based algorithm needs to do log(p) full-size muls, plus log(p) 
modular reductions. Karatsuba helps a bit to speed up the muls, but as far as I 
know it only kicks in for quite sizeable inputs. I forgot how Python is dealing 
with the modular reductions, but presumably that's done without divisions.

The xgcd-based algorithm needs to do a division per iteration, but the numbers 
are getting smaller over the course of the algorithm. And, the worst-case 
behavior occurs for things involving Fibonacci numbers only. In any case, the 
overall bit complexity is quadratic, even if division is quadratic. There may 
be a few expensive divisions along the way, but these also reduce the numbers a 
lot in size, which leads to good amortized complexity for each iteration.

--

___
Python tracker 

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



[issue36042] Setting __init_subclass__ and __class_getitem__ methods are in runtime doesnt make them class method.

2019-02-19 Thread BTaskaya


New submission from BTaskaya :

CPython only makes these methods class method when a class created. If you set 
__class_getitem__ method after the creation it doesn't work unless you use 
classmethod decorator manually.

>>> class B:
... pass
... 
>>> def y(*a, **k):
... return a, k
... 
>>> B.__class_getitem__ = y 
>>> B[int]
((,), {})
>>> B.__class_getitem__ = classmethod(y)
>>> B[int]
((, ), {})

--
messages: 335985
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Setting __init_subclass__ and __class_getitem__ methods are in runtime 
doesnt make them class method.
type: behavior

___
Python tracker 

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



[issue36011] ssl - tls verify on Windows fails

2019-02-19 Thread Steve Dower


Steve Dower  added the comment:

Thanks.

This is a well-known and long-standing issue between OpenSSL and Windows, and 
the best workaround right now is to use the Mozilla certs directly.

One day when OpenSSL is no longer part of the CPython public API, then we can 
consider switching to an HTTP implementation that uses the operating system 
support (which in my experimentation is 2-3x faster than using OpenSSL anyway, 
but a *big* breaking change for a lot of code). Until then, use the options 
provided by OpenSSL to enable it to verify what you need.

--

___
Python tracker 

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



[issue35941] ssl.enum_certificates() regression

2019-02-19 Thread Steve Dower


Steve Dower  added the comment:

The PR requires PEP 7 to be applied thoroughly, but I think the concept is 
sound enough.

--
nosy: +nr

___
Python tracker 

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



[issue36028] Integer Division discrepancy with float

2019-02-19 Thread Au Vo


Au Vo  added the comment:

thanks for the clarification. You have been a great help. Love Python and our 
supportive community!

--

___
Python tracker 

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



[issue36040] Python\ast.c(3875): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int'

2019-02-19 Thread Steve Dower


Steve Dower  added the comment:

Eh, just needs to change the local variable to Py_ssize_t. This applies to all 
platforms.

Might be worth asserting that it is no bigger than the largest number of child 
tokens a node may have, but only if we have an arbitrary limit for that 
somewhere (I *believe* that's what it's doing here, but ast.c isn't a file that 
I understand well).

--
keywords: +easy (C)

___
Python tracker 

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



[issue36037] test_ssl fails on RHEL8 strict OpenSSL configuration

2019-02-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11966

___
Python tracker 

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



[issue36037] test_ssl fails on RHEL8 strict OpenSSL configuration

2019-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 3ef6344ee53f59ee86831ec36ed2c6f93a56229d by Victor Stinner in 
branch 'master':
bpo-36037: Fix test_ssl for strict OpenSSL policy (GH-11940)
https://github.com/python/cpython/commit/3ef6344ee53f59ee86831ec36ed2c6f93a56229d


--

___
Python tracker 

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



[issue36021] [Security][Windows] webbrowser: WindowsDefault uses os.startfile() and so can be abused to run arbitrary commands

2019-02-19 Thread Steve Dower


Steve Dower  added the comment:

The most I'd be okay with doing here is filtering for "://" in the 
webbrowser module, and not limiting "scheme" at all except that it must be a 
valid scheme.

Windows allows apps and programs to extend protocol handling in 
HKEY_CLASSES_ROOT\PROTOCOLS\Handler and os.startfile() should respect this 
list, even while some browsers may handle more protocols that are not 
registered here. So there's really no way to limit the scheme sensibly.

And yeah, anyone can take an arbitrary local or remote path and rewrite it as 
"file:///". That's a feature :)

Perhaps we should add a warning to the docs that by default, webbrowser will 
open a URL with the user's associated program, and while this is generally the 
desirable behavior, if you want to enforce a particular browser then you should 
.get() it first?

--

___
Python tracker 

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



[issue36020] HAVE_SNPRINTF and MSVC std::snprintf support

2019-02-19 Thread Steve Dower


Steve Dower  added the comment:

We don't support older versions of MSVC at this point, so the version check 
seems unnecessary.

If we need to alias these within the CPython sources for non-MSVC compilers, 
then we should do it in source files. In general, we never want to pollute the 
user's namespace with aliases like this - when we do, it should get a "_Py_" 
prefix and ideally be behind one of the Py_BUILD_CORE variables.

So I'd rather see a change to remove those definitions from the header files 
and put them closer to where they belong. If that's too many places, they can 
go into an internal header with "_Py_" prefix and update all uses.

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



[issue33935] shutil.copyfile throws incorrect SameFileError on Google Drive File Stream

2019-02-19 Thread Steve Dower


Steve Dower  added the comment:

Would it make sense to add a parameter to _getfinalpathname that specifies the 
type of the path? For same[open]file(), we can probably just go to the most 
unreadable but broadly supported type, whereas the other functions that are 
actually going to return the path can work their way up through easiest-to-read 
options.

I like the proposed logic for st_dev and st_ino, though I don't see any value 
in testing the drive name separately. At that point we've already gone to the 
filesystem driver, so any chances of doing it fast are gone and we may as well 
have simpler logic that goes straight to the full path.

--
versions:  -Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue36027] Consider adding modular multiplicative inverse to the math module

2019-02-19 Thread Mark Dickinson


Mark Dickinson  added the comment:

> Then, it should be considerably faster

Why would you expect that? Both algorithms involve a number of (bigint) 
operations that's proportional to log(p), so it's going to be down to the 
constants involved and the running times of the individual operations. Is there 
a clear reason for your expectation that the xgcd-based algorithm should be 
faster?

Remember that Python has a subquadratic multiplication (via Karatsuba), but its 
division algorithm has quadratic running time.

--

___
Python tracker 

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



[issue36041] email: folding of quoted string in display_name violates RFC

2019-02-19 Thread Aaryn Tonita


New submission from Aaryn Tonita :

When using a policy for an EmailMessage that triggers folding (during 
serialization) of a fairly long display_name in an address field, the folding 
process removes the quotes from the display name breaking the semantics of the 
field.

In particular, for a From address's display name like r'anyth...@anything.com ' 
+ 'a' * MAX_LINE_LEN the folding puts anyth...@anything.com unquoted 
immediately after the From: header. For applications that do sender 
verification inside and then send it to an internal SMTP server that does not 
perform its own sender verification this could be considered a security issue 
since it enables sender spoofing. Receiving mail servers might be able to 
detect the broken header, but experiments show that the mail gets delivered.

Simple demonstration (reproduced in attachment) of issue:

SMTP_POLICY = email.policy.default.clone(linesep='\r\n', max_line_length=72)
address = Address(display_name=r'anyth...@anything.com ' + 'a' * 72, 
addr_spec='d...@local.startmail.org')

message = EmailMessage(policy=SMTP_POLICY)
message['From'] = Address(display_name=display_name, addr_spec=addr_spec)

# Trigger folding (via as_string()), then parse it back in.
msg_string = message.as_string()
msg_bytes = msg_string.encode('utf-8')
msg_deserialized = BytesParser(policy=SMTP_POLICY).parsebytes(msg_bytes)

# Verify badness
from_hdr = msg_deserialized['From']
assert from_hdr != str(address)  # But they should be equal...

--
components: email
files: address_folding_bug.py
messages: 335975
nosy: aaryn.startmail, barry, r.david.murray
priority: normal
severity: normal
status: open
title: email: folding of quoted string in display_name violates RFC
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48155/address_folding_bug.py

___
Python tracker 

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



[issue36040] Python\ast.c(3875): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int'

2019-02-19 Thread STINNER Victor


New submission from STINNER Victor :

Example on AMD64 Windows8.1 Non-Debug 3.x buildbot:
https://buildbot.python.org/all/#/builders/12/builds/2024

2>d:\buildarea\3.x.ware-win81-release\build\python\ast.c(3875): warning C4244: 
'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data 
[D:\buildarea\3.x.ware-win81-release\build\PCbuild\pythoncore.vcxproj]

--
components: Windows
messages: 335974
nosy: paul.moore, steve.dower, tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: Python\ast.c(3875): warning C4244: 'initializing': conversion from 
'Py_ssize_t' to 'int'
type: compile error
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



[issue36039] Replace append loops with list comprehensions

2019-02-19 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

In some places, using a lot is also a deliberate choice to improve readability.

I think the boy scout rule is more appropriate for such changes.

--
nosy: +remi.lapeyre

___
Python tracker 

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



  1   2   3   >