[issue41835] Speed up dict vectorcall creation using keywords

2020-09-22 Thread Inada Naoki


Inada Naoki  added the comment:

I have a Linux desktop machine for benchmarking & profiling in my office. But 
the machine is offline and I am working from home several weeks.
So please wait several weeks until I confirm your branch.

> This change speeds up the code up to a 30%. Tested with:
>
>  python -m timeit -n 2000  --setup "from uuid import uuid4 ; o =
>  {str(uuid4()).replace('-', '') : str(uuid4()).replace('-', '') for i
>  in range(1)}" "dict(**o)"

`dict(**o)` is not common use case. Could you provide some other benchmarks?

--

___
Python tracker 

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



Re: Importing from within package

2020-09-22 Thread Abdur-Rahmaan Janhangeer
Greetings list,

In case this might help, i am on Python3.8 and running in a virtual env
This command also does not work:
python -m shopyo new . test2

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

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


Re: Python 3.8.5 Not Launching

2020-09-22 Thread Igor Korot
Hi,

On Tue, Sep 22, 2020 at 11:25 PM  wrote:
>
>Hi,
>
>
>
>I installed Python 3.8.5 on Windows 10
>
>When I click on a python file it launches the program but it closes
>immediately.

What is the content of this file?
Is it a py or pyc file?

Thank you.

>
>
>
>Please help, thanks.
>
>
>
>Yehudis Gruber
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue35144] TemporaryDirectory clean-up fails with unsearchable directories

2020-09-22 Thread Eryk Sun


Eryk Sun  added the comment:

It seems to me that if `path == name`, then resetperms(path) and possibly a 
recursive call are only needed on the first call. In subsequent calls, if `path 
== name`, then we know that resetperms(path) was already called, so it 
shouldn't handle PermissionError. If resetperms was ineffective (e.g. in 
Windows, a sharing violation or custom discretionary/mandatory permissions), or 
if something else changed the permissions in the mean time, just give up 
instead of risking a RecursionError or stack overflow. For example:


@classmethod
def _rmtree(cls, name, first_call=True):
resetperms_funcs = (_os.unlink, _os.rmdir, _os.scandir, _os.open)

def resetperms(path):
try:
_os.chflags(path, 0)
except AttributeError:
pass
_os.chmod(path, 0o700)

def onerror(func, path, exc_info):
if (issubclass(exc_info[0], PermissionError) and
  func in resetperms_funcs and (first_call or path != name)):
try:
if path != name:
resetperms(_os.path.dirname(path))
resetperms(path)
try:
_os.unlink(path)
# PermissionError is raised on FreeBSD for directories
except (IsADirectoryError, PermissionError):
cls._rmtree(path, first_call=False)
except FileNotFoundError:
pass
elif issubclass(exc_info[0], FileNotFoundError):
pass
else:
raise

_shutil.rmtree(name, onerror=onerror)

--
nosy: +eryksun

___
Python tracker 

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



Re: Importing from within package

2020-09-22 Thread Chris Angelico
On Wed, Sep 23, 2020 at 2:16 PM Terry Reedy  wrote:
>
> On 9/22/2020 8:31 PM, Chris Angelico wrote:
> > On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber  
> > wrote:
> >>
> >> On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer
> >>  declaimed the following:
> >>
> >>> I have this main script:
> >>> https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py
> >>>
> >>
> >>  Well, that file name scares me...
> >>
> >>  __main__ is the name Python uses internally for the, well, main 
> >> program
> >> (whatever the real file name is), and becomes part of the convention
> >>
> >> if __name__ == "__main__":
> >>  #running as stand-alone program
> >>  #do stuff
> >>
> >> where imported files will appear with the name by which they were imported.
> >>
> >
> > In a package, __main__.py does that same job.
>
> I am not sure of your intended meaning.
>
> Assume that director 'mypac' is in a directory on sys.path.  Forget
> namespace packages, which I have not studied.
> 'import mypac' within code imports mypac/__init__.py
> 'python -m mypac' on a command line runs mypac/__main__.py
>
> Example: .../pythonxy/lib/idlelib. lib is on sys.path.
> idlelib/__init__.py is nearly empty.
> idlelib/__main__.py starts IDLE,
> so 'python -m idlelib' on a command line starts idle.
>

Correct. I was a bit too brief there, but Terry's elaboration is what
I was getting at: that __main__.py is a valid and normal member of a
package, and will be used as the entry point.

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


Python 3.8.5 Not Launching

2020-09-22 Thread yehudisgru
   Hi,

    

   I installed Python 3.8.5 on Windows 10

   When I click on a python file it launches the program but it closes
   immediately.

    

   Please help, thanks.

    

   Yehudis Gruber

    

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


Re: List Partition Comprehension (Feature Suggestion)

2020-09-22 Thread Terry Reedy

On 9/22/2020 3:16 PM, Yakov Shalunov wrote:

Python list comprehension is substantially faster than plan iteration, to the 
point where
```
l0, l1 = [],[]
for x in l:
 if cond(x):
 l0.append(x)
 else:
 l1.append(x)
```
runs at about the same speed as
```
l0 = [x for x in l if cond(x)]
l1 = [x for x in l if not cond(x)]
```
assuming `cond` is a computationally light conditional.
While this isn't an extremely common use, I suggest a "partition comprehension" 
syntax which extends normal filtered-generator syntax. Such as:
```
l0, l1 = ([x for x in l if cond(x) else x])
```
(parenthesis there to indicate that the output is a tuple)


Parentheses only make a tuple when empty.  They otherwise group items as 
function arguments or to indicate precedence.


'else' by itself would be enough to indicate that one wants two streams, 
even if it is a bit baroque.


'x for x in iterable if condition' is a generator comprehension. 
Putting {} or [] around it says to run the iteration to make a set or 
list.  Passing the generator comprehension to set() or list() has the 
same effect, but the set or list comprehensions can be optimized to run 
faster.


'x:f(x) for x in iterable' is not quite legal as a standalone generator, 
but '(x,f(x)} for x in iterable' is, and {x:f(x) for x in iterable} has 
the effect of

dict((x,f(x)) for x in iterable).

By analogy,
'ftrue(x) for x in iterable if condition else ffalse(x)'
should be a double generator comprehension producing a pair of generators
'(f(x) for x in iterable if condition),
 (f(x) for x in iterable if not condition)'

Then enclosing in {} or [] applies set() or list() to each separately to 
produce a pair of sets or lists.  But the latter could be optimized.


The double generator comprehension is similar to a conditional 
expression except that both true and false values are produced -- and 
kept separate.

'(ft(x) if condition else ff(x)) for x in iterable'
is legal today, but does not separate the true and false results.

--
Terry Jan Reedy

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


Re: Importing from within package

2020-09-22 Thread Terry Reedy

On 9/22/2020 8:31 PM, Chris Angelico wrote:

On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber  wrote:


On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer
 declaimed the following:


I have this main script:
https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py



 Well, that file name scares me...

 __main__ is the name Python uses internally for the, well, main program
(whatever the real file name is), and becomes part of the convention

if __name__ == "__main__":
 #running as stand-alone program
 #do stuff

where imported files will appear with the name by which they were imported.



In a package, __main__.py does that same job.


I am not sure of your intended meaning.

Assume that director 'mypac' is in a directory on sys.path.  Forget 
namespace packages, which I have not studied.

'import mypac' within code imports mypac/__init__.py
'python -m mypac' on a command line runs mypac/__main__.py

Example: .../pythonxy/lib/idlelib. lib is on sys.path.
idlelib/__init__.py is nearly empty.
idlelib/__main__.py starts IDLE,
so 'python -m idlelib' on a command line starts idle.


--
Terry Jan Reedy

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


[issue35767] unittest loader doesn't work with partial test functions

2020-09-22 Thread Jason Fried


Change by Jason Fried :


--
resolution:  -> fixed

___
Python tracker 

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



[issue35767] unittest loader doesn't work with partial test functions

2020-09-22 Thread Jason Fried


Change by Jason Fried :


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



[issue37062] `AutoNumber` class in enum documentation: support *args in constructor

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 64362c2e435eddc5e84cea313d92bc0b96d227f7 by Miss Islington (bot) 
in branch '3.9':
bpo-37062: Enum: add extended AutoNumber example (GH-22349) (GH-22370)
https://github.com/python/cpython/commit/64362c2e435eddc5e84cea313d92bc0b96d227f7


--

___
Python tracker 

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



[issue37062] `AutoNumber` class in enum documentation: support *args in constructor

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you, Reuben!

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



[issue37062] `AutoNumber` class in enum documentation: support *args in constructor

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 5acc1b5f0b62eef3258e4bc31eba3b9c659108c9 by Miss Islington (bot) 
in branch '3.8':
bpo-37062: Enum: add extended AutoNumber example (GH-22349) (GH-22369)
https://github.com/python/cpython/commit/5acc1b5f0b62eef3258e4bc31eba3b9c659108c9


--

___
Python tracker 

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



[issue37062] `AutoNumber` class in enum documentation: support *args in constructor

2020-09-22 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21410
pull_request: https://github.com/python/cpython/pull/22370

___
Python tracker 

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



[issue37062] `AutoNumber` class in enum documentation: support *args in constructor

2020-09-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +21409
pull_request: https://github.com/python/cpython/pull/22369

___
Python tracker 

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



Re: Importing from within package

2020-09-22 Thread 黃炳熙
Chris Angelico  writes:

> ...
> In a package, __main__.py does that same job.

Sorry ChrisA, would you please some example? Because i am working in
progress with Python things... 

Sicnerely, Byung-Hee

-- 
^고맙습니다 _布德天下_ 감사합니다_^))//
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue40564] Using zipfile.Path with several files prematurely closes zip

2020-09-22 Thread Jason R. Coombs


Change by Jason R. Coombs :


--
keywords: +patch
pull_requests: +21408
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22371

___
Python tracker 

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



[issue41513] High accuracy math.hypot()

2020-09-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 438e9fc66f664eff0526a16a6d900349bfd1f9d2 by Raymond Hettinger in 
branch 'master':
bpo-41513: Improve order of adding fractional values. Improve variable names. 
(GH-22368)
https://github.com/python/cpython/commit/438e9fc66f664eff0526a16a6d900349bfd1f9d2


--

___
Python tracker 

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



[issue41823] Add more fields to sys.float_info

2020-09-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Given that reliable checks aren't possible, it would still be nice (to have 
flags suchas non_ieee754_detected and double_rounding_detected.  If the flag is 
False it provides no firm guarantees, but it if it is true, it is meaningful.

--

___
Python tracker 

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



Re: List Partition Comprehension (Feature Suggestion)

2020-09-22 Thread Greg Ewing

On 23/09/20 7:16 am, Yakov Shalunov wrote:

l0, l1 = ([x for x in l if cond(x) else x])
l0, l1, l2 = ([x for x in l if cond0(x) else x**2 if cond1(x) else x**3])


This syntax seems a bit convoluted. One of the result expressions
is at the beginning as usual, but the rest are tacked on the end.
And it's far from obvious that it returns multiple lists instead
of a single list with alternative values, as you would get from

[(x if cond0(x) else x**2 if cond1(x) else x**3) for x in l]

which at first glance seems very similar.

Also I'm not sure how this would interact with the existing
comprehension syntax in its full generality, where you can
have multiple "for" and "if" clauses mixed in any order.


A possible alternative would be a partition library function in the
same vein as `map` and `filter`

That sounds like a much better idea for something that is so
rarely needed. Although it probably wouldn't be as fast as an
LC could potentially be, due to the need to call a user-supplied
function for every item.

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


Re: Question from a "java background" developer

2020-09-22 Thread David Lowry-Duda
On Tue, Sep 22, 2020 at 11:13:50AM +0200, Agnese Camellini wrote:
> I mean do i have a keyword to obtain all the methods and the 
> attributes of
> a class in python?

In addition to the `dir()` that others have mentioned, I'll add that 
developing interactively is very common, especially in ipython/jupyter 
sessions or notebooks. With these, you have tab completion or question 
mark documentation.

For example, if you have an instance `myobj` of the class `MyClass`, 
then in an ipython session, typing `myobj.` will open up a list of 
all the methods for objects of `MyClass`. And given an object or 
funcation, appending `?` will bring up the documentation (as given in 
the docstring) for that object or function. This is true even for 
user-defined functions and objects, even if they were defined during the 
same interactive session.

Good luck!

-- 
David Lowry-Duda  
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41837] Upgrade installers to OpenSSL 1.1.1h

2020-09-22 Thread Ned Deily


New submission from Ned Deily :

"22-Sep-2020  OpenSSL 1.1.1h is now available, including bug fixes"

Christian, any changes need in _ssl or any other reasons we should not upgrade?

Changes between 1.1.1g and 1.1.1h [22 Sep 2020]

  *) Certificates with explicit curve parameters are now disallowed in
 verification chains if the X509_V_FLAG_X509_STRICT flag is used.
 [Tomas Mraz]

  *) The 'MinProtocol' and 'MaxProtocol' configuration commands now silently
 ignore TLS protocol version bounds when configuring DTLS-based contexts, 
and
 conversely, silently ignore DTLS protocol version bounds when configuring
 TLS-based contexts.  The commands can be repeated to set bounds of both
 types.  The same applies with the corresponding "min_protocol" and
 "max_protocol" command-line switches, in case some application uses both 
TLS
 and DTLS.
  
 SSL_CTX instances that are created for a fixed protocol version (e.g.
 TLSv1_server_method()) also silently ignore version bounds.  Previously
 attempts to apply bounds to these protocol versions would result in an
 error.  Now only the "version-flexible" SSL_CTX instances are subject to
 limits in configuration files in command-line options.
 [Viktor Dukhovni]

  *) Handshake now fails if Extended Master Secret extension is dropped
 on renegotiation.
 [Tomas Mraz]

--
components: Build, Windows, macOS
messages: 377352
nosy: christian.heimes, ned.deily, paul.moore, ronaldoussoren, steve.dower, 
tim.golden, zach.ware
priority: high
severity: normal
status: open
title: Upgrade installers to OpenSSL 1.1.1h
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



[issue41513] High accuracy math.hypot()

2020-09-22 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +21407
pull_request: https://github.com/python/cpython/pull/22368

___
Python tracker 

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



Re: Importing from within package

2020-09-22 Thread Chris Angelico
On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber  wrote:
>
> On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer
>  declaimed the following:
>
> >I have this main script:
> >https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py
> >
>
> Well, that file name scares me...
>
> __main__ is the name Python uses internally for the, well, main 
> program
> (whatever the real file name is), and becomes part of the convention
>
> if __name__ == "__main__":
> #running as stand-alone program
> #do stuff
>
> where imported files will appear with the name by which they were imported.
>

In a package, __main__.py does that same job.

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


[issue25655] Python errors related to failures loading DLL's lack information

2020-09-22 Thread Steve Dower


Steve Dower  added the comment:

> IMO, the most direct way to resolve the problem is by enabling "loader snaps" 
> for python.exe via gflags and attaching a native debugger to the process ...

This is indeed the best way to go about solving it, so you can see why we don't 
put it in an error message or take responsibility for documenting the process. 
It's not for the faint-hearted :)

Also, the recommended releases of WinDBG (from the Microsoft Store) no longer 
include gflags, though I believe once you're in the debugger it will just break 
at the point where the DLL can't be loaded and it's "simple" to get its 
expected name.

I wouldn't refuse a docs PR to add a short section pointing to this page and 
explaining its relevance: 
https://docs.microsoft.com/cpp/build/reference/dependents

I *would* stop short of writing a whole tutorial on how to do it. That's a 
great topic for someone's blog, and will likely get better SEO and social 
attention from not being in the docs.

--
versions: +Python 3.10 -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



[issue41420] Academic Free License v. 2.1 link is not found and is obsolete

2020-09-22 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

The Adobe form itself also still lists the broken URL. Only Ewa or Betsy can 
fix this, I suppose. I'll write them an email.

--

___
Python tracker 

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



[issue41420] Academic Free License v. 2.1 link is not found and is obsolete

2020-09-22 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

Fixed https://www.python.org/psf/contrib/ to point to 
https://spdx.org/licenses/AFL-2.1.html instead. The contrib-form page 
(https://www.python.org/psf/contrib/contrib-form/) already had this change, but 
the PDF you can download from there still lists the old link.

--
nosy: +lemburg

___
Python tracker 

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



[issue41817] Incorrect types in tkinter.EventType Enum

2020-09-22 Thread Ethan Furman


Change by Ethan Furman :


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



[issue41816] need StrEnum in enum.py

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you for your help, Serhiy!

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



[issue41816] need StrEnum in enum.py

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset d986d1657e1e7b50807d0633cb31d96a2d866d42 by Ethan Furman in 
branch 'master':
bpo-41816: `StrEnum.__str__` is `str.__str__` (GH-22362)
https://github.com/python/cpython/commit/d986d1657e1e7b50807d0633cb31d96a2d866d42


--

___
Python tracker 

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



Re: List Partition Comprehension (Feature Suggestion)

2020-09-22 Thread Yakov Shalunov
A possible alternative would be a partition library function in the same vein 
as `map` and `filter`
```
def partition(n, key, iter):
"""
Partitions a list.
Args: (n: the number of partitions), (key: function which takes elements 
and returns the index of the partition to place them in), (iter: the iterable 
to be partitioned)
Returns: A tuple of lists partitioned per the key function. If this were a 
library function, this would likely return a tuple of generators instead in the 
same vein as `map` and `filter`.
"""
lists = tuple([] for _ in range(n))
for x in iter:
lists[key(x)].append(x)
return lists
```
Except it would be optimized like a library function (which means written in C, 
I believe)

On Tuesday, September 22, 2020 at 12:16:39 PM UTC-7, Yakov Shalunov wrote:
> Python list comprehension is substantially faster than plan iteration, to the 
> point where 
> ``` 
> l0, l1 = [],[] 
> for x in l: 
> if cond(x): 
> l0.append(x) 
> else: 
> l1.append(x) 
> ``` 
> runs at about the same speed as 
> ``` 
> l0 = [x for x in l if cond(x)] 
> l1 = [x for x in l if not cond(x)] 
> ``` 
> assuming `cond` is a computationally light conditional. 
> While this isn't an extremely common use, I suggest a "partition 
> comprehension" syntax which extends normal filtered-generator syntax. Such 
> as: 
> ``` 
> l0, l1 = ([x for x in l if cond(x) else x]) 
> ``` 
> (parenthesis there to indicate that the output is a tuple) 
> It could allow extension to n-way partitions as well. Because elif doesn't 
> fit nicely in-line, it would probably be nicer to do it like: 
> ``` 
> l0, l1, l2 = ([x for x in l if cond0(x) else x**2 if cond1(x) else x**3]) 
> ``` 
> So l0 would be all elements that match cond0, l1 would be squares of all that 
> match cond1, and l2 would be cubes of everything that matches neither.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41827] 2D array issue

2020-09-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks, Serhiy. That's a better section than I found.

I'm going to close this. @jeetshahj12375: If you can show that this is a bug in 
python, please re-open this issue.

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



List Partition Comprehension (Feature Suggestion)

2020-09-22 Thread Yakov Shalunov
Python list comprehension is substantially faster than plan iteration, to the 
point where
```
l0, l1 = [],[]
for x in l:
if cond(x):
l0.append(x)
else:
l1.append(x)
```
runs at about the same speed as
```
l0 = [x for x in l if cond(x)]
l1 = [x for x in l if not cond(x)]
```
assuming `cond` is a computationally light conditional.
While this isn't an extremely common use, I suggest a "partition comprehension" 
syntax which extends normal filtered-generator syntax. Such as:
```
l0, l1 = ([x for x in l if cond(x) else x])
```
(parenthesis there to indicate that the output is a tuple)
It could allow extension to n-way partitions as well. Because elif doesn't fit 
nicely in-line, it would probably be nicer to do it like:
```
l0, l1, l2 = ([x for x in l if cond0(x) else x**2 if cond1(x) else x**3])
```
So l0 would be all elements that match cond0, l1 would be squares of all that 
match cond1, and l2 would be cubes of everything that matches neither.
-- 
https://mail.python.org/mailman/listinfo/python-list


PyCA cryptography 3.1.1 released

2020-09-22 Thread Paul Kehrer
PyCA cryptography 3.1.1 has been released to PyPI. cryptography
includes both high level recipes and low level interfaces to
common cryptographic algorithms such as symmetric ciphers,
asymmetric algorithms, message digests, X509, key derivation functions, and
much more. We support Python 2.7, Python 3.5+, and PyPy.

Changelog (https://cryptography.io/en/latest/changelog/#v3-1-1):
* Updated Windows, macOS, and manylinux wheels to be compiled with OpenSSL
1.1.1h.

-Paul Kehrer (reaperhulk)
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[issue35764] IDLE: revise calltip doc

2020-09-22 Thread Terry J. Reedy


Change by Terry J. Reedy :


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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 2466a7ae6bb1e4049c3d045a30a0503dda7654c5 by Miss Islington (bot) 
in branch '3.8':
bpo-35764: Rewrite the IDLE Calltips doc section  (GH-22363)
https://github.com/python/cpython/commit/2466a7ae6bb1e4049c3d045a30a0503dda7654c5


--

___
Python tracker 

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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset f27a1577d32f88c959e1ef6d0b12f25b2a54cdca by Miss Islington (bot) 
in branch '3.9':
bpo-35764: Rewrite the IDLE Calltips doc section  (GH-22363)
https://github.com/python/cpython/commit/f27a1577d32f88c959e1ef6d0b12f25b2a54cdca


--

___
Python tracker 

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



[issue41827] 2D array issue

2020-09-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See 
https://docs.python.org/3/faq/programming.html#how-do-i-create-a-multidimensional-list.

--
nosy: +serhiy.storchaka
status: pending -> open

___
Python tracker 

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



Re: Pythonic style

2020-09-22 Thread Chris Angelico
On Wed, Sep 23, 2020 at 3:52 AM Stavros Macrakis  wrote:
>
> Thanks to everyone for the comments, especially Tim Chase for the simple
> and elegant tuple unpacking solution, and Léo El Amri for the detailed
> comments on the variants. Below are some more variants which *don't *use
> tuple unpacking, on the theory that the coding patterns may be useful in
> other cases where unpacking doesn't apply.

When doesn't it apply? Can you elaborate on this? It might be easier
to advise on Pythonic style when the specific requirements are known.

> For me, one of the interesting lessons from all these finger exercises is
> that *for* and unpacking hide a lot of messiness, both the initial *iter* call
> and the exception handling. I don't see any way to eliminate the *iter*,
> but there are ways to avoid the verbose exception handling.

In Python, exception handling IS the way to do these things. Having a
two-part return value rather than using an exception is an unusual
idiom in Python (although it's well known in other languages; I
believe JavaScript does iterators this way, for one).

> Using the second arg to *next*, we get what is arguably a more elegant
> solution:
>
>
> _uniq = []
> def firstg(iterable):
> it = iter(iterable)
> val0 = next(it,_uniq)
> val1 = next(it,_uniq)
> if val0 is not _uniq and val1 is _uniq:
> return val0
> else:
> raise ValueError("first1: arg not exactly 1 long")
>
> But I don't know if the *_uniq* technique is considered Pythonic.

It is when it's needed, but a more common way to write this would be
to have the sentinel be local to the function (since it doesn't need
to be an argument):

def firstg_variant(iterable):
it = iter(iterable)
sentinel = object()
first = next(it, sentinel)
if first is sentinel:
raise ValueError("empty iterable")
second = next(it, sentinel)
if second is not sentinel:
raise ValueError("too many values")
return first

But getting a return value and immediately checking it is far better
spelled "try/except" here. (Note, BTW, that I made a subtle change to
the logic here: this version doesn't call next() a second time if the
first one returned the sentinel. This avoids problems with broken
iterators that raise StopException and then keep going.)

> If *next* were instead defined to return a flag (rather than raising an
> exception), the code becomes cleaner and clearer, something like this:
>
>
> def firsth(iterable):
>   it = iter(iterable)
>   (val0, good0) = next2(it)
>   (val1, good1) = next2(it)  # val1 is dummy
>   if good0 and not good1:
> return val0
>   else:
> raise ValueError("first1: arg not exactly 1 long")
>

IMO this isn't any better than the previous one. You still need a
sentinel, but now you use True and False instead of a special object.
It isn't *terrible*, but it's no advantage either.

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


[issue41827] 2D array issue

2020-09-22 Thread Eric V. Smith


Change by Eric V. Smith :


--
status: open -> pending

___
Python tracker 

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



Re: Pythonic style

2020-09-22 Thread Stavros Macrakis
Thanks to everyone for the comments, especially Tim Chase for the simple
and elegant tuple unpacking solution, and Léo El Amri for the detailed
comments on the variants. Below are some more variants which *don't *use
tuple unpacking, on the theory that the coding patterns may be useful in
other cases where unpacking doesn't apply.

For me, one of the interesting lessons from all these finger exercises is
that *for* and unpacking hide a lot of messiness, both the initial *iter* call
and the exception handling. I don't see any way to eliminate the *iter*,
but there are ways to avoid the verbose exception handling.

Using the second arg to *next*, we get what is arguably a more elegant
solution:


_uniq = []
def firstg(iterable):
it = iter(iterable)
val0 = next(it,_uniq)
val1 = next(it,_uniq)
if val0 is not _uniq and val1 is _uniq:
return val0
else:
raise ValueError("first1: arg not exactly 1 long")


But I don't know if the *_uniq* technique is considered Pythonic.

If *next* were instead defined to return a flag (rather than raising an
exception), the code becomes cleaner and clearer, something like this:


def firsth(iterable):
  it = iter(iterable)
  (val0, good0) = next2(it)
  (val1, good1) = next2(it)  # val1 is dummy
  if good0 and not good1:
return val0
  else:
raise ValueError("first1: arg not exactly 1 long")

# returns (value, validp)

# validp is False if no more values

def next2(iterable):
  try:
val = next(iterable)
  except StopIteration:
return (None, False)
  return (val, True)


(To be clear, I'm *not *suggesting that *next2* replace *next*!)

Thoughts?

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


Re: Question from a "java background" developer

2020-09-22 Thread Dieter Maurer
Chris Angelico wrote at 2020-9-22 19:25 +1000:
>On Tue, Sep 22, 2020 at 7:15 PM Agnese Camellini
> wrote:
>>
>> Hello to everyone, I have a question. I come from a Java background and I
>> would like to develop in python but i'm wondering: is there anything, in
>> python, like Java "reflection"?
>> I mean do i have a keyword to obtain all the methods and the attributes of
>> a class in python?
>
>Yes - introspection can be done by looking at a class's dictionary.
>Check out the dir() function to start exploring!

I find also `help(obj)` very helpful.

The basics behind `help` (a built in function) come from
the `inspect` module. It is very helpful to programmatically inspect
features of Python objects.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Trouble with uninstalling Python 3.8 from windows10

2020-09-22 Thread Malkinson Guy
Hello 
I'm a Python beginner. I installed last week python 3.8 64bit on windows 10 for 
the purpose of working with tiff images. 
I next tried to import PIL (or pil), but was unsuccessful (all stackoverflow 
solutions didn't work either). I next thought this could be due to the python 
version, and wanted to removed the 3.8 in order to install an older version. 
But I can't seem to uninstall: while the uninstaller gives a "successfully 
uninstalled" message, the python is not removed from the list of programs. I 
also tried deleting the python folder itself, this doesn't work. And of course 
have restarted the computer... 
I then tried to modify via the applications list: I didn't receive the option 
of "modify" or "repair", only install. So I proceeded with the installation, 
which failed , error message 0x80070001 
Any ideas how to solve these issues? 
All the best 
Guy 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyOBEX installation problem

2020-09-22 Thread Walter Penn

Johny wrote:

I tried to install PyOBEX


Maybe this one instead?

pip install PyOBEX


see https://pypi.org/project/PyOBEX/

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


[issue41817] Incorrect types in tkinter.EventType Enum

2020-09-22 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21406
pull_request: https://github.com/python/cpython/pull/22367

___
Python tracker 

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



[issue41817] Incorrect types in tkinter.EventType Enum

2020-09-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +21405
pull_request: https://github.com/python/cpython/pull/22366

___
Python tracker 

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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 947adcaa13080790167757664912c3a6c2d4c201 by Terry Jan Reedy in 
branch 'master':
bpo-35764: Rewrite the IDLE Calltips doc section  (GH-22363)
https://github.com/python/cpython/commit/947adcaa13080790167757664912c3a6c2d4c201


--

___
Python tracker 

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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 1.0 -> 2.0
pull_requests: +21403
stage: commit review -> patch review
pull_request: https://github.com/python/cpython/pull/22364

___
Python tracker 

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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21404
pull_request: https://github.com/python/cpython/pull/22365

___
Python tracker 

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



[issue41823] Add more fields to sys.float_info

2020-09-22 Thread Mark Dickinson


Mark Dickinson  added the comment:

Double rounding is a property of how operations on floats are carried out, 
rather than being a property of the float format itself; I'm not sure that it 
belongs in float_info. It's also potentially ill-defined. Right now, as far as 
I *know*, it seems to be the case that our builds of CPython on x86 or x64 
either consistently use x87+extended precision for all floating-point 
operations, or they consistently use SSE2 for all floating-point operations, 
but there's no reason that a build couldn't use SSE2 in some cases and 
x87+extended precision in others. (There are also subtle differences between 
x87+53-bit precision setting and IEEE 754-following SSE2.)

We also don't have any _reliable_ way to tell whether floats use IEEE 754, 
though we do have some ad-hoc ways that seem to work in practice (at least for 
now).

--

___
Python tracker 

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



EuroPython "Ask me Anything"

2020-09-22 Thread M.-A. Lemburg
Dear Community,

we want to try a new experiment and run an “Ask me Anything” (AMA) this
Thursday to answer questions you may have, share our knowledge or help
you in planning your online event.

Some of the topics we can cover:
- our tools research and findings
- our concepts for running an online conference or event
- our experience with running EuroPython online
- what we could do to support you
- how our Zoom license sharing works
- how you can apply for a grant
- how the EuroPython Society works
- how we run the EuroPython organization with fully remote work groups
and, of course, anything else :-)

If you’re interested in joining the call, please send your name and
email to helpd...@europython.eu and we’ll send you the invite for the
call on

* Thursday, Sept 24, starting at 19:30 CEST *

When requesting the invite, please also consider adding any more
detailed questions, so we can better prepare and make the meeting more
effective.

If there is demand, we’ll probably have these calls on a monthly basis
to keep the momentum going.

BTW: We are making our conference resources available on our website, in
case you have missed our blog post earlier this year.

Many thanks.


Help spread the word


Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/post/629951901661790208/europython-ask-me-anything

Tweet:

https://twitter.com/europython/status/1308346430130663426

Thanks,
--
EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


EuroPython "Ask me Anything"

2020-09-22 Thread M.-A. Lemburg
Dear Community,

we want to try a new experiment and run an “Ask me Anything” (AMA) this
Thursday to answer questions you may have, share our knowledge or help
you in planning your online event.

Some of the topics we can cover:
- our tools research and findings
- our concepts for running an online conference or event
- our experience with running EuroPython online
- what we could do to support you
- how our Zoom license sharing works
- how you can apply for a grant
- how the EuroPython Society works
- how we run the EuroPython organization with fully remote work groups
and, of course, anything else :-)

If you’re interested in joining the call, please send your name and
email to helpd...@europython.eu and we’ll send you the invite for the
call on

* Thursday, Sept 24, starting at 19:30 CEST *

When requesting the invite, please also consider adding any more
detailed questions, so we can better prepare and make the meeting more
effective.

If there is demand, we’ll probably have these calls on a monthly basis
to keep the momentum going.

BTW: We are making our conference resources available on our website, in
case you have missed our blog post earlier this year.

Many thanks.


Help spread the word


Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/post/629951901661790208/europython-ask-me-anything

Tweet:

https://twitter.com/europython/status/1308346430130663426

Thanks,
--
EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/

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


Importing from within package

2020-09-22 Thread Abdur-Rahmaan Janhangeer
Greeting list,

I have this main script:
https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py

However, i get errors after package installation
saying:
ImportError: cannot import name 'shopyoapi' from 'shopyo'

I've tried from .shopyoapi also but to no avail.

To reproduce:

python -m pip install shopyo==1.1.45
shopyo new . test2

Thanks!

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

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


[issue41810] Consider reintroducing `types.EllipsisType` for the sake of typing

2020-09-22 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 0d0e9fe2ffc1683758a1985ef6dedeef5ecafdbc by Bas van Beek in 
branch 'master':
bpo-41810: Reintroduce `types.EllipsisType`, `.NoneType` & 
`.NotImplementedType` (GH-22336)
https://github.com/python/cpython/commit/0d0e9fe2ffc1683758a1985ef6dedeef5ecafdbc


--

___
Python tracker 

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



[issue41810] Consider reintroducing `types.EllipsisType` for the sake of typing

2020-09-22 Thread Guido van Rossum


Change by Guido van Rossum :


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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-22 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset a68a2ad19c891faa891904b3da537911cc77df21 by Thomas Grainger in 
branch 'master':
bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module 
(#21956)
https://github.com/python/cpython/commit/a68a2ad19c891faa891904b3da537911cc77df21


--

___
Python tracker 

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



[issue41602] Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)

2020-09-22 Thread Guido van Rossum


Change by Guido van Rossum :


--
resolution:  -> fixed
stage: needs patch -> 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



[issue41828] No longer able to override DATA_UPLOAD_MAX_MEMORY_SIZE outside of settings.py

2020-09-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

No problem. Good luck!

--
resolution:  -> third party
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



[issue41828] No longer able to override DATA_UPLOAD_MAX_MEMORY_SIZE outside of settings.py

2020-09-22 Thread Drew Scholz


Drew Scholz  added the comment:

I think you are right. I'll move this to the Django bug tracker. 

Thank you.

--

___
Python tracker 

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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

xref addition and 'extension' deletion are done already.  Added /* sentence and 
generally edited entry.  A few details have changed.

--
stage: patch review -> commit review
type: enhancement -> behavior
versions: +Python 3.10, Python 3.9 -Python 3.7

___
Python tracker 

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



[issue35764] IDLE: revise calltip doc

2020-09-22 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
keywords: +patch
pull_requests: +21402
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/22363

___
Python tracker 

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



[issue25655] Python errors related to failures loading DLL's lack information

2020-09-22 Thread Eryk Sun


Eryk Sun  added the comment:

> " OSError: [WinError 126] The specified module could not be found" is 
> raised when calling ctypes.CDLL(dll_path) even when this "dll_path" 
> exists... because the error comes from another DLL.

That's the old error. bpo-36085 changed it to FileNotFoundError, with the 
message "Could not find module '%.500S'. Try using the full path with 
constructor syntax." bpo-39393 modified the message to "Could not find module 
'%.500S' (or one of its dependencies). Try using the full path with constructor 
syntax."

IMO, the most direct way to resolve the problem is by enabling "loader snaps" 
for python.exe via gflags and attaching a native debugger to the process. The 
loader outputs debug strings that show the computed DLL search path (from 
LdrpComputeLazyDllPath), each attempt to resolve the dependent DLL to a 
directory in the search path (via LdrpResolveDllName), and the final result 
from loader's work queue (from LdrpProcessWork), which includes the dependent 
DLL that caused loading to fail and the parent module (DLL or EXE) that depends 
on it.

--
nosy: +eryksun

___
Python tracker 

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



[issue41817] Incorrect types in tkinter.EventType Enum

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset ea0711a9f9f207d6d4ca037d90de6ec60db131b0 by Ethan Furman in 
branch 'master':
bpo-41817: use new StrEnum to ensure all members are strings (GH-22348)
https://github.com/python/cpython/commit/ea0711a9f9f207d6d4ca037d90de6ec60db131b0


--

___
Python tracker 

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



[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread Ammar Askar


Ammar Askar  added the comment:

Having the target in the thread name definitely seems like a good idea and 
would help ease debugging, not just for our tests but when printing thread 
objects in general. 

I would agree with the suggestion of placing the counter in there for when 
multiple threads get spawned with the same target or maybe even using names 
like:

  Thread-1 (doit)
  Thread-2
  Thread-3 (print)

might be better just for people who are familiar with them.

--
nosy: +ammar2

___
Python tracker 

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



[issue41832] PyType_FromSpec() should accept tp_doc=NULL

2020-09-22 Thread hai shi


Change by hai shi :


--
nosy: +shihai1991

___
Python tracker 

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



[issue39337] codecs.lookup() ignores non-ASCII characters, whereas encodings.normalize_encoding() copies them

2020-09-22 Thread hai shi


Change by hai shi :


--
pull_requests: +21401
pull_request: https://github.com/python/cpython/pull/22360

___
Python tracker 

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



[issue15500] Python should support exporting thread names to the OS

2020-09-22 Thread STINNER Victor


Change by STINNER Victor :


--
versions: +Python 3.10 -Python 3.9

___
Python tracker 

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



[issue15500] Python should support exporting thread names to the OS

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

bpo-18006 "Set thread name in linux kernel" was marked as a duplicate of this 
issue:

"""
In linux (Since 2.6.9) we can use syscall

prctl(PR_SET_NAME, "Some thread name")

to set thread name to the kernel.
(...)
"""

--
nosy: +vstinner

___
Python tracker 

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



[issue36666] threading.Thread should have way to catch an exception thrown within

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

I consider that this issue as a duplicate of bpo-1230540. Python 3.8 has a new 
threading.excepthook hook which can be used in various ways to decide how to 
handle uncatched thread exceptions.

https://docs.python.org/dev/library/threading.html#threading.excepthook

--
nosy: +vstinner
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Add threading.excepthook() to handle uncaught exceptions raised 
by Thread.run()

___
Python tracker 

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



[issue41816] need StrEnum in enum.py

2020-09-22 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +21400
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/22362

___
Python tracker 

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



[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-15500 "Python should support exporting thread names to the OS".

--

___
Python tracker 

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



[issue35144] TemporaryDirectory clean-up fails with unsearchable directories

2020-09-22 Thread Vidar Fauske


Vidar Fauske  added the comment:

A somewhat easy repro:

Create the temporary directory, add a subdir (not sure if subdir truly 
necessary at this point), use `os.chdir()` to set the cwd to that subdir. Clean 
up the temp dir. The cwd should prevent the deletion because it will be "in 
use".

--

___
Python tracker 

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



[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

> And what if run different threads with the same target or with different 
> targets with the same name?

If multiple Thread objects using the same target (or different targets with the 
same name), they all get the same name using my PR 22357.

> Would not "Thread-3" be more useful in this case?

Well, that's an open question. In my experience, "Thread" name is pretty 
useless.

What if I modify my PR to add "-{counter}" (ex: "func-3" for 
target.__name__="func") to the default name? Reuse _counter().

Pseudo-code:

self._name = str(name)
try:
base_name = target.__name__
except AttributeError:
base_name = "Thread"
if not self._name:
self._name = "{base_name)-{_counter()}"

--

___
Python tracker 

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



[issue25655] Python errors related to failures loading DLL's lack information

2020-09-22 Thread Philippe Ombredanne


Philippe Ombredanne  added the comment:

Eric Smith, you wrote:

> My understanding is that Windows doesn't tell you which DLL is missing. I 
> think the best we could do is append something to the error message saying 
> "or one its dependencies".

If we have such an error message, this means the main DLL exists: the original 
path passed to ctypes exists and is a valid DLL otherwise the message would be 
different. 

So I think that this is always a direct or indirect dependency of that primary 
DLL that would be missing and we could be explicit in the error message.

We could also provide some hints in the error message on how to research the 
issue may be?

--
nosy:  -altendky

___
Python tracker 

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



[issue25655] Python errors related to failures loading DLL's lack information

2020-09-22 Thread Kyle Altendorf


Change by Kyle Altendorf :


--
nosy: +altendky

___
Python tracker 

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



[issue25655] Python errors related to failures loading DLL's lack information

2020-09-22 Thread Philippe Ombredanne


Philippe Ombredanne  added the comment:

>From https://bugs.python.org/issue41836 closed as a dupe of this:

When the dependency of a DLL is missing (at least on Windows) the error " 
OSError: [WinError 126] The specified module could not be found" is raised when 
calling ctypes.CDLL(dll_path) even when this "dll_path" exists... because the 
error comes from another DLL.

These errors are really hard to diagnose because the path of the missing DLL is 
not returned in the exception message. Returning it would help fixing these 
kind of errors quickly.

Researching errors such as this one 
https://github.com/nexB/scancode-toolkit/issues/2236 wastes quite a bit of time 
and would be made a non issue if we had the path in the error message.


and this reply from Eric Smith: https://bugs.python.org/msg377324

> Author: Eric V. Smith (eric.smith) * (Python committer)   Date: 
> 2020-09-22 14:13

> My understanding is that Windows doesn't tell you which DLL is missing. I 
> think the best we could do is append something to the error message saying 
> "or one its dependencies".

--
nosy: +pombredanne

___
Python tracker 

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



[issue41836] Improve ctypes error reporting with missing DLL path

2020-09-22 Thread Philippe Ombredanne


Philippe Ombredanne  added the comment:

Eric, Thanks!
This is IMHO a dupe of https://bugs.python.org/issue25655 in earnest. So I am 
closing this in favor of that and will carry over comments there

--
components:  -Windows
resolution:  -> duplicate
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



[issue25655] Python errors related to failures loading DLL's lack information

2020-09-22 Thread Florian Bruhin


Change by Florian Bruhin :


--
nosy: +The Compiler

___
Python tracker 

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



[issue41836] Improve ctypes error reporting with missing DLL path

2020-09-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

My understanding is that Windows doesn't tell you which DLL is missing. I think 
the best we could do is append something to the error message saying "or one 
its dependencies".

--
components: +Windows
nosy: +eric.smith, paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue40564] Using zipfile.Path with several files prematurely closes zip

2020-09-22 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

I've also created this alternative to option 2:

- https://github.com/jaraco/zipp/tree/bugfix/bpo-40564-mixin

This alternative approach uses a mix-in rather than subclasses, creating a new 
class on-demand. I was hoping this approach would enable just augmenting the 
instance rather than affecting `source.__class__`, but when I got to the 
implementation, I found that `source.__class__` had to be mutated regardless.

This approach does have an advantage over option 2 in that it would support 
other ZipFile subclasses for source. It has the disadvantage in that it creates 
a new subclass for every instance created.

I've thought about it a lot and while I'm not particularly happy with any of 
the approaches, I'm leaning toward option 2.

--

___
Python tracker 

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



[issue41836] Improve ctypes error reporting with missing DLL path

2020-09-22 Thread Florian Bruhin


Change by Florian Bruhin :


--
nosy: +The Compiler

___
Python tracker 

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



[issue41836] Improve ctypes error reporting with missing DLL path

2020-09-22 Thread Kyle Altendorf


Change by Kyle Altendorf :


--
nosy: +altendky

___
Python tracker 

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



[issue41836] Improve ctypes error reporting with missing DLL path

2020-09-22 Thread Philippe Ombredanne


New submission from Philippe Ombredanne :

When the dependency of a DLL is missing (at least on Windows) the error " 
OSError: [WinError 126] The specified module could not be found" is raised when 
calling ctypes.CDLL(dll_path) even when this "dll_path" exists... because the 
error comes from another DLL.

These errors are really hard to diagnose because the path of the missing DLL is 
not returned in the exception message. Returning it would help fixing these 
kind of errors quickly.

Researching errors such as this one 
https://github.com/nexB/scancode-toolkit/issues/2236 wastes quite a bit of time 
and would be made a non issue if we had the path in the error message.

--
components: ctypes
messages: 377322
nosy: pombredanne
priority: normal
severity: normal
status: open
title: Improve ctypes error reporting with missing DLL path
type: enhancement
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



[issue41816] need StrEnum in enum.py

2020-09-22 Thread Ethan Furman


Ethan Furman  added the comment:

>From Serhiy Storchaka:
-
The only exception is StrEnum -- overriding __str__ of str
subclass may be not safe. Some code will call str() implicitly, other
will read the string content of the object directly, and they will be
different.

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

___
Python tracker 

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



[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

And what if run different threads with the same target or with different 
targets with the same name? Would not "Thread-3" be more useful in this case?

for i in range(10):
Thread(target=print, args=(i,)).start()

for i in range(10):
def doit(i=i):
print(i)
Thread(target=doit).start()

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32682] test_zlib improve version parsing

2020-09-22 Thread pmp-p


Change by pmp-p :


--
pull_requests: +21399
pull_request: https://github.com/python/cpython/pull/22361

___
Python tracker 

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



[issue40670] supplying an empty string to timeit causes an IndentationError

2020-09-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 557b9a52edc4445cec293f2cc2c268c4f564adcf by Serhiy Storchaka in 
branch 'master':
bpo-40670: More reliable validation of statements in timeit.Timer. (GH-22358)
https://github.com/python/cpython/commit/557b9a52edc4445cec293f2cc2c268c4f564adcf


--

___
Python tracker 

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



Re: Question from a "java background" developer

2020-09-22 Thread Mats Wichmann
On 9/22/20 3:25 AM, Chris Angelico wrote:
> On Tue, Sep 22, 2020 at 7:15 PM Agnese Camellini
>  wrote:
>>
>> Hello to everyone, I have a question. I come from a Java background and I
>> would like to develop in python but i'm wondering: is there anything, in
>> python, like Java "reflection"?
>> I mean do i have a keyword to obtain all the methods and the attributes of
>> a class in python?
> 
> Yes - introspection can be done by looking at a class's dictionary.
> Check out the dir() function to start exploring!

Without knowing any specifics of what you're looking for you can examine
and modifiy object attributes. Python's dynamic nature makes the
modifying part easy (sometimes I think *too* easy :) ).  Along with
dir(), other functions to read a bit on:

type, isinstance, callable, setattr, getattr as well as the attribute
__dict__.




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


[issue41835] Speed up dict vectorcall creation using keywords

2020-09-22 Thread Marco Sulla


New submission from Marco Sulla :

I've done a PR that speeds up the vectorcall creation of a dict using keyword 
arguments. The PR in practice creates a insertdict_init(), a specialized 
version of insertdict. I quote the comment to the function:

Same to insertdict but specialized for inserting without resizing and for dict 
that are populated in a loop and was empty before (see the empty arg).
Note that resizing must be done before calling this function. If not 
possible, use insertdict(). Furthermore, ma_version_tag is left unchanged, you 
have to change it after calling this function (probably at the end of a loop).

This change speeds up the code up to a 30%. Tested with:

python -m timeit -n 2000  --setup "from uuid import uuid4 ; o =
{str(uuid4()).replace('-', '') : str(uuid4()).replace('-', '') for i
in range(1)}" "dict(**o)"

--
components: Interpreter Core
messages: 377318
nosy: Marco Sulla, inada.naoki
priority: normal
pull_requests: 21398
severity: normal
status: open
title: Speed up dict vectorcall creation using keywords
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



[issue41834] Remove _Py_CheckRecursionLimit variable

2020-09-22 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +21397
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22359

___
Python tracker 

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



[issue41834] Remove _Py_CheckRecursionLimit variable

2020-09-22 Thread STINNER Victor


New submission from STINNER Victor :

_Py_CheckRecursionLimit variable is no longer needed and can be removed.

In Python 3.9, I added a recursion limit per interpreter.

In Python 3.8 and older, it was used by _Py_MakeRecCheck() macro to check for 
recursion error. 

Previously, the _Py_CheckRecursionLimit variable was kept for backward 
compatibility with the stable ABI, but in Python 3.8 and older, 
Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() could not be used with the 
limited C API since these macros accessed PyThreadState structure member, 
whereas the structure is opaque in the limited C API.

Attached PR removed the variable.

---

(3) bpo-40513: Limit made per interpreter.

commit 4e30ed3af06ae655f4cb8aad8cba21f341384250
Author: Victor Stinner 
Date:   Tue May 5 16:52:52 2020 +0200

bpo-40513: Per-interpreter recursion_limit (GH-19929)

Move recursion_limit member from _PyRuntimeState.ceval to
PyInterpreterState.ceval.

* Py_SetRecursionLimit() now only sets _Py_CheckRecursionLimit
  of ceval.c if the current Python thread is part of the main
  interpreter.
* Inline _Py_MakeEndRecCheck() into _Py_LeaveRecursiveCall().
* Convert _Py_RecursionLimitLowerWaterMark() macro into a static
  inline function.

---

(2) bpo-38644: The _Py_CheckRecursionLimit variable was used by 
Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() macros. I converted these 
macros into function calls in Python 3.9:

commit f4b1e3d7c64985f5d5b00f6cc9a1c146bbbfd613
Author: Victor Stinner 
Date:   Mon Nov 4 19:48:34 2019 +0100

bpo-38644: Add Py_EnterRecursiveCall() to the limited API (GH-17046)

Provide Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() as
regular functions for the limited API. Previously, there were defined
as macros, but these macros didn't work with the limited API which
cannot access PyThreadState.recursion_depth field.

Remove _Py_CheckRecursionLimit from the stable ABI.

Add Include/cpython/ceval.h header file.

In pycore_ceval.h, the function is overriden by a macro which points to an 
inline function which uses:

* tstate->recursion_depth
* tstate->interp->ceval.recursion_limit
* tstate->stackcheck_counter (if USE_STACKCHECK macro is defined)

---

(1) bpo-31857: Original change adding the FIXME.

commit 1896793520a49a6f97ae360c0b288967e56b005e
Author: pdox 
Date:   Wed Oct 25 23:03:01 2017 -0700

bpo-31857: Make the behavior of USE_STACKCHECK deterministic (#4098)

This change added the FIXME comment:

/* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
   the stable ABI.  It should be removed therefrom when possible.
*/

--
components: C API
messages: 377317
nosy: vstinner
priority: normal
severity: normal
status: open
title: Remove _Py_CheckRecursionLimit variable
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



[issue35144] TemporaryDirectory clean-up fails with unsearchable directories

2020-09-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you Vidar! I wasn't sure about Windows, but was not able to reproduce 
possible failures. Your report gives a clue.

--

___
Python tracker 

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



[issue40670] supplying an empty string to timeit causes an IndentationError

2020-09-22 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +21396
pull_request: https://github.com/python/cpython/pull/22358

___
Python tracker 

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



[issue41739] test_logging: threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2)

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

I created bpo-41833 "threading.Thread: use target name if the name parameter is 
omitted" to help me to debug this issue.

--

___
Python tracker 

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



[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +21395
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22357

___
Python tracker 

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



[issue41833] threading.Thread: use target name if the name parameter is omitted

2020-09-22 Thread STINNER Victor


New submission from STINNER Victor :

When debugging race conditions in a multithreaded application with many 
threads, it's hard to debug when threads have generic names like "Thread-3".

I propose to use the target name in threading.Thread constructor if the name 
parameter is omitted.


See for example bpo-41739 with "Dangling thread: ": the "Thread-3" name is not helpful. I suspect that the 
bug comes from threading.Thread(target=remove_loop, args=(fn, del_count)): with 
my proposed change, the thread would be called "target=remove_loop", which is 
more helpful than "Thread".

Fall back on _newname() as usual if target.__name__ attribute does not exist.

Attached PR implements this idea.

--
components: Library (Lib)
messages: 377314
nosy: vstinner
priority: normal
severity: normal
status: open
title: threading.Thread: use target name if the name parameter is omitted
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



[issue38225] iscoroutinefunction broken with cython - allow tagging of functions as async?

2020-09-22 Thread Stefan Behnel


Stefan Behnel  added the comment:

FYI, https://github.com/cython/cython/pull/3427 has been merged into Cython. In 
Cython 3.0, compiled coroutines will disguise as non-compiled coroutines, from 
the PoV of asyncio.

Restricting this ticket to Py3.10 since we're rather discussing a new feature 
now.

--
versions: +Python 3.10 -Python 3.7, 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



[issue41739] test_logging: threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2)

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

Previous issues:

* bpo-30131: "test_logging now joins queue threads"
* bpo-30830: test_logging uses threading_setup/cleanup, logging.config.listen() 
calls server_close(), socketserver.ThreadingMixIn.server_close()
* bpo-31235: Fix ResourceWarning in test_logging

--

___
Python tracker 

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



[issue41739] test_logging: threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2)

2020-09-22 Thread STINNER Victor


STINNER Victor  added the comment:

See also https://pythondev.readthedocs.io/unstable_tests.html

--

___
Python tracker 

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



[issue41828] No longer able to override DATA_UPLOAD_MAX_MEMORY_SIZE outside of settings.py

2020-09-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

This seems like a Django specific error, in which case this isn't the correct 
bug tracker to report the problem.

Can you reproduce a problem with just straight Python, without using Django?

--
nosy: +eric.smith

___
Python tracker 

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



  1   2   >