[issue41524] PyOS_mystricmp advances pointers too far

2020-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21088
pull_request: https://github.com/python/cpython/pull/21979

___
Python tracker 

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



[issue41524] PyOS_mystricmp advances pointers too far

2020-08-26 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue41524] PyOS_mystricmp advances pointers too far

2020-08-26 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset 97eaf2b5e5c826b9abe59896a363853bef55c5d9 by wmeehan in branch 
'master':
bpo-41524: fix pointer bug in PyOS_mystr{n}icmp (GH-21845)
https://github.com/python/cpython/commit/97eaf2b5e5c826b9abe59896a363853bef55c5d9


--
nosy: +corona10

___
Python tracker 

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



Re: How do I do this in Python 3 (string.join())?

2020-08-26 Thread Cameron Simpson
On 26Aug2020 15:09, Chris Green  wrote:
>2qdxy4rzwzuui...@potatochowder.com wrote:
>> Join bytes objects with a byte object:
>>
>> b"\n".join(popmsg[1])
>
>Aaahhh!  Thank you (and the other reply).

But note: joining bytes like strings is uncommon, and may indicate that 
you should be working in strings to start with. Eg you may want to 
convert popmsg from bytes to str and do a str.join anyway. It depends on 
exactly what you're dealing with: are you doing text work, or are you 
doing "binary data" work?

I know many network protocols are "bytes-as-text, but that is 
accomplished by implying an encoding of the text, eg as ASCII, where 
characters all fit in single bytes/octets.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why __hash__() does not return an UUID4?

2020-08-26 Thread Cameron Simpson
On 26Aug2020 22:10, Marco Sulla  wrote:
>As title. The reasons that came in my mind are:
>1. speed
>2. security

Various reasons come to mind:
- it is overkill for what __hash__ has to do (computational and feature 
  overkill)
- requires importing the uuid module (overkill again)
- speed
- the hash must be the same each time it is called for a given object, 
  so you'd need to waste space saving a UUID

The requirements for a hash are that:
- it be stable for a given object
- for use in dicts, objects of equal value (via ==) have the same hash

That second is actually a problem for UUID4. Suppose we have 2 
independent objects with the same value - how are you to ensure they 
have the same UUID?

Think through how a hash is used in a hash table - the hash is used to 
distribute values into buckets in a statisticly even fashion, so that 
all the values which are "equal" land in the _same_ bucket. That 
requires coordination of the hash values. Where that matters, you 
compute the hash from the value. UUID4s are not like that.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37149] link to John Shipman's Tkinter 8.5 documentation fails: website no longer available

2020-08-26 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
stage: patch review -> needs patch
versions:  -Python 3.5

___
Python tracker 

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



[issue37149] link to John Shipman's Tkinter 8.5 documentation fails: website no longer available

2020-08-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Pending improving the our docs, I would like to replace the Archive link, which 
is slow to respond.  Issue: there is no copyright notice.  Once might expect it 
to belong to NMT, but they seem to have disowned it by removing the web pages.  
The dead links should be removed from any copy.  The .pdf line in the does work 
at this moment.

If not a work-for-hire, the copyright belonged to Shipman, and now his estate.  
I would not add it to the PSF site without formal permission, but I don't see 
why linking to one unauthorized copy versus another would make much difference.

--
versions: +Python 3.10 -Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

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



[issue17005] Add a topological sort algorithm

2020-08-26 Thread Paddy McCarthy


Paddy McCarthy  added the comment:

Please ignore my earlier Message-id 
<1598493715.04.0.06462575371.issue17...@roundup.psfhosted.org>.

I missed a dependency in cutting down a larger example. Sorry.

--

___
Python tracker 

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



[issue17005] Add a topological sort algorithm

2020-08-26 Thread Paddy McCarthy

Paddy McCarthy  added the comment:

I've been playing with Python 3.9.0rc1 and was looking at a particular graph to 
see when it released tasks for processing.
I ran the following code:

from functools import reduce
from pprint import pprint as pp
from collections import defaultdict
from graphlib import TopologicalSorter
from heapq import heapify, heappush, heappop, heappushpop

print("""
###
### TASK DEPENDENCY 
###

A -> B -> C
↓↓↓
D -> E -> F
""")
graph3 = {"A": {"B", "D"},
  "B": {"C", "E"},
  "C": {"F"},
  "D": {"E"},
  "E": {"F"},
  }
tasktime = {task: 2 for task in 'ABCDEF'}


def simulate(graph, tasktime):
print("\n## NEW SIMULATION")
t = 0
heap = []
heapify(heap)
print("\n# Task runtimes:")
for node, tm in tasktime.items():
print(f"  {node}: {tm}")

print("\n# OUTPUT. (:> for task start times, <: for stop times).\n")
ts = TopologicalSorter(graph)
ts.prepare()
while ts.is_active():
for node in ts.get_ready():
finish = t + tasktime[node]
heappush(heap, (finish, node))
print(f"{'  ' * t}{node}:> @{t}")
t, node = heappop(heap)
print(f"{'  ' * t}{node}<: @{t}")
ts.done(node)

simulate(graph3, tasktime)
tasktime['C'] = 1
simulate(graph3, tasktime)


I got the following output:


###
### TASK DEPENDENCY 
###

A -> B -> C
↓↓↓
D -> E -> F


## NEW SIMULATION

# Task runtimes:
  A: 2
  B: 2
  C: 2
  D: 2
  E: 2
  F: 2

# OUTPUT. (:> for task start times, <: for stop times).

F:> @0
F<: @2
C:> @2
E:> @2
C<: @4
E<: @4
B:> @4
D:> @4
B<: @6
D<: @6
A:> @6
A<: @8

## NEW SIMULATION

# Task runtimes:
  A: 2
  B: 2
  C: 1
  D: 2
  E: 2
  F: 2

# OUTPUT. (:> for task start times, <: for stop times).

F:> @0
F<: @2
C:> @2
E:> @2
  C<: @3
E<: @4
B:> @4
D:> @4
B<: @6
D<: @6
A:> @6
A<: @8
>>> 


Note that in the second simulation, C finish, but B isn't then immediately 
started. I have my own code that also works like this but it isn't optimal.

Thanks guys.

--
nosy: +Paddy McCarthy

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Dong-hee Na

Dong-hee Na  added the comment:

Thanks Łukasz for finanlizing this work :)

--

___
Python tracker 

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thank you for your contribution, Irit!

--

___
Python tracker 

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread Łukasz Langa

Change by Łukasz Langa :


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

___
Python tracker 

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 7361451b97a30de0e758094ac83a1fb1f01ed5bb by Miss Islington (bot) 
in branch '3.9':
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) 
(#21977)
https://github.com/python/cpython/commit/7361451b97a30de0e758094ac83a1fb1f01ed5bb


--

___
Python tracker 

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 641279e6e51b5d2e10d3fbffe6330e47c94c4bb2 by Miss Islington (bot) 
in branch '3.8':
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) 
(#21976)
https://github.com/python/cpython/commit/641279e6e51b5d2e10d3fbffe6330e47c94c4bb2


--

___
Python tracker 

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21086
pull_request: https://github.com/python/cpython/pull/21977

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:

Sorry it took so long, this will get released in Python 3.8.6 and newer.

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



[issue41609] pdb's whatis command reports method as function

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 022bc7572f061e1d1132a4db9d085b29707701e7 by Irit Katriel in 
branch 'master':
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935)
https://github.com/python/cpython/commit/022bc7572f061e1d1132a4db9d085b29707701e7


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 211e4c6e9c1ab60bb2577dda6587fbec79f679b2 by Miss Islington (bot) 
in branch '3.9':
bpo-33660: Fix PosixPath to resolve a relative path on root (#21974)
https://github.com/python/cpython/commit/211e4c6e9c1ab60bb2577dda6587fbec79f679b2


--

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 7475aa2c590e33a47f5e79e4079bca0645e93f2f by Miss Islington (bot) 
in branch '3.8':
bpo-33660: Fix PosixPath to resolve a relative path on root (GH-21975)
https://github.com/python/cpython/commit/7475aa2c590e33a47f5e79e4079bca0645e93f2f


--

___
Python tracker 

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



[issue41624] typing.Coroutine documentation

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 8c58d2a216ca2b5965361df9b8d8944bc7d4854d by MingZhe Hu in branch 
'master':
bpo-41624: fix documentation of typing.Coroutine (GH-21952)
https://github.com/python/cpython/commit/8c58d2a216ca2b5965361df9b8d8944bc7d4854d


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 94ad6c674f7687ef22853cb8d42b440d6b42ddc8 by Łukasz Langa 
(Dong-hee Na) in branch 'master':
bpo-33660: Fix PosixPath to resolve a relative path on root
https://github.com/python/cpython/commit/94ad6c674f7687ef22853cb8d42b440d6b42ddc8


--

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 8.0 -> 9.0
pull_requests: +21083
pull_request: https://github.com/python/cpython/pull/21974

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21084
pull_request: https://github.com/python/cpython/pull/21975

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Petr Viktorin


Change by Petr Viktorin :


--
pull_requests: +21082
pull_request: https://github.com/python/cpython/pull/21973

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Łukasz Langa

Change by Łukasz Langa :


--
nosy: +lukasz.langa
nosy_count: 7.0 -> 8.0
pull_requests: +21081
pull_request: https://github.com/python/cpython/pull/21972

___
Python tracker 

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Manuel Barkhau


Manuel Barkhau  added the comment:

This issue cropped up recently in the black project: 
https://github.com/psf/black/issues/1631

It appears to me that PR 7666 was closed without being merged.

I created https://github.com/python/cpython/pull/21971 before I had found this 
issue.

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



[issue33660] pathlib.Path.resolve() returns path with double slash when resolving a relative path in root directory

2020-08-26 Thread Manuel Barkhau


Change by Manuel Barkhau :


--
nosy: +mbarkhau
nosy_count: 6.0 -> 7.0
pull_requests: +21079
pull_request: https://github.com/python/cpython/pull/21971

___
Python tracker 

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



[issue37149] link to John Shipman's Tkinter 8.5 documentation fails: website no longer available

2020-08-26 Thread Mark Roseman


Mark Roseman  added the comment:

Hello, also (very) late to this party. 

If this would be useful, and unless anyone has any objections, I'd be open to 
hosting a copy of John's material on tkdocs.com. I'd add a header to each page 
explaining it's an unmaintained archive with all the usual caveats. 

That would at least provide a stable place to link to.

--

___
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-08-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Implementing that last option:

```
diff --git a/zipp.py b/zipp.py
index 697d4a9..f244cba 100644
--- a/zipp.py
+++ b/zipp.py
@@ -111,6 +111,7 @@ class CompleteDirs(zipfile.ZipFile):
 
 res = cls.__new__(cls)
 vars(res).update(vars(source))
+res.close = lambda: None
 return res
 
 
```

Does appear to address the issue. I'm not super happy about the implementation, 
though.

--

___
Python tracker 

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



Re: About float/double type number in range.

2020-08-26 Thread Rob Cliffe via Python-list




On 26/08/2020 12:02, Peter J. Holzer wrote:

On 2020-08-26 22:40:36 +1200, dn via Python-list wrote:

On 26/08/2020 19:58, Joel Goldstick wrote:


[...]

<<< Code NB Python v3.8 >>>
def fp_range( start:float, stop:float, step:float=1.0 )->float:
 """Generate a range of floating-point numbers."""
 if stop <= start:
 raise OverflowError( "RangeError: start must be less than stop" )
 x = start
 while x < stop:
 yield x
 x += step

This is almost the same solution as I came up with, but note that this
is not quote the same as what Joel proposed. Repeated addition is not
the same as multiplication with floating point numbers.
To expand on this: it is because floating point numbers cannot represent 
all real numbers exactly.
Repeated addition of a number represented inexactly will drift away from 
the mathematical value.
Example: fp_range(0, 70, 0.07) as written above will yield 1001 numbers 
ending with 69.66 (i.e. approximately, but not quite, 70).
Whereas Peter's version (below) will correctly yield 1000 numbers ending 
with 69.93.
(Even then some numbers are not represented exactly, e.g. the 
last-but-one is 69.860001.)


  


A generator based on Joel's idea would look like this:

def fp_range(start, end, step):
 v = start
 n = int(math.ceil((end - start) / step))
 for i in range(n):
 yield start + i * step



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


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

2020-08-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

I see a few options here:

- Implement CompleteDirs/FastLookup as adapters instead of subclasses, allowing 
the original ZipFile object to represent the state in a single place. This 
approach would likely be slower due to the indirection on all operations 
through the wrapper.
- Instead of constructing a new object and copying the state, CompleteDirs.make 
could mutate the existing ZipFile class, replacing `source.__class__` with the 
new class. This approach is messy and the caller would still need to be aware 
that this change could be applied to the zipfile object.
- Consider this use-case unsupported and document that any ZipFile object 
passed into Path is no longer viable and should not be referenced for another 
purpose.
- Eliminate the class-based performance optimizations and replace them with 
some functional/imperative form. This approach may provide less separation of 
concerns.
- Disable the close-on-delete behavior for the subclasses when state is copied 
from another.

--

___
Python tracker 

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



Re: Why __hash__() does not return an UUID4?

2020-08-26 Thread Chris Angelico
On Thu, Aug 27, 2020 at 7:52 AM Richard Damon  wrote:
>
> On 8/26/20 5:13 PM, 2qdxy4rzwzuui...@potatochowder.com wrote:
> > On 2020-08-26 at 22:10:26 +0200,
> > Marco Sulla  wrote:
> >
> >> As title ...
> > Assuming that the title appears prominently with the content of your
> > email.  For the rest of us:
> >
> > Why __hash__() does not return an UUID4?
> >
> >> ... The reasons that came in my mind are:
> >>
> >> 1. speed
> >> 2. security
> > Correctness?
> >
> > Why would __hash__() return a random number?  An important property of
> > hashes is that if x == y, then hash(x) == hash(y).  If hash(x) and
> > hash(y) were random numbers, then how would this property be maintained?
> >
> > Or do UUID4 mean something else to you than a random number?
>
> Looking up which UUID type 4 is, yes it is a random number, so could
> only be applicable for objects that currently return id(), which could
> instead make id() be a UUID4 (and save it in the object, increasing its
> side)
>

I can't see how this is any benefit over any other definition, but if
someone wants to propose that id() return a UUID4, then that would be
entirely separate from anything regarding hash. As long as there's an
absolute guarantee that the same ID will never be used for two objects
at once, it's fine to generate them any way you like.

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


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

2020-08-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

I suspect the issue lies in how the CompleteDirs.make [replaces one instance 
with 
another](https://github.com/jaraco/zipp/blob/8ad959e61cd4be40baab93528775c2bf03c8f4e1/zipp.py#L112-L114)
 in order to provide a complete list of implied directories and to memoize the 
names lookup.

Because constructing a zipfile.Path object around a zipfile.ZipFile copies the 
underlying state, closing one will have the affect of closing the other.

I believe this issue is the same root issue as issue41350.

--

___
Python tracker 

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



Re: Why __hash__() does not return an UUID4?

2020-08-26 Thread Richard Damon
On 8/26/20 5:13 PM, 2qdxy4rzwzuui...@potatochowder.com wrote:
> On 2020-08-26 at 22:10:26 +0200,
> Marco Sulla  wrote:
>
>> As title ...
> Assuming that the title appears prominently with the content of your
> email.  For the rest of us:
>
> Why __hash__() does not return an UUID4?
>
>> ... The reasons that came in my mind are:
>>
>> 1. speed
>> 2. security
> Correctness?
>
> Why would __hash__() return a random number?  An important property of
> hashes is that if x == y, then hash(x) == hash(y).  If hash(x) and
> hash(y) were random numbers, then how would this property be maintained?
>
> Or do UUID4 mean something else to you than a random number?

Looking up which UUID type 4 is, yes it is a random number, so could
only be applicable for objects that currently return id(), which could
instead make id() be a UUID4 (and save it in the object, increasing its
side)

-- 
Richard Damon

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


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

2020-08-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

I am able to replicate the failure using the ondisk fixture:

```diff
diff --git a/test_zipp.py b/test_zipp.py
index a6fbf39..539d0a9 100644
--- a/test_zipp.py
+++ b/test_zipp.py
@@ -259,3 +259,11 @@ class TestPath(unittest.TestCase):
 def test_implied_dirs_performance(self):
 data = ['/'.join(string.ascii_lowercase + str(n)) for n in 
range(1)]
 zipp.CompleteDirs._implied_dirs(data)
+
+def test_read_does_not_close(self):
+for alpharep in self.zipfile_ondisk():
+with zipfile.ZipFile(alpharep) as file:
+for rep in range(2):
+p_ = zipp.Path(file, 'a.txt')
+with p_.open() as inner:
+print(list(inner))
```

--

___
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-08-26 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

I've attempted to replicate the issue in the 
[zipp](https://github.com/jaraco/zipp) test suite with this test:

```diff
diff --git a/test_zipp.py b/test_zipp.py
index a6fbf39..dc7c8aa 100644
--- a/test_zipp.py
+++ b/test_zipp.py
@@ -259,3 +259,10 @@ class TestPath(unittest.TestCase):
 def test_implied_dirs_performance(self):
 data = ['/'.join(string.ascii_lowercase + str(n)) for n in 
range(1)]
 zipp.CompleteDirs._implied_dirs(data)
+
+def test_read_does_not_close(self):
+for alpharep in self.zipfile_alpharep():
+for rep in range(2):
+p_ = zipp.Path(alpharep, 'a.txt')
+with p_.open() as inner:
+print(list(inner))
```

But the test passes.

--

___
Python tracker 

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



Re: Why __hash__() does not return an UUID4?

2020-08-26 Thread 2QdxY4RzWzUUiLuE
On 2020-08-26 at 22:10:26 +0200,
Marco Sulla  wrote:

> As title ...

Assuming that the title appears prominently with the content of your
email.  For the rest of us:

Why __hash__() does not return an UUID4?

> ... The reasons that came in my mind are:
> 
> 1. speed
> 2. security

Correctness?

Why would __hash__() return a random number?  An important property of
hashes is that if x == y, then hash(x) == hash(y).  If hash(x) and
hash(y) were random numbers, then how would this property be maintained?

Or do UUID4 mean something else to you than a random number?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why __hash__() does not return an UUID4?

2020-08-26 Thread Richard Damon
On 8/26/20 4:10 PM, Marco Sulla wrote:
> As title. The reasons that came in my mind are:
>
> 1. speed
> 2. security

My guess is that the typical use of the value for __hash__() doesn't
need that level of guarantee of uniqueness, so requiring it would be
unnecessarily expensive.

Since the typical use of hash will be followed by a real equality test
if the hashes match, we don't need the level of a UUID

-- 
Richard Damon

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


[issue32751] wait_for(future, ...) should wait for the future (even if a timeout occurs)

2020-08-26 Thread Yury Selivanov


Yury Selivanov  added the comment:


New changeset 57b698886b47bb81c782c2ba80a8a72fe66c7aad by Elvis Pranskevichus 
in branch '3.8':
[3.8] bpo-32751: Wait for task cancel in asyncio.wait_for() when timeout <= 0 
(GH-21895) (#21967)
https://github.com/python/cpython/commit/57b698886b47bb81c782c2ba80a8a72fe66c7aad


--

___
Python tracker 

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



[issue41598] Adding support for rounding modes to builtin round

2020-08-26 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Given that most of commenters don't think this is a good idea, I'm going to 
mark it as closed.  Feel free to continue the discussion on python-ideas.  If 
it gains traction, open this back up and give it more core-developer attention.

--
resolution:  -> rejected
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



[issue38884] __import__ is not thread-safe on Python 3

2020-08-26 Thread Kyle Mulka


Kyle Mulka  added the comment:

Was able to reproduce with Python 3.9.0rc1 using issue38884.zip. macOS 10.15.5

--

___
Python tracker 

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



[issue38884] __import__ is not thread-safe on Python 3

2020-08-26 Thread Kyle Mulka


Change by Kyle Mulka :


--
nosy: +repalviglator
versions: +Python 3.9

___
Python tracker 

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



Why __hash__() does not return an UUID4?

2020-08-26 Thread Marco Sulla
As title. The reasons that came in my mind are:

1. speed
2. security
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41151] Support for new Windows pseudoterminals in the subprocess module

2020-08-26 Thread Chad Smith


Change by Chad Smith :


--
nosy: +cs01

___
Python tracker 

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



[issue39116] StreamReader.readexactly() raises GeneratorExit on ProactorEventLoop

2020-08-26 Thread Guilherme Salgado


Change by Guilherme Salgado :


--
nosy: +salgado

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Initialized: when dlopen on import.

With this I mean import-> dlopen -> dlsym for init function -> call init 
function

--

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2020-08-26 Thread Elvis Pranskevichus


Change by Elvis Pranskevichus :


--
pull_requests: +21078
pull_request: https://github.com/python/cpython/pull/21969

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> What I'm not yet clear on: when is that shared object is initialized and 
> destroyed?

I am assuming that you mean at the Python level and not at the linker level. 
Then:

* Initialized: when dlopen on import.

* Destroyed: never. The interpreter does not dlclose the shared objects.

--

___
Python tracker 

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



[issue32751] wait_for(future, ...) should wait for the future (even if a timeout occurs)

2020-08-26 Thread Elvis Pranskevichus


Change by Elvis Pranskevichus :


--
pull_requests: +21077
pull_request: https://github.com/python/cpython/pull/21968

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Petr Viktorin


Petr Viktorin  added the comment:

> Also, option 1 is virtually equivalent to the state of the _ast module prior 
> to the recent changes except that the symbols are in a shared object instead 
> of the binary or libpython. The advantage here is not moving them out of the 
> shared object, is making them having static storage.

What I'm not yet clear on: when is that shared object is initialized and 
destroyed?

> Would that impact performance considerably?
> Also, adding them into a module that needs access through Python had a 
> bootstrap problem

Only for PyCF_ONLY_AST, which is, AFAIK, not used by the interpreter itself.

--

___
Python tracker 

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



[issue41644] builtin type kwargs

2020-08-26 Thread Joseph Perez


Joseph Perez  added the comment:

That's why it's not an interpreter issue but a lack in the official 
documentation where the signature is documented.
I quote https://docs.python.org/3/library/functions.html#type:
> class type(object)
> class type(name, bases, dict)

The second line should be "class type(name, bases, dict, **kwargs)".

(I've mentioned Pycharm and Mypy, but i think it's a kind of side-effect of the 
incomplete official documentation on which is based their typeshed)

In fact, I've raised this issue because I've found myself needing to 
instantiate a class using `type` and kwargs, and I've not found in the 
documentation an example of it.

--

___
Python tracker 

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



[issue41598] Adding support for rounding modes to builtin round

2020-08-26 Thread Vedran Čačić

Vedran Čačić  added the comment:

Well, of course, but that's possible even now, and people still reach for 
`round`. I guess the problem is that it's too easily accessible. :-)

--

___
Python tracker 

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



Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Terry Reedy

On 8/26/2020 11:10 AM, Chris Green wrote:


I have a simple[ish] local mbox mail delivery module as follows:-

...

It has run faultlessly for many years under Python 2.  I've now
changed the calling program to Python 3 and while it handles most
E-Mail OK I have just got the following error:-

 Traceback (most recent call last):
   File "/home/chris/.mutt/bin/filter.py", line 102, in 
 mailLib.deliverMboxMsg(dest, msg, log)

...

   File "/usr/lib/python3.8/email/generator.py", line 406, in write
 self._fp.write(s.encode('ascii', 'surrogateescape'))
 UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in 
position 4: ordinal not in range(128)


'\ufeff' is the Unicode byte-order mark.  It should not be present in an 
ascii-only 3.x string and would not normally be present in general 
unicode except in messages like this that talk about it.  Read about it, 
for instance, at

https://en.wikipedia.org/wiki/Byte_order_mark

I would catch the error and print part or all of string s to see what is 
going on with this particular message.  Does it have other non-ascii chars?



--
Terry Jan Reedy

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


[issue32751] wait_for(future, ...) should wait for the future (even if a timeout occurs)

2020-08-26 Thread Elvis Pranskevichus


Change by Elvis Pranskevichus :


--
pull_requests: +21076
pull_request: https://github.com/python/cpython/pull/21967

___
Python tracker 

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



Unsubscrip (Re: Another 2 to 3 mail encoding problem)

2020-08-26 Thread Terry Reedy

On 8/26/2020 11:27 AM, Alexa Oña wrote:

Don’t send me more emails



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


Unsubscribe yourself by going to the indicated url.


--
Terry Jan Reedy


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


Re: About float/double type number in range.

2020-08-26 Thread Terry Reedy

On 8/26/2020 6:40 AM, dn via Python-list wrote:

def fp_range( start:float, stop:float, step:float=1.0 )->float:
     """Generate a range of floating-point numbers."""
     if stop <= start:
     raise OverflowError( "RangeError: start must be less than stop" )
     x = start
     while x < stop:
     yield x
     x += step


This only works exactly as expected for fraction steps of k/2**n give 
exactly.  Your only tests used .5 and .25.


print(list(fp_range(0.0, 2.01, .1)))
produces
[0.0, 0.1, 0.2, 0.30004, 0.4, 0.5, 0.6, 0.7, 
0.7999, 0.8999, 0., 
1.0999, 1.2, 1.3, 1.4001, 1.5002, 
1.6003, 1.7004, 1.8005, 
1.9006, 2.0004]


For exact fractional steps, one should use fractions or multiply and 
divide by the denominator, as shown by Joel, after stepping by the 
numerator.



--
Terry Jan Reedy


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


[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

Also, adding them into a module that needs access through Python had a 
bootstrap problem:

Basically:

initializing import system -> initialize codec -> compile -> ast init -> init 
ast module -> 

--

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Also, option 1 is virtually equivalent to the state of the _ast module prior to 
the recent changes except that the symbols are in a shared object instead of 
the binary or libpython. The advantage here is not moving them out of the 
shared object, is making them having static storage.

--

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

>The mod2obj/obj2mod functions, called by e.g. compile(..., PyCF_ONLY_AST), 
>should:
* import the _ast module
* call a Python-accessible function, e.g. _ast._mod2obj


Would that impact performance considerably?

--

___
Python tracker 

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



[issue41645] Typo First Page of Documentation

2020-08-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I don't think that Python, a computer language, IS an approach to OOP. A 
programming language HAS an approach to OOP.

We would say "Python's approach to OOP is ..." so the approach is something 
that belongs to Python, it isn't Python itself.

(My dog's approach to cats is to bark loudly and chase them. It would be wrong 
to say that my dog is to bark loudly and chase cats.)

So the sentence is grammatically correct, inserting an "is" would make it 
incorrect. But perhaps it could be re-written to be more clear? It seems a 
little clumsy to me.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Petr Viktorin


Petr Viktorin  added the comment:

Regarding ac46eb4ad6662cf6d771b20d8963658b2186c48c:
Module states come and go with the modules that contain them; if a 
"get_global_ast_state" or "astmodulestate_global" needs to be accessed from 
outside the module, it shouldn't be module state :/



So, the main issue here is that the AST types are not used only by the _ast 
module, but by the interpreter itself: the compile() builtin and 
Py_CompileStringObject.

I see two ways of fixing this properly:

1. All the classes _ast provides should be built-in, like, say, `function`. 
(Currently, that means they should be static types; later they could be 
per-interpreter.)
The _ast module should merely expose them from Python, like the `types` module 
exposes the function type.
This would mean that calling Py_CompileStringObject with PyCF_ONLY_AST will be 
independent of the _ast module.

2. The mod2obj/obj2mod functions, called by e.g. compile(..., PyCF_ONLY_AST), 
should:
* import the _ast module
* call a Python-accessible function, e.g. _ast._mod2obj
This would mean replacing the _ast module (in sys.modules or through an import 
hook, which you can do from Python code) will affect what AST types will be 
used throughout the interpreter.

--
nosy: +dino.viehland, eric.snow, petr.viktorin

___
Python tracker 

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



Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Michael Torrie
On 8/26/20 9:27 AM, Alexa Oña wrote:
> Don’t send me more emails
>
> https://mail.python.org/mailman/listinfo/python-list
^
Please unsubscribe from the mailing list. Click on the link above.

Thank you.



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


[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2020-08-26 Thread Yury Selivanov


Yury Selivanov  added the comment:


New changeset 6e1954cd8286e083e7f8d09516d91b6b15769a4e by Miss Islington (bot) 
in branch '3.8':
bpo-37658: Fix asyncio.wait_for() to respect waited task status (GH-21894) 
(#21965)
https://github.com/python/cpython/commit/6e1954cd8286e083e7f8d09516d91b6b15769a4e


--

___
Python tracker 

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



[issue41645] Typo First Page of Documentation

2020-08-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

I read it as "It HAS ... data structures and it HAS ... a simple but effective 
approach ...".

So if I were changing it I might add the second "has". Or maybe adding "uses" 
would be better. But I'm not sure it's a great sentence either way.

--
nosy: +eric.smith

___
Python tracker 

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



[issue41548] Tk Window rendering on macOS Big Sur

2020-08-26 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
stage:  -> resolved
status: open -> closed
versions:  -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



[issue41645] Typo First Page of Documentation

2020-08-26 Thread Krishan Agarwal


New submission from Krishan Agarwal :

Grammatical error (parallelism) in Python 3.8.5 documentation, "The Python 
Tutorial". First page first paragraph. The "it" refers to the Python 
programming language. It HAS...data structures and it IS...a simple but 
effective approach...

Currently reads:
Python is an easy to learn, powerful programming language. It has efficient 
high-level data structures and a simple but effective approach to 
object-oriented programming. 

Should read:
Python is an easy to learn, powerful programming language. It has efficient 
high-level data structures and is a simple but effective approach to 
object-oriented programming.

--
assignee: docs@python
components: Documentation
messages: 375945
nosy: docs@python, kagarwal603
priority: normal
severity: normal
status: open
title: Typo First Page of Documentation
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



Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Peter J. Holzer
On 2020-08-26 16:10:35 +0100, Chris Green wrote:
> I'm unearthing a few issues here trying to convert my mail filter and
> delivery programs from 2 to 3!  
> 
> I have a simple[ish] local mbox mail delivery module as follows:-
> 
[...]
> class mymbox(mailbox.mbox):
> def _pre_message_hook(self, f):
> """Don't write the blank line before the 'From '"""
> pass
[...]
> def deliverMboxMsg(dest, msg, log):
[...]
> mbx = mymbox(dest, factory=None)
[...]
> mbx.add(msg)
[...]
> 
> 
> It has run faultlessly for many years under Python 2.  I've now
> changed the calling program to Python 3 and while it handles most
> E-Mail OK I have just got the following error:-
> 
> Traceback (most recent call last):
>   File "/home/chris/.mutt/bin/filter.py", line 102, in 
> mailLib.deliverMboxMsg(dest, msg, log)
>   File "/home/chris/.mutt/bin/mailLib.py", line 52, in deliverMboxMsg
> mbx.add(msg)
>   File "/usr/lib/python3.8/mailbox.py", line 603, in add
> self._toc[self._next_key] = self._append_message(message)
>   File "/usr/lib/python3.8/mailbox.py", line 758, in _append_message
> offsets = self._install_message(message)
>   File "/usr/lib/python3.8/mailbox.py", line 830, in _install_message
> self._dump_message(message, self._file, self._mangle_from_)
>   File "/usr/lib/python3.8/mailbox.py", line 215, in _dump_message
> gen.flatten(message)
>   File "/usr/lib/python3.8/email/generator.py", line 116, in flatten
> self._write(msg)
>   File "/usr/lib/python3.8/email/generator.py", line 181, in _write
> self._dispatch(msg)
>   File "/usr/lib/python3.8/email/generator.py", line 214, in _dispatch
> meth(msg)
>   File "/usr/lib/python3.8/email/generator.py", line 432, in _handle_text
> super(BytesGenerator,self)._handle_text(msg)
>   File "/usr/lib/python3.8/email/generator.py", line 249, in _handle_text
> self._write_lines(payload)
>   File "/usr/lib/python3.8/email/generator.py", line 155, in _write_lines
> self.write(line)
>   File "/usr/lib/python3.8/email/generator.py", line 406, in write
> self._fp.write(s.encode('ascii', 'surrogateescape'))
> UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in 
> position 4: ordinal not in range(128)

The problem is that the message contains a '\ufeff' character (byte
order mark) where email/generator.py expects only ASCII characters.

I see two possible reasons for this:

 * The mbox writing code assumes that all messages with non-ascii
   characters are QP or base64 encoded, and some higher layer uses 8bit
   instead.

 * A mime-part is declared as charset=us-ascii but contains really
   Unicode characters.

Both reasons are weird.

The first would be an unreasonable assumption (8bit encoding has been
common since the mid-1990s), but even if the code made that assumption,
one would expect that other code from the same library honors it.

The second shouldn't be possible: If a message is mis-declared (that
happens) one would expect that the error happens during parsing, not
when trying to serialize the already parsed message. 

But then you haven't shown where msg comes from. How do you parse the
message to get "msg"?

Can you construct a minimal test message which triggers the bug?

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Python

Alexa Oña wrote:

Don’t send me more emails

Obtener Outlook para iOS


You are the one spamming the mailing list with unrelated posts.

STOP.


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


[issue41598] Adding support for rounding modes to builtin round

2020-08-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

If you're using round(str(some_float), digits) and the result is a float, then 
that's a problem, since you're going to round it again for display at some 
point.

If you want a string result, you're better off using format(float, 
format_spec), or f-strings, or str.format() (all of which have the same 
underlying implementation) to do your float-to-string-for-display-purposes work.

I just don't see how getting a binary float via decimal rounding would be 
useful.

--

___
Python tracker 

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



Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Chris Green
To add a little to this, the problem is definitely when I receive a
message with UTF8 (or at least non-ascci) characters in it.  My code
is basically very simple, the main program reads an E-Mail message
received from .forward on its standard input and makes it into an mbox
message as follows:-

msg = mailbox.mboxMessage(sys.stdin.read())

it then does various tests (but doesn't change msg at all) and at the
end delivers the message to my local mbox with:-

mbx.add(msg)

where mbx is an instance of mailbox.mbox.


So, how is one supposed to handle this, should I encode the incoming
message somewhere?

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


[issue40077] Convert static types to PyType_FromSpec()

2020-08-26 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset 31967fd8d0220af84e2698172d1378bffc8cd851 by Dong-hee Na in branch 
'master':
bpo-40077: Convert _operator to use PyType_FromSpec (GH-21954)
https://github.com/python/cpython/commit/31967fd8d0220af84e2698172d1378bffc8cd851


--

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 9de6be4e2ae605a1deb6fa72d5c5f66b07817e4c by Miss Islington (bot) 
in branch '3.9':
bpo-37658: Fix asyncio.wait_for() to respect waited task status (GH-21894) 
(GH-21964)
https://github.com/python/cpython/commit/9de6be4e2ae605a1deb6fa72d5c5f66b07817e4c


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue32751] wait_for(future, ...) should wait for the future (even if a timeout occurs)

2020-08-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 1036ccb55de4abc70837cb46a72ddbb370b8fc94 by Miss Islington (bot) 
in branch '3.9':
bpo-32751: Wait for task cancel in asyncio.wait_for() when timeout <= 0 
(GH-21895) (GH-21963)
https://github.com/python/cpython/commit/1036ccb55de4abc70837cb46a72ddbb370b8fc94


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue41598] Adding support for rounding modes to builtin round

2020-08-26 Thread Vedran Čačić

Vedran Čačić  added the comment:

> Personally, I think I'd rather have easier ways to create Decimal objects

Wouldn't everybody? :-P But that's been proposed at least 4 times already and 
never got anywhere. My proposal is at least original, has a precedent at the 
above link (strings as surogate literals, preserving value across semantic 
boundaries), _and_ comes with a natural scope limitation guarantee: noone can 
argue for '2.1' + '3.5' to be '5.6' (because it is already '2.13.5';), it works 
only in the first argument of round.

Also, the string at that time is not so pointless: many people use round for 
printing, at that point you are going to convert to str anyway. And 
round(str(result), digits) gives a nice way to use python's builtin repr 
capability of "picking the shortest representation" for DWIMming: it's the best 
of both worlds, your implementation DWIMs, but you're not responsible for 
corner cases. ;-=

But no, I'm not going to Python-ideas, for the same reason I'm not going back 
to high school: too many bullies, too hard to get your voice heard, mostly 
because everyone assumes you wouldn't be there if you had anything smart to 
say. :-/

--

___
Python tracker 

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



[issue41644] builtin type kwargs

2020-08-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is rather an issue of MyPy and PyCharm. The Python interpreter itself does 
not perform static type testing and does not provide annotations for builtins.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2020-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21075
pull_request: https://github.com/python/cpython/pull/21965

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2020-08-26 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +21074
pull_request: https://github.com/python/cpython/pull/21964

___
Python tracker 

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



[issue37658] In some cases asyncio.wait_for can lead to socket leak.

2020-08-26 Thread Yury Selivanov


Yury Selivanov  added the comment:


New changeset a2118a14627256197bddcf4fcecad4c264c1e39d by Elvis Pranskevichus 
in branch 'master':
bpo-37658: Fix asyncio.wait_for() to respect waited task status (#21894)
https://github.com/python/cpython/commit/a2118a14627256197bddcf4fcecad4c264c1e39d


--

___
Python tracker 

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



[issue32751] wait_for(future, ...) should wait for the future (even if a timeout occurs)

2020-08-26 Thread Yury Selivanov


Yury Selivanov  added the comment:


New changeset c517fc712105c8e5930cb42baaebdbe37fc3e15f by Elvis Pranskevichus 
in branch 'master':
bpo-32751: Wait for task cancel in asyncio.wait_for() when timeout <= 0 (#21895)
https://github.com/python/cpython/commit/c517fc712105c8e5930cb42baaebdbe37fc3e15f


--

___
Python tracker 

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



[issue32751] wait_for(future, ...) should wait for the future (even if a timeout occurs)

2020-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21073
pull_request: https://github.com/python/cpython/pull/21963

___
Python tracker 

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



[issue41644] builtin type kwargs

2020-08-26 Thread Joseph Perez


New submission from Joseph Perez :

Class definition can have kwargs which are used by `__init_subclass__` (and 
`__prepare__`).
However, passing these kwargs using `type` builtin function instead of class 
definition syntax is not documented; kwargs are not mentioned in the function 
signature.
https://docs.python.org/3/library/functions.html#type

However, passing kwargs to `type` works:
```python
class Foo:
def __init_subclass__(cls, **kwargs):
print(kwargs)
Bar = type("Bar", (Foo,), {}, bar=None) # mypy and Pycharm complain
#> {'bar': None}
```

By the way, the possibility to pass kwargs in `type` call is not documented  in 
https://docs.python.org/3/reference/datamodel.html#customizing-class-creation 
too.

--
assignee: docs@python
components: Documentation
messages: 375936
nosy: docs@python, joperez
priority: normal
severity: normal
status: open
title: builtin type kwargs
versions: Python 3.10, Python 3.6, 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



[issue41598] Adding support for rounding modes to builtin round

2020-08-26 Thread Mark Dickinson


Mark Dickinson  added the comment:

@Vedran:

> I have tons of these ideas, but usually am afraid of voicing them ...

Always good to have ideas brought up, so long as there's no expectation that 
every idea gets implemented. :-) But I think rounding a string is probably 
another one for the python-ideas mailing list. (Personally, I think I'd rather 
have easier ways to create Decimal objects than have strings become a kind of 
proxy for Decimal objects - e.g., `round(2.675d, 2)` rather than 
`round("2.657", 2)`.)

--

___
Python tracker 

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



Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Alexa Oña
Don’t send me more emails

Obtener Outlook para iOS

De: Python-list  
en nombre de Chris Green 
Enviado: Wednesday, August 26, 2020 5:10:35 PM
Para: python-list@python.org 
Asunto: Another 2 to 3 mail encoding problem

I'm unearthing a few issues here trying to convert my mail filter and
delivery programs from 2 to 3!

I have a simple[ish] local mbox mail delivery module as follows:-


import mailbox
import logging
import logging.handlers
import os
import time
#
#
# Class derived from mailbox.mbox so we can override _pre_message_hook()
# to do nothing instead of appending a blank line
#
class mymbox(mailbox.mbox):
def _pre_message_hook(self, f):
"""Don't write the blank line before the 'From '"""
pass
#
#
# log a message
#
def initLog(name):
log = logging.getLogger(name)
log.setLevel(logging.DEBUG)
f = logging.handlers.RotatingFileHandler("/home/chris/tmp/mail.log", 
'a', 100, 4)
f.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - 
%(message)s')
f.setFormatter(formatter)
log.addHandler(f)
return log
#
#
# Deliver a message to a local mbox
#
def deliverMboxMsg(dest, msg, log):
#
#
# Create the destination mbox instance
#
mbx = mymbox(dest, factory=None)

log.info("From: " + msg.get("From", "unknown"))
log.info("Destination is: " + dest)
#
#
# Lock the mbox while we append to it
#
for tries in range(3):
try:
mbx.lock()
#
#
# Append the incoming message to the appropriate mbox
#
mbx.add(msg)
#
#
# now set the modified time later than the access time (which 
is 'now') so
# that mutt will see new mail in the mbox.
#
os.utime(dest, ((time.time()), (time.time() + 5)))
mbx.unlock()
break

except mailbox.ExternalClashError:
log.info("Destination locked, try " + str(tries))
time.sleep(1)

else: # get here if we ran out of tries
log.warn("Failed to lock destination after 3 attempts, giving up")

return


It has run faultlessly for many years under Python 2.  I've now
changed the calling program to Python 3 and while it handles most
E-Mail OK I have just got the following error:-

Traceback (most recent call last):
  File "/home/chris/.mutt/bin/filter.py", line 102, in 
mailLib.deliverMboxMsg(dest, msg, log)
  File "/home/chris/.mutt/bin/mailLib.py", line 52, in deliverMboxMsg
mbx.add(msg)
  File "/usr/lib/python3.8/mailbox.py", line 603, in add
self._toc[self._next_key] = self._append_message(message)
  File "/usr/lib/python3.8/mailbox.py", line 758, in _append_message
offsets = self._install_message(message)
  File "/usr/lib/python3.8/mailbox.py", line 830, in _install_message
self._dump_message(message, self._file, self._mangle_from_)
  File "/usr/lib/python3.8/mailbox.py", line 215, in _dump_message
gen.flatten(message)
  File "/usr/lib/python3.8/email/generator.py", line 116, in flatten
self._write(msg)
  File "/usr/lib/python3.8/email/generator.py", line 181, in _write
self._dispatch(msg)
  File "/usr/lib/python3.8/email/generator.py", line 214, in _dispatch
meth(msg)
  File "/usr/lib/python3.8/email/generator.py", line 432, in _handle_text
super(BytesGenerator,self)._handle_text(msg)
  File "/usr/lib/python3.8/email/generator.py", line 249, in _handle_text
self._write_lines(payload)
  File "/usr/lib/python3.8/email/generator.py", line 155, in _write_lines
self.write(line)
  File "/usr/lib/python3.8/email/generator.py", line 406, in write
self._fp.write(s.encode('ascii', 'surrogateescape'))
UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in 
position 4: ordinal not in range(128)

So what do I need to do to the message I'm adding with mbx.add(msg) to
fix this?  (I assume that's what I need to do).

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


Another 2 to 3 mail encoding problem

2020-08-26 Thread Chris Green
I'm unearthing a few issues here trying to convert my mail filter and
delivery programs from 2 to 3!  

I have a simple[ish] local mbox mail delivery module as follows:-


import mailbox
import logging
import logging.handlers
import os
import time
#
#
# Class derived from mailbox.mbox so we can override _pre_message_hook()
# to do nothing instead of appending a blank line
#
class mymbox(mailbox.mbox):
def _pre_message_hook(self, f):
"""Don't write the blank line before the 'From '"""
pass
#
#
# log a message
#
def initLog(name):
log = logging.getLogger(name)
log.setLevel(logging.DEBUG)
f = logging.handlers.RotatingFileHandler("/home/chris/tmp/mail.log", 
'a', 100, 4)
f.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - 
%(message)s')
f.setFormatter(formatter)
log.addHandler(f)
return log
#
#
# Deliver a message to a local mbox
#
def deliverMboxMsg(dest, msg, log):
#
#
# Create the destination mbox instance
#
mbx = mymbox(dest, factory=None)

log.info("From: " + msg.get("From", "unknown"))
log.info("Destination is: " + dest)
#
#
# Lock the mbox while we append to it
#
for tries in range(3):
try:
mbx.lock()
#
#
# Append the incoming message to the appropriate mbox
#
mbx.add(msg)
#
#
# now set the modified time later than the access time (which 
is 'now') so
# that mutt will see new mail in the mbox.
#
os.utime(dest, ((time.time()), (time.time() + 5)))
mbx.unlock()
break

except mailbox.ExternalClashError:
log.info("Destination locked, try " + str(tries))
time.sleep(1)

else: # get here if we ran out of tries
log.warn("Failed to lock destination after 3 attempts, giving up")

return


It has run faultlessly for many years under Python 2.  I've now
changed the calling program to Python 3 and while it handles most
E-Mail OK I have just got the following error:-

Traceback (most recent call last):
  File "/home/chris/.mutt/bin/filter.py", line 102, in 
mailLib.deliverMboxMsg(dest, msg, log)
  File "/home/chris/.mutt/bin/mailLib.py", line 52, in deliverMboxMsg
mbx.add(msg)
  File "/usr/lib/python3.8/mailbox.py", line 603, in add
self._toc[self._next_key] = self._append_message(message)
  File "/usr/lib/python3.8/mailbox.py", line 758, in _append_message
offsets = self._install_message(message)
  File "/usr/lib/python3.8/mailbox.py", line 830, in _install_message
self._dump_message(message, self._file, self._mangle_from_)
  File "/usr/lib/python3.8/mailbox.py", line 215, in _dump_message
gen.flatten(message)
  File "/usr/lib/python3.8/email/generator.py", line 116, in flatten
self._write(msg)
  File "/usr/lib/python3.8/email/generator.py", line 181, in _write
self._dispatch(msg)
  File "/usr/lib/python3.8/email/generator.py", line 214, in _dispatch
meth(msg)
  File "/usr/lib/python3.8/email/generator.py", line 432, in _handle_text
super(BytesGenerator,self)._handle_text(msg)
  File "/usr/lib/python3.8/email/generator.py", line 249, in _handle_text
self._write_lines(payload)
  File "/usr/lib/python3.8/email/generator.py", line 155, in _write_lines
self.write(line)
  File "/usr/lib/python3.8/email/generator.py", line 406, in write
self._fp.write(s.encode('ascii', 'surrogateescape'))
UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in 
position 4: ordinal not in range(128)

So what do I need to do to the message I'm adding with mbx.add(msg) to
fix this?  (I assume that's what I need to do).

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


[issue41642] RHEL and fedora buildbots fail due to disk space error

2020-08-26 Thread STINNER Victor


STINNER Victor  added the comment:

Statistics on partition which are the most full.

Fedora Rawhide x86-64 is ok:

/dev/mapper/vg_root_python--builder--rawhide.osci.io-root14G5,4G  7,6G  
42% /
/dev/mapper/vg_root_python--builder--rawhide.osci.io-home36G 24G   11G  
70% /home

Fedora Stable x86-64 is ok:

/dev/mapper/vg_root_python--builder2--rawhide.osci.io-root14G7,7G  5,2G 
 60% /
/dev/mapper/vg_root_python--builder2--rawhide.osci.io-home36G 23G   12G 
 67% /home

RHEL8 x86-64 is ok:

/dev/mapper/vg_root_python--builder--rhel8.osci.io-root14G3,5G  9,5G  
27% /
/dev/mapper/vg_root_python--builder--rhel8.osci.io-home36G9,7G   24G  
29% /home

RHEL7 x86-64 is ok:

/dev/mapper/vg_root_python--builder--rhel7.osci.io-root   7,6G3,6G  3,7G  
49% /
/dev/mapper/vg_root_python--builder--rhel7.osci.io-home22G 15G  5,9G  
71% /home

RHEL8 FIPS x86-64 is ok:

/dev/mapper/vg_root_python--builder--rhel8--fips.osci.io-root   15G  2.8G   12G 
 20% /
/dev/mapper/vg_root_python--builder--rhel8--fips.osci.io-home   34G  3.7G   29G 
 12% /home

Fedora Rawhide AArch64 is ok:

/dev/mapper/fedora-root44G 26G   19G  58% /
tmpfs  16G436K   16G   1% /tmp

Fedora Stable AArch64 is ok:

/dev/mapper/fedora-root44G 33G   11G  76% /
tmpfs  16G1,6G   15G  11% /tmp

RHEL7 AArch64 is ok:

/dev/mapper/rhel-root44G 15G   30G  33% /

RHEL8 AArch64 had like 22 GB in /tmp, I removed them. It's now better:

* before: /dev/mapper/rhel-root   44G   41G  3.3G  93% /
* after: /dev/mapper/rhel-root   44G   16G   28G  36% /


Fedora Stable ppc64le /tmp contained 1 GB of temporay files. I removed them. 
Before:

/dev/mapper/fedora-root   45G   29G   17G  63% /
tmpfs4.0G  1.1G  3.0G  27% /tmp

Fedora Rawhide ppc64le is ok:

/dev/mapper/fedora-root   45G   27G   19G  59% /
tmpfs4.0G  384K  4.0G   1% /tmp

RHEL7 ppc64le is ok:

/dev/mapper/rhel-root45G 19G   27G  42% /

RHEL8 ppc64le had 22 GB of old files in /tmp: removed, rebooted. Before:

/dev/mapper/rhel-root   45G   41G  4.2G  91% /

--

___
Python tracker 

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



[issue41598] Adding support for rounding modes to builtin round

2020-08-26 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think we should add this. It will often surprise the user. We get 
enough .1+.2 != .3 reports as it is, and this would be just as problematic.

--
nosy: +eric.smith

___
Python tracker 

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



Re: How do I do this in Python 3 (string.join())?

2020-08-26 Thread Chris Green
2qdxy4rzwzuui...@potatochowder.com wrote:
> On 2020-08-26 at 14:22:10 +0100,
> Chris Green  wrote:
> 
> > I have the following line in Python 2:-
> > 
> > msgstr = string.join(popmsg[1], "\n") # popmsg[1] is a list containing 
> the lines of the message 
> > 
> > ... so I changed it to:-
> > 
> > s = "\n"
> > msgstr = s.join(popmsg[1])  # popmsg[1] is a list containing the 
> > lines of the message
> > 
> > However this still doesn't work because popmsg[1] isn't a list of
> > strings, I get the error:-
> > 
> > TypeError: sequence item 0: expected str instance, bytes found
> > 
> > So how do I do this?  I can see clumsy ways by a loop working through
> > the list in popmsg[1] but surely there must be a way that's as neat
> > and elegant as the Python 2 way was?
> 
> Join bytes objects with a byte object:
> 
> b"\n".join(popmsg[1])

Aaahhh!  Thank you (and the other reply).

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


[issue32313] Wrong inspect.getsource for datetime

2020-08-26 Thread Dong-hee Na


Dong-hee Na  added the comment:

_datetime.datetime's tp_name is datetime.datetime so
inspect module guess that _datetime.datetime's module name is datetime, not 
_datetime.
I don't think we have to fix this issue from inspect module side.

If the _datetime.datetime's tp_name is updated to _datetime.datetime it could 
be fixed but I don't know this is the right approach and there might be some 
reason for choosing tp_name as datetime.datetime instead of _datetime.datetime.

@p-ganssle is the best expert for datetime module :)
I think that he could give the answer to this.

--
nosy: +corona10

___
Python tracker 

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



Re: How do I do this in Python 3 (string.join())?

2020-08-26 Thread MRAB

On 2020-08-26 14:22, Chris Green wrote:

I have the following line in Python 2:-

 msgstr = string.join(popmsg[1], "\n")  # popmsg[1] is a list 
containing the lines of the message

... so I changed it to:-

 s = "\n"
 msgstr = s.join(popmsg[1])  # popmsg[1] is a list containing the lines 
of the message

However this still doesn't work because popmsg[1] isn't a list of
strings, I get the error:-

 TypeError: sequence item 0: expected str instance, bytes found

So how do I do this?  I can see clumsy ways by a loop working through
the list in popmsg[1] but surely there must be a way that's as neat
and elegant as the Python 2 way was?


In Python 3, bytestring literals require the 'b' prefix:

msgstr = b"\n".join(popmsg[1])
--
https://mail.python.org/mailman/listinfo/python-list


Re: How do I do this in Python 3 (string.join())?

2020-08-26 Thread D'Arcy Cain
On 2020-08-26 09:22, Chris Green wrote:
> I have the following line in Python 2:-
> 
> msgstr = string.join(popmsg[1], "\n")  # popmsg[1] is a list 
> containing the lines of the message
> 
> ... so I changed it to:-
> 
> s = "\n"
> msgstr = s.join(popmsg[1])  # popmsg[1] is a list containing the 
> lines of the message
> 
> However this still doesn't work because popmsg[1] isn't a list of
> strings, I get the error:-
> 
> TypeError: sequence item 0: expected str instance, bytes found
> 
> So how do I do this?  I can see clumsy ways by a loop working through
> the list in popmsg[1] but surely there must be a way that's as neat
> and elegant as the Python 2 way was?

Well, the simple fix is to set s to b"\n" but that may not solve all of your
problems.  The issue is that popmsg[1] is a list of bytes.  You probably
want a list of strings.  I would look further back and think about getting a
list of strings in the first place.  Without knowing how popmsg was created
we can't tell you how to do that.

Of course, if a bytes object is what you want then the above will work.  You
can also convert to string after the join.

Cheers.

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
A unit of Excelsior Solutions Corporation - Propelling Business Forward
http://www.VybeNetworks.com/
IM:da...@vybenetworks.com VoIP: sip:da...@vybenetworks.com



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41642] RHEL and fedora buildbots fail due to disk space error

2020-08-26 Thread STINNER Victor


STINNER Victor  added the comment:

python-builder-rawhide had its /tmp partition full of temporary "cc.XXX" 
files. Before: /tmp was full at 100% (3.9 GB). After sudo rm -f /tmp/cc*, only 
52 KB are used (1%).

I'm not sure why gcc/clang left so many temporary files :-/ There are many 
large (22 MB) assembly files (.s).

--

___
Python tracker 

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



Re: How do I do this in Python 3 (string.join())?

2020-08-26 Thread 2QdxY4RzWzUUiLuE
On 2020-08-26 at 14:22:10 +0100,
Chris Green  wrote:

> I have the following line in Python 2:-
> 
> msgstr = string.join(popmsg[1], "\n")  # popmsg[1] is a list 
> containing the lines of the message
> 
> ... so I changed it to:-
> 
> s = "\n"
> msgstr = s.join(popmsg[1])  # popmsg[1] is a list containing the 
> lines of the message
> 
> However this still doesn't work because popmsg[1] isn't a list of
> strings, I get the error:-
> 
> TypeError: sequence item 0: expected str instance, bytes found
> 
> So how do I do this?  I can see clumsy ways by a loop working through
> the list in popmsg[1] but surely there must be a way that's as neat
> and elegant as the Python 2 way was?

Join bytes objects with a byte object:

b"\n".join(popmsg[1])
-- 
https://mail.python.org/mailman/listinfo/python-list


How do I do this in Python 3 (string.join())?

2020-08-26 Thread Chris Green
I have the following line in Python 2:-

msgstr = string.join(popmsg[1], "\n")  # popmsg[1] is a list containing 
the lines of the message

... so I changed it to:-

s = "\n"
msgstr = s.join(popmsg[1])  # popmsg[1] is a list containing the lines 
of the message

However this still doesn't work because popmsg[1] isn't a list of
strings, I get the error:-

TypeError: sequence item 0: expected str instance, bytes found

So how do I do this?  I can see clumsy ways by a loop working through
the list in popmsg[1] but surely there must be a way that's as neat
and elegant as the Python 2 way was?

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


[issue41642] RHEL and fedora buildbots fail due to disk space error

2020-08-26 Thread Charalampos Stratakis


Charalampos Stratakis  added the comment:

There were almost 10GB of remnant cc* files in /tmp from the compilers used, 
which I presume were also the temporary artifacts which remained there after 
the disconnects.

Cleaned those up and rebooted the RHEL8 x86_64 buildbot.

--

___
Python tracker 

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



Re: About float/double type number in range.

2020-08-26 Thread Richard Damon
On 8/25/20 10:39 PM, ADITYA wrote:
>Dear Sir/Ma’am
>
>I am requesting you to satisfy me about float number in Range function,
>because in the argument of range we can take integer but not double or
>float whenever double as well as float are integer in nature but when we
>use double/float in, it gives error that- “'float' object cannot be
>interpreted as an integer.” If we want to increment the number by half or
>quarter what can I do.
>
>For ex- Range(1,3,0.5) I want it gives Output as [1 1.5 2 2.5 3)
>
>I am requesting to change the nature of increment number nature in above
>example so that we can increase the number with half or quarter any point
>value.
>
>Your Sincerely
>
>Aditya Gautam
>Saharsa (Bihar)
>India
>Postal Code- 852201

As was indicated, Range(1, 3, 0.5) if legal would generate ([1, 1.5, 2,
2.5] because range excludes the top value. This case happens to work in
the sense that if Python allowed it, this is the result that would come
out. On the other hand, the very similar Range(1, 3, 0.4) would be need
very detailed knowledge to predict, it could return [1, 1.4, 1.8, 2.2,
2.6] as expected or [1, 1.4, 1.8, 2.2, 2.6, 3.0]. The issue is that
there is no such exact number in binary floating point as 0.4, (it is
like trying to write out exactly 1/3), so the actual value used for 0.4
will be either slightly higher (where you get the expected value) or
slightly lower (where you would get the top 'excluded' value listed).
This sort of unpredictability is part of the difficulty dealing with
floating point.

As was pointed out, you can scale the range, or build your own generator
to get what you want.

-- 
Richard Damon

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


[issue41632] Tkinter - Unexpected behavior after creating around 10000 widgets

2020-08-26 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue41643] make shutil.make_archive always accept pathlib objects

2020-08-26 Thread Thomas Grainger


Change by Thomas Grainger :


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

___
Python tracker 

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



Re: About float/double type number in range.

2020-08-26 Thread Peter J. Holzer
On 2020-08-26 22:40:36 +1200, dn via Python-list wrote:
> On 26/08/2020 19:58, Joel Goldstick wrote:
> > On Wed, Aug 26, 2020 at 3:43 AM ADITYA  wrote:
> > > Dear Sir/Ma’am
> > > 
> > > I am requesting you to satisfy me about float number in Range
> > > function, because in the argument of range we can take integer
> > > but not double or float whenever double as well as float are
> > > integer in nature but when we use double/float in, it gives
> > > error that- “'float' object cannot be interpreted as an
> > > integer.” If we want to increment the number by half or
> > > quarter what can I do.
> > > 
> > > For ex- Range(1,3,0.5) I want it gives Output as [1 1.5 2 2.5 3)
> > > 
> > 
> > Take a look at this:
> > > > > l = [i/2 for i in range(2,7)]
> > > > > l
> > [1.0, 1.5, 2.0, 2.5, 3.0]
> 
> 
> This is a neat solution! To make it more user-friendly, the above needs to
> be wrapped in a convenience function that the user can call using arguments
> like "(1,3,0.5)" and not have to think about the 'multiplies' and 'divides'.
> 
[...]
> <<< Code NB Python v3.8 >>>
> def fp_range( start:float, stop:float, step:float=1.0 )->float:
> """Generate a range of floating-point numbers."""
> if stop <= start:
> raise OverflowError( "RangeError: start must be less than stop" )
> x = start
> while x < stop:
> yield x
> x += step

This is almost the same solution as I came up with, but note that this
is not quote the same as what Joel proposed. Repeated addition is not
the same as multiplication with floating point numbers. 

A generator based on Joel's idea would look like this:

def fp_range(start, end, step):
v = start
n = int(math.ceil((end - start) / step))
for i in range(n):
yield start + i * step

(I omitted the OverflowError: range() doesn't raise one, either)

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41639] Unpickling derived class of list does not call __init__()

2020-08-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

>From https://docs.python.org/3/library/pickle.html#pickling-class-instances:

When a class instance is unpickled, its __init__() method is usually not 
invoked.

If you want to change this behavior you have to implement the __reduce__ or 
__reduce_ex__ methods or register the object type in the global or per-pickler 
dispatch table. For example:

class NocaseList(list):

def __reduce__(self):
return self.__class__, (), None, iter(self)

--

___
Python tracker 

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



  1   2   >