[issue39110] UserList-subclass Tree slicing changes the original list unexpectedly

2019-12-20 Thread Tarn Yeong Ching


Tarn Yeong Ching  added the comment:

and more... It doesn't happen when Tree directly subclasses list.

--

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes the original list unexpectedly

2019-12-20 Thread ctarn


ctarn  added the comment:

Moreover, it works as expected with Python 3.6 (the owner of each of them is 
d), and Python 3.8 and Python 3.7 work differently.
I didn't try it using Python 3.9 yet.

--
versions: +Python 3.7 -Python 3.9

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes the original list unexpectedly

2019-12-20 Thread ctarn


Change by ctarn :


Removed file: https://bugs.python.org/file48797/bug.py

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes the original list unexpectedly

2019-12-20 Thread ctarn


ctarn  added the comment:

I tried to remove list(), and just use cmd like `_ = d[0:1]`, and it 
surprisingly changed d[0].owner from d to d[0:1]!
The file attached is updated.
I pretty sure that it is a (serious) bug. Please check it more carefully. 
Thanks.

--
title: UserList-subclass Tree slicing changes node attribute -> 
UserList-subclass Tree slicing changes the original list unexpectedly
Added file: https://bugs.python.org/file48799/bug.py

___
Python tracker 

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



[issue39113] PyUnicode_AsUTF8AndSize Sometimes Segfaults With Incomplete Surrogate Pair

2019-12-20 Thread william.ayd


william.ayd  added the comment:

Hmm my mistake - thanks!

--

___
Python tracker 

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



Re: How to combine a group of lists together

2019-12-20 Thread wanghao7915
Thanks!
Actually, I neglected that my "print" is in the "for", so I get a group of 
lists.
Now I put the "print" out of the iteration then use .extend to append each list 
I produce. Finally, print and get my ideal result.

Haha, I'm too naive, so is my English.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to combine a group of lists together

2019-12-20 Thread wanghao7915
thanks for responding!
Now I've solved this problem!

My former code is:
for j in data:
spe = j.get_text()
l_spe = spe.split()
print(l_spe)

Then I get the result:
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details']
['4.7', 'inches']
['750', 'x', '1334']
['64', 'GB']
['2', 'GB']
['Apple', 'A11', 'Bionic,', 'Hexa-Core,', '(2x', 'Monsoon', '+', '4x', 
'Mistral)']
['5.22', 'ounces']
['No']
['No']
['12', 'MP']
['7', 'MP']
['1821', 'mah']
['No']
['Yes,', 'on', 'the', 'front']
['None']
['iOS', '(Last', 'OS', 'info:', 'IOS', '11)']
['September', '2017']

Now my code is:
for j in data:
spe = j.get_text()
temp_li.extend(spe.split())
print(temp_li)

Then: 
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details', 
'4.7', 'inches', '750', 'x', '1334', '64', 'GB', '2', 'GB', 'Apple', 'A11', 
'Bionic,', 'Hexa-Core,', '(2x', 'Monsoon', '+', '4x', 'Mistral)', '5.22', 
'ounces', 'No', 'No', '12', 'MP', '7', 'MP', '1821', 'mah', 'No', 'Yes,', 'on', 
'the', 'front', 'None', 'iOS', '(Last', 'OS', 'info:', 'IOS', '11)', 
'September', '2017']

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


[issue24945] Expose Py_TPFLAGS_ values from Python

2019-12-20 Thread Batuhan


Batuhan  added the comment:

IMHO inspect would be a better place to put these constants (like CO_ flags).

--
nosy: +BTaskaya
versions: +Python 3.9 -Python 3.6

___
Python tracker 

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



[issue13047] imp.find_module("") and imp.find_module(".")

2019-12-20 Thread Batuhan


Batuhan  added the comment:

`imp` is now deprecated and IMHO no reason to make this change after this 
deprecation.

--
nosy: +BTaskaya

___
Python tracker 

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



[issue36051] Drop the GIL during large bytes.join operations?

2019-12-20 Thread Batuhan


Change by Batuhan :


--
versions: +Python 3.9 -Python 3.8

___
Python tracker 

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



[issue36051] Drop the GIL during large bytes.join operations?

2019-12-20 Thread Batuhan


Change by Batuhan :


--
nosy: +BTaskaya, vstinner

___
Python tracker 

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



[issue33772] Fix few dead code paths

2019-12-20 Thread Batuhan


Batuhan  added the comment:

I agree, can be closed

--
nosy: +BTaskaya

___
Python tracker 

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



[issue39106] Add suggestions to argparse error message output for unrecognized arguments

2019-12-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

-1  Given an unknown argument, we really can't know what the user intended.  
The usage string already lists all available options and -h --help gives more 
detail when requested.

--

___
Python tracker 

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



Re: How to extend an object?

2019-12-20 Thread DL Neil via Python-list

On 21/12/19 2:50 pm, Greg Ewing wrote:

On 21/12/19 1:59 am, Stefan Ram wrote:

   I would like to add a method to a string.

   This is not possible in Python?


It's not possible. Built-in classes can't have methods added
to them.

You can define your own subclass of str and give it whatever
methods you want.

But in your case:


for s in 'abc'.like( '(.)' ):


I would recommend making it a stand-alone function instead,
so that you would write

   for s in like('abc', '(.)'):



Contrarily: sub-classing str and making like() a method strikes me as 
the way to go, particularly if the 'abc' disappears into the instance's 
__init__() - and better still if the '(.)' may also be absorbed as a 
class/instance attribute, and even more-so if like() is not the only 
method/stand-alone function required for this category of strings...


but...

choose a self-documenting name for the class, and
choose a better-documenting name for the method.

instance = class( "abc" )
...
for s in instance.method():

is clean, self-documenting (or will be once you've done your thing), 
easier to test (fewer args => easier assured testing).


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


Re: How to combine a group of lists together

2019-12-20 Thread DL Neil via Python-list

On 21/12/19 6:04 pm, wanghao7...@gmail.com wrote:

I utilized .get_text() + .split() functions and obtain this:
spe=
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details']
['4.7', 'inches']
['750', 'x', '1334']
['64', 'GB']
['2', 'GB']
['Apple', 'A11', 'Bionic,', 'Hexa-Core,', '(2x', 'Monsoon', '+', '4x', 
'Mistral)']
['5.22', 'ounces']
['No']
['No']
['12', 'MP']
['7', 'MP']
['1821', 'mah']
['No']
['Yes,', 'on', 'the', 'front']
['None']
['iOS', '(Last', 'OS', 'info:', 'IOS', '11)']
['September', '2017']

They have a shared name 'spe', but no concrete names for each list.
If I use spe[0], I can only get all the first element of each list.

How can I mix all of these elements into a single list like:
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 
'Details','4.7', 'inches'..]


What is type( spe )? Please copy-paste code/session into your email msg 
- the above is NOT Python.


Your best solution may be to use a loop (instead of the constant 0, as 
list-argument).


The answer to your specific question is 'in the manual': list.extend()
(but a loop will likely still be required...)


WebRef:
https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range


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


[issue39113] PyUnicode_AsUTF8AndSize Sometimes Segfaults With Incomplete Surrogate Pair

2019-12-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Your function returns a borrowed reference. It xiuld cause  ceash even without 
calling PyUnicode_AsUTF8AndSize. Add Py_INCREF(str)

--
nosy: +serhiy.storchaka
resolution:  -> not a bug

___
Python tracker 

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



Re: How to combine a group of lists together

2019-12-20 Thread Cameron Simpson

On 20Dec2019 21:04, wanghao7...@gmail.com  wrote:

I utilized .get_text() + .split() functions and obtain this:
spe=
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details']
['4.7', 'inches']
['750', 'x', '1334']
['64', 'GB']
['2', 'GB']
['Apple', 'A11', 'Bionic,', 'Hexa-Core,', '(2x', 'Monsoon', '+', '4x', 
'Mistral)']
['5.22', 'ounces']
['No']
['No']
['12', 'MP']
['7', 'MP']
['1821', 'mah']
['No']
['Yes,', 'on', 'the', 'front']
['None']
['iOS', '(Last', 'OS', 'info:', 'IOS', '11)']
['September', '2017']

They have a shared name 'spe', but no concrete names for each list.


Does that mean you have a loop, with spe being computed in each loop 
pass?


It would help to see your code.


If I use spe[0], I can only get all the first element of each list.


Indeed, since that designates the first element.


How can I mix all of these elements into a single list like:
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 
'Details','4.7', 'inches'..]


Have a look at the chain() function from the itertools module. Or at the 
extend() method of the list class. Either will help you compose a longer 
list from a collection of individual lists.


If you're still stuck, post your code in a followup message and ask 
sepecific questions about your attempts to build a bigger list from 
various smaller ones.


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


How to combine a group of lists together

2019-12-20 Thread wanghao7915
I utilized .get_text() + .split() functions and obtain this:
spe=
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 'Details']
['4.7', 'inches']
['750', 'x', '1334']
['64', 'GB']
['2', 'GB']
['Apple', 'A11', 'Bionic,', 'Hexa-Core,', '(2x', 'Monsoon', '+', '4x', 
'Mistral)']
['5.22', 'ounces']
['No']
['No']
['12', 'MP']
['7', 'MP']
['1821', 'mah']
['No']
['Yes,', 'on', 'the', 'front']
['None']
['iOS', '(Last', 'OS', 'info:', 'IOS', '11)']
['September', '2017']

They have a shared name 'spe', but no concrete names for each list.
If I use spe[0], I can only get all the first element of each list.

How can I mix all of these elements into a single list like:
['$278.86as', 'of', 'Dec', '20,', '2019,', '06:47', 'PST', '-', 
'Details','4.7', 'inches'..]

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


[issue39110] UserList-subclass Tree slicing changes node attribute

2019-12-20 Thread ctarn


Change by ctarn :


--
resolution: not a bug -> 

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes node attribute

2019-12-20 Thread ctarn

ctarn  added the comment:

Sorry but it is not. See the first time I print ls[4].owner. We get d as 
expected, not a slice of d, that is, d[0:2].

However the next time we print it after _ = list(d[0:1]), noticed that ls[4] == 
d[0:1], we get d[0:1], it’s extremely surprising!!!

I have to highlight it: we just print *.owner before and after `_ = 
list(d[0:1])`, and the results are different!!!

The latest 3 lines show more strange results.

By the way, it’s my first time to report bug, and I don’t know what is 
discussion list, and reopened the issue. Thank you.

--
status: closed -> open

___
Python tracker 

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



[issue39113] PyUnicode_AsUTF8AndSize Sometimes Segfaults With Incomplete Surrogate Pair

2019-12-20 Thread william.ayd


New submission from william.ayd :

With the attached extension module, if I run the following in the REPL:

>>> import libtest
>>>
>>> libtest.error_if_not_utf8("foo")
'foo'
>>> libtest.error_if_not_utf8("\ud83d")
Traceback (most recent call last):
  File "", line 1, in 
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 
0: surrogates not allowed
>>> libtest.error_if_not_utf8("foo")
'foo'

Things seem OK. But the next invocation of

>>> libtest.error_if_not_utf8("\ud83d")

Then causes a segfault. Note that the order of the input seems important; 
simply repeating the call with the invalid surrogate doesn't cause the segfault

--
files: testmodule.c
messages: 358755
nosy: william.ayd
priority: normal
severity: normal
status: open
title: PyUnicode_AsUTF8AndSize Sometimes Segfaults With Incomplete Surrogate 
Pair
Added file: https://bugs.python.org/file48798/testmodule.c

___
Python tracker 

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



Re: How to extend an object?

2019-12-20 Thread Greg Ewing

On 21/12/19 1:59 am, Stefan Ram wrote:

   I would like to add a method to a string.

   This is not possible in Python?


It's not possible. Built-in classes can't have methods added
to them.

You can define your own subclass of str and give it whatever
methods you want.

But in your case:


for s in 'abc'.like( '(.)' ):


I would recommend making it a stand-alone function instead,
so that you would write

  for s in like('abc', '(.)'):

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


[issue39108] random needs doc for "gauss" versus "normalvariate"

2019-12-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I can make the update for you.

--
assignee: docs@python -> rhettinger

___
Python tracker 

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



[issue39112] Misleading documentation for tuple

2019-12-20 Thread Simon Berens


New submission from Simon Berens :

Sorry if this is a silly question (my first bug report), but it seems that 
https://docs.python.org/3/library/functions.html#func-tuple
should say "class tuple" instead of just "tuple", as list, dict, and set do.

--
assignee: docs@python
components: Documentation
messages: 358753
nosy: docs@python, sberens
priority: normal
severity: normal
status: open
title: Misleading documentation for tuple
type: enhancement
versions: Python 2.7, Python 3.5, 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



[issue39111] Misleading documentation for NotImplemented

2019-12-20 Thread Steven D'Aprano


Change by Steven D'Aprano :


--
title: Misleading documentation -> Misleading documentation for NotImplemented

___
Python tracker 

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



[issue39111] Misleading documentation

2019-12-20 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

The behaviour is correct: `==` should not raise, even if both objects' `__eq__` 
method returns NotImplemented.

I agree that the documentation needs improvement. Looking at the current 
version:

https://docs.python.org/3/library/constants.html#NotImplemented

it says:

Note: When a binary (or in-place) method returns NotImplemented 
the interpreter will try the reflected operation on the other 
type (or some other fallback, depending on the operator). If all
attempts return NotImplemented, the interpreter will raise an
appropriate exception. Incorrectly returning NotImplemented will
result in a misleading error message or the NotImplemented value
being returned to Python code.


(1) In the case of `==` and `!=`, an exception is not raised even all relevant 
methods return NotImplemented.

The source code for PyObject_RichCompare in object.c says:

/* If neither object implements it, provide a sensible default
   for == and !=, but raise an exception for ordering. */

and then falls back to object identity.

If we wanted to lawyer up, the current docs don't say that "some other 
fallback" is limited to Python dunder methods. But that's the strong impression 
it gives, and it is actively misleading in that there's no hint that the 
fallback includes a default notion of equality as object identity, built right 
into the interpreter itself.

Even Brett got this wrong: object.__eq__ can return NotImplemented, so it isn't 
a suitable final fallback:

py> object.__eq__(o, None)
NotImplemented


so I think these docs could do with some improvement. Based on the current 
docs, I too would expect equality to raise an exception for a class that 
defines `__eq__`  and `__ne__` to always return NotImplemented.


(2) The last sentence, about "incorrectly returning NotImplemented", confuses 
me. Why are we warning about that? If you incorrectly return any value, whether 
it is NotImplemented, True, False, None or 3.1415, it will result in a 
misleading error message or incorrect value being returned.

Is it perhaps meant to say "incorrectly *raising* NotImplemented"?

I'm reopening this for a doc enhancement. Unfortunately I can't use github for 
technical reasons, so can't do a PR, but I'll suggest an updated description 
for the first part. (I have no idea what to do for the second part.)

When a binary (or in-place) method returns NotImplemented 
the interpreter will try the reflected operation on the other 
type (or some other fallback, depending on the operator). If all
attempts return NotImplemented, the interpreter will fall back
to object identity for `==` and `!=` or raise an appropriate
exception for all other comparisons.

--
nosy: +steven.daprano
resolution: not a bug -> 
stage: resolved -> 
status: closed -> open
type:  -> enhancement

___
Python tracker 

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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

So I see 3 things to address here:

1. Python daemon threads
2. Python threads created in atexit handlers
3. non-Python threads accessing the C-API

Possible solutions (starting point for discussion):

1. stop them at the point we stop waiting for non-daemon threads (at the 
beginning of finalization)
2. disallow them?  do one more pass of wait-for-threads?
3. cause all (external) attempts to access the C-API to fail once finalization 
begins

Regarding daemon threads, the docs already say "Daemon threads are abruptly 
stopped at shutdown." [1]  So let's force them to stop.  Can we do that?  If we 
*can* simply kill the threads, can we do so without leaking resources?  
Regardless, the mechanism we currently use (check for finalizing each(?) time 
through the eval loop) mostly works fine.  The problem is when C code called 
from Python in a daemon thread blocks long enough that it makes C-API calls (or 
even the eval loop) *after* we've started cleaning up the runtime state.  So if 
there was a way to interrupt that blocking code, that would probably be good 
enough.

The other two possible solutions are, I suppose, a bit more drastic.  What are 
the alternatives?


[1] https://docs.python.org/3/library/threading.html#thread-objects

--
nosy: +nanjekyejoannah, ncoghlan, pablogsal, pitrou, tim.peters, vstinner

___
Python tracker 

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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

To put it another way:

(from issue33608#msg358748)

> The docs [1] aren't super clear about it, but there are some fundamental
> assumptions we make about runtime finalization:
>
> * no use of the C-API while Py_FinalizeEx() is executing (except for a
> few helpers like Py_Initialized)
> * only a small portion of the C-API is available afterward (at least
> until Py_Initialize() is run)
>
> I guess the real question is what to do about this?
> 
>[1] https://docs.python.org/3/c-api/init.html#c.Py_FinalizeEx

Adding to that list:

* no other Python threads are running once we start finalizing the runtime (not 
far into Py_FinalizeEx())

--

___
Python tracker 

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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

Analysis by @pconnell:

* https://bugs.python.org/issue33608#msg357169
* https://bugs.python.org/issue33608#msg357170
* https://bugs.python.org/issue33608#msg357179

tl;dr daemon threads and external C-API access during/after runtime 
finalization are causing crashes.

--

___
Python tracker 

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



[issue33608] Add a cross-interpreter-safe mechanism to indicate that an object may be destroyed.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

Thanks for the detailed analysis, Phil.  I think the results are pretty 
conclusive: daemon threads are the worst. :)  But seriously, thanks.

As you demonstrated, it isn't just Python "daemon" threads that cause the 
problem.  It is essentially any external access of the C-API once runtime 
finalization has started.  The docs [1] aren't super clear about it, but there 
are some fundamental assumptions we make about runtime finalization:

* no use of the C-API while Py_FinalizeEx() is executing (except for a few 
helpers like Py_Initialized)
* only a small portion of the C-API is available afterward (at least until 
Py_Initialize() is run)

I guess the real question is what to do about this?

Given that this is essentially a separate problem, let's move further 
discussion and effort over related to sorting out problematic threads to 
#36476, "Runtime finalization assumes all other threads have exited."  @Phil, 
would you mind attaching those same two files to that issue?


[1] https://docs.python.org/3/c-api/init.html#c.Py_FinalizeEx

--

___
Python tracker 

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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
nosy: +pconnell

___
Python tracker 

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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

Problems with lingering threads during/after runtime finalization continue to 
be a problem.  I'm going to use this issue as the focal point for efforts to 
resolve this.


Related issues:
* #36479 "Exit threads when interpreter is finalizing rather than runtime."
* #24770 "Py_Finalize() doesn't stop daemon threads"
* #23592 "SIGSEGV on interpreter shutdown, with daemon threads running wild"
* #37127 "Handling pending calls during runtime finalization may cause 
problems."
* #33608 "Add a cross-interpreter-safe mechanism to indicate that an object may 
be destroyed."
* #36818 "Add PyInterpreterState.runtime."
* #36724 "Clear _PyRuntime at exit"
* #14073 "allow per-thread atexit()"
* #1596321 "KeyError at exit after 'import threading' in other thread"
* #37266 "Daemon threads must be forbidden in subinterpreters"
* #31517 "MainThread association logic is fragile"

--

___
Python tracker 

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



[issue24770] Py_Finalize() doesn't stop daemon threads

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

I'm closing this in favor of #36476 "Runtime finalization assumes all other 
threads have exited."

--
nosy: +eric.snow
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Runtime finalization assumes all other threads have exited.
versions: +Python 3.8, Python 3.9 -Python 3.6

___
Python tracker 

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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
stage:  -> needs patch
versions: +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



[issue36476] Runtime finalization assumes all other threads have exited.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

Adding to the list:

* any OS threads created by an extension module or embedding application

--

___
Python tracker 

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



[issue13077] Unclear behavior of daemon threads on main thread exit

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue34296] Speed up python startup by pre-warming the vm

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue31517] MainThread association logic is fragile

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

probably a duplicate: issue #39042 "Use the runtime's main thread ID in the 
threading module."

--

___
Python tracker 

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



[issue14073] allow per-thread atexit()

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue28812] Deadlock between GIL and pystate head_mutex.

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue1332869] Fatal Python error: Interpreter not initialized

2019-12-20 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue1596321] KeyError at exit after 'import threading' in other thread

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

related: issue #39042 "Use the runtime's main thread ID in the threading 
module."

--
nosy: +eric.snow

___
Python tracker 

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



[issue39102] Increase Enum performance

2019-12-20 Thread Arseny Boykov


Arseny Boykov  added the comment:

Also, do we need to leave compatibility with python <3.8? 
If not, we could use the fact that python 3.8 dicts and sets which are preserve 
order to speed things up even more. Also I'd replace % string formatting with 
f-strings, as they also faster.

And another thing to think about: maybe we can calculate values returned by 
__str__, __repr__ and __invert__ once on member creation, since they not 
supposed to change during its life?

For example __invert__ on Flag does a lot of work on every call:
def __invert__(self):
cls = self.__class__
members, uncovered = _decompose(cls, self._value_)
inverted = cls(0)
for m in cls:
if m not in members and not (m._value_ & self._value_):
inverted = inverted | m
return cls(inverted)

--

___
Python tracker 

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



Re: Unable to install "collect" via pip3

2019-12-20 Thread Barry


> On 20 Dec 2019, at 15:27, Mahmood Naderan via Python-list 
>  wrote:
> 
> Hi
> 
> I can install collect with pip for python2.7
> $ pip install --user collect 
> Collecting collect
>  Using cached 
> https://files.pythonhosted.org/packages/cf/5e/c0f0f51d081665374a2c219ea4ba23fb1e179b70dded96dc16606786d828/collect-0.1.1.tar.gz
> Collecting couchdbkit>=0.5.7 (from collect)
>  Using cached 
> https://files.pythonhosted.org/packages/a1/13/9e9ff695a385c44f62b4766341b97f2bd8b596962df2a0beabf358468b70/couchdbkit-0.6.5.tar.gz
> Collecting restkit>=4.2.2 (from couchdbkit>=0.5.7->collect)
>  Downloading 
> https://files.pythonhosted.org/packages/76/b9/d90120add1be718f853c53008cf5b62d74abad1d32bd1e7097dd913ae053/restkit-4.2.2.tar.gz
>  (1.3MB)
>100% || 1.3MB 633kB/s
> Collecting http-parser>=0.8.3 (from 
> restkit>=4.2.2->couchdbkit>=0.5.7->collect)
>  Downloading 
> https://files.pythonhosted.org/packages/07/c4/22e3c76c2313c26dd5f84f1205b916ff38ea951aab0c4544b6e2f5920d64/http-parser-0.8.3.tar.gz
>  (83kB)
>100% || 92kB 2.4MB/s
> Collecting socketpool>=0.5.3 (from restkit>=4.2.2->couchdbkit>=0.5.7->collect)
>  Downloading 
> https://files.pythonhosted.org/packages/d1/39/fae99a735227234ffec389b252c6de2bc7816bf627f56b4c558dc46c85aa/socketpool-0.5.3.tar.gz
> Building wheels for collected packages: collect, couchdbkit, restkit, 
> http-parser, socketpool
>  Running setup.py bdist_wheel for collect ... done
>  Stored in directory: 
> /home/mnaderan/.cache/pip/wheels/b9/7c/7c/b09b334cc0e27b4f63ee9f6f19ca1f3db8672666a7e0f3d9cd
>  Running setup.py bdist_wheel for couchdbkit ... done
>  Stored in directory: 
> /home/mnaderan/.cache/pip/wheels/f6/05/1b/f8f576ef18564bc68ab6e64f405e1263448036208cafb221e0
>  Running setup.py bdist_wheel for restkit ... done
>  Stored in directory: 
> /home/mnaderan/.cache/pip/wheels/48/c5/32/d0d25fb272791a68c49c26150f332d9b9492d0bc9ea0cdd2c7
>  Running setup.py bdist_wheel for http-parser ... done
>  Stored in directory: 
> /home/mnaderan/.cache/pip/wheels/22/db/06/cb609a3345e7aa87206de160f00cc6af364650d1139d904a25
>  Running setup.py bdist_wheel for socketpool ... done
>  Stored in directory: 
> /home/mnaderan/.cache/pip/wheels/93/f6/8c/65924848766618647078cb66b1d964e8b80876536e84517469
> Successfully built collect couchdbkit restkit http-parser socketpool
> Installing collected packages: http-parser, socketpool, restkit, couchdbkit, 
> collect
> Successfully installed collect-0.1.1 couchdbkit-0.6.5 http-parser-0.8.3 
> restkit-4.2.2 socketpool-0.5.3
> However, pip3 fails with this error
> $ pip3 install --user collect
> Collecting collect
>  Using cached 
> https://files.pythonhosted.org/packages/cf/5e/c0f0f51d081665374a2c219ea4ba23fb1e179b70dded96dc16606786d828/collect-0.1.1.tar.gz
> Collecting couchdbkit>=0.5.7 (from collect)
>  Using cached 
> https://files.pythonhosted.org/packages/a1/13/9e9ff695a385c44f62b4766341b97f2bd8b596962df2a0beabf358468b70/couchdbkit-0.6.5.tar.gz
>Complete output from command python setup.py egg_info:
>Traceback (most recent call last):
>  File "", line 1, in 
>  File "/tmp/pip-build-qf95n0tt/couchdbkit/setup.py", line 25, in 
>long_description = file(
>NameError: name 'file' is not defined

My guess is that file is python 2 only. Couchdbkit needs porting to python 3.

Barry

> 
>
> Command "python setup.py egg_info" failed with error code 1 in 
> /tmp/pip-build-qf95n0tt/couchdbkit/
> I can not figure out what is the problem. Any way to fix that?
> 
> More info:
> $ which python
> /usr/bin/python
> $ ls -l /usr/bin/python
> lrwxrwxrwx 1 root root 9 Apr 16  2018 /usr/bin/python -> python2.7
> $ which python3
> /usr/bin/python3
> $ ls -l /usr/bin/python3
> lrwxrwxrwx 1 root root 9 Jun 21  2018 /usr/bin/python3 -> python3.6 
> 
> 
> 
> Regards,
> Mahmood
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


[issue39110] UserList-subclass Tree slicing changes node attribute

2019-12-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

(ctarn), if you want to discuss what you are doing further, please try a 
discussion list, such as python-list.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes node attribute

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes node attribute

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
status: open -> pending

___
Python tracker 

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



[issue39110] UserList-subclass Tree slicing changes node attribute

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
status: pending -> open
title: It seems that list() changes the value of the parameter -> 
UserList-subclass Tree slicing changes node attribute

___
Python tracker 

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



[issue39108] random needs doc for "gauss" versus "normalvariate"

2019-12-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

You could start by posting suggested new text here.

--
nosy: +terry.reedy
title: Documentation for "random.gauss" vs "random.normalvariate" is lacking -> 
random needs doc for "gauss" versus "normalvariate"
versions:  -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



[issue39102] Increase Enum performance

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions:  -Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue39098] OSError: handle closed, ProcessPoolExecutor shutdown(wait=False)

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
title: OSError: handle is closed in ProcessPoolExecutor  on 
shutdown(wait=False) -> OSError: handle closed, ProcessPoolExecutor 
shutdown(wait=False)

___
Python tracker 

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



[issue39096] "Format Specification Mini-Language" doc mistake for Decimal

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
title: Description of "Format Specification Mini-Language" not accurate for 
Decimal -> "Format Specification Mini-Language" doc mistake for Decimal

___
Python tracker 

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



[issue39062] ValueError in TarFile.getmembers

2019-12-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

jvoisin, please consider rerunning such reproducers with lastest 3.8 and 3.9 
before submitting.  It is much easier for you to do so when you have the fuzz 
file, script, and command line already present.

--

___
Python tracker 

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



[issue39062] ValueError in TarFile.getmembers

2019-12-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

jvoisin, what do you consider to be the bug?  Raising an exception  is exactly 
the right thing to do on bad input.  I leave it to others to decide if this 
should be closed as 'not a bug' or if the internal exception should be caught 
and replaced.  We don't pretend to document all possible exception from all 
functions.

The more important aim of fuzzing is to find inputs that cause no-exception 
crashes.

--

___
Python tracker 

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



[issue39062] ValueError in TarFile.getmembers

2019-12-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

See #39065, #39067 for similar tarfile issues.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue39062] ValueError in TarFile.getmembers

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +lars.gustaebel, serhiy.storchaka

___
Python tracker 

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



[issue39060] asyncio.Task.print_stack doesn't print the full stack

2019-12-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Amit, is there a simple doc change that would have made the result clearer? 
(before getting Andrew's response?)

--
nosy: +terry.reedy
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



[issue39048] Reorder __aenter__ & __aexit__ checks for async with statement

2019-12-20 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
title: Reorder the __aenter__ and __aexit__ method checks for the async with 
statement -> Reorder  __aenter__ & __aexit__ checks for async with statement
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



Re: Unable to install "collect" via pip3

2019-12-20 Thread Terry Reedy

On 12/20/2019 2:22 AM, Mahmood Naderan via Python-list wrote:


However, pip3 fails with this error
$ pip3 install --user collect
Collecting collect
   Using cached 
https://files.pythonhosted.org/packages/cf/5e/c0f0f51d081665374a2c219ea4ba23fb1e179b70dded96dc16606786d828/collect-0.1.1.tar.gz
Collecting couchdbkit>=0.5.7 (from collect)
   Using cached 
https://files.pythonhosted.org/packages/a1/13/9e9ff695a385c44f62b4766341b97f2bd8b596962df2a0beabf358468b70/couchdbkit-0.6.5.tar.gz
 Complete output from command python setup.py egg_info:
 Traceback (most recent call last):
   File "", line 1, in 
   File "/tmp/pip-build-qf95n0tt/couchdbkit/setup.py", line 25, in 
 long_description = file(
 NameError: name 'file' is not defined


The builtin function 'file' does not exist in 3.x.  pip3 is trying to 
install 2.x code.  I suspect this is because the package is not properly 
labelled as 2.x only.  (Some 2.x code will run unaltered on 3.x, so pip 
should try even if 3.x is not specified.)



--
Terry Jan Reedy

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


Re: Problems with "Tarfile.close()"

2019-12-20 Thread Chris Angelico
On Sat, Dec 21, 2019 at 6:13 AM Peter Otten <__pete...@web.de> wrote:
>
> Dr Rainer Woitok wrote:
>
> > Ethan,
> >
> > On Friday, 2019-12-20 07:41:51 -0800, you wrote:
> >
> >> ...
> >> In Python 3 `sys.stdout` is a character interface, not bytes.
> >
> > Does that mean that with Python  3 "Tarfile" is  no longer able to write
> > the "tar" file  to a pipe?   Or is there now  another way  to write to a
> > pipe?   And if that new way also  worked with Python  2, it would be even
> > better ... :-)
> >
> >> There are a couple solutions to the Python 3 aspect of the problem here:
> >>
> >>https://stackoverflow.com/q/908331/208880
> >
> > Using "sys.stdout.buffer"  seems to work  in Python 3  (at least with my
> > current rather trivial test case) but does not work in Python 2.  Quest-
> > ion: what is the cheapest way  to retrieve the Python version the script
> > is executing in?
>
> While I didn't look into the stackoverflow page an easy way to get something
> that accepts bytes may be
>
> # untested
> stdout = sys.stdout
> try:
> stdout = stdout.buffer
> except AttributeError:
> pass

This construct can be simplified down to:

stdout = getattr(sys.stdout, "buffer", sys.stdout)

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


Re: on sorting things

2019-12-20 Thread Chris Angelico
On Sat, Dec 21, 2019 at 6:01 AM Peter Otten <__pete...@web.de> wrote:
>
> Chris Angelico wrote:
>
> > On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__pete...@web.de> wrote:
> >> PS: If you are sorting files by size and checksum as part of a
> >> deduplication effort consider using dict-s instead:
> >
> > Yeah, I'd agree if that's the purpose. But let's say the point is to
> > have a guaranteed-stable ordering of files that are primarily to be
> > sorted by file size - in order to ensure that two files are in the
> > same order every time you refresh the view, they get sorted by their
> > checksums.
>
> One thing that struck me about Eli's example is that it features two key
> functions rather than a complex comparison.
>
> If sort() would accept a sequence of key functions each function could be
> used to sort slices that compare equal when using the previous key.
>

That would basically make it a comparison function, not a key function
:) The value of the key function is that it's called exactly once per
element, and the result is what you sort by. There's no correlation to
any other element. It's effectively this:

# sortme.sort(key=keyfunc)
keys = sortme.map(keyfunc)
keys.sort(keep_in_parallel=sortme)

Which is why cmp_to_key is the correct solution to that problem.

(For cases where you don't mind pre-calling both key functions, of
course, it's equivalent to a single key function that returns a
tuple.)

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


[issue13305] datetime.strftime("%Y") not consistent for years < 1000

2019-12-20 Thread Paul Ganssle


Change by Paul Ganssle :


--
versions: +Python 3.7, Python 3.8, Python 3.9 -Python 3.6

___
Python tracker 

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



[issue39103] [linux] strftime renders %Y with only 3 characters

2019-12-20 Thread Paul Ganssle


Paul Ganssle  added the comment:

This is a duplicate of issue 13305.

Right now we have some shims around `strftime` to improve consistency in some 
situations and for other reasons, but mostly we just call the libc version.

There is an open issue from 2008 (#3173) to ship our own implementation of 
strftime that could smooth out some of these issues and try and make the 
behavior more consistent (though presumably some people have started to rely on 
platform-specific behaviors by now, so it may be a decent amount of work to 
roll it out).

I'm going to close this in favor of 13305, but thanks for reporting it!

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> datetime.strftime("%Y") not consistent for years < 1000
type:  -> behavior

___
Python tracker 

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



[issue38918] Add __module__ entry for function type in inspect docs table.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

Thanks for working on this, @parthsharma2!

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



[issue38918] Add __module__ entry for function type in inspect docs table.

2019-12-20 Thread miss-islington


miss-islington  added the comment:


New changeset 44683bbc634bd007df572dce0d8bb348a469a6bb by Miss Islington (bot) 
in branch '3.8':
bpo-38918: Add __module__ entry for function & method type in inspect docs 
table (GH-17408)
https://github.com/python/cpython/commit/44683bbc634bd007df572dce0d8bb348a469a6bb


--

___
Python tracker 

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



[issue38918] Add __module__ entry for function type in inspect docs table.

2019-12-20 Thread miss-islington


miss-islington  added the comment:


New changeset 0ffc90031cadf5637cfc13a40899e71c259c49b1 by Miss Islington (bot) 
in branch '3.7':
bpo-38918: Add __module__ entry for function & method type in inspect docs 
table (GH-17408)
https://github.com/python/cpython/commit/0ffc90031cadf5637cfc13a40899e71c259c49b1


--

___
Python tracker 

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



[issue38918] Add __module__ entry for function type in inspect docs table.

2019-12-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17136
pull_request: https://github.com/python/cpython/pull/17676

___
Python tracker 

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



[issue38918] Add __module__ entry for function type in inspect docs table.

2019-12-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17135
pull_request: https://github.com/python/cpython/pull/17675

___
Python tracker 

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



[issue23868] Uninitialized objects are tracked by the garbage collector

2019-12-20 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

In summary, a normal allocation for an object tracked by the Garbage collector 
follows these steps:

1.- Call PyObject_GC_New or PyObject_GC_NewVar or related APIs.
2.- Initialize everything and make sure the object is consistent.
3.- Call PyObject_GC_Track

You can check the implementation of containers types in the stdlib for 
reference or the documentation for the C API.

Closing this, feel free to reopen of you think there is something missing.

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



[issue38918] Add __module__ entry for function type in inspect docs table.

2019-12-20 Thread miss-islington


miss-islington  added the comment:


New changeset f522a6ddb67a238bab5673608111f74ec4e22205 by Miss Islington (bot) 
(Parth Sharma) in branch 'master':
bpo-38918: Add __module__ entry for function & method type in inspect docs 
table (GH-17408)
https://github.com/python/cpython/commit/f522a6ddb67a238bab5673608111f74ec4e22205


--
nosy: +miss-islington

___
Python tracker 

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



Re: Problems with "Tarfile.close()"

2019-12-20 Thread Peter Otten
Dr Rainer Woitok wrote:

> Ethan,
> 
> On Friday, 2019-12-20 07:41:51 -0800, you wrote:
> 
>> ...
>> In Python 3 `sys.stdout` is a character interface, not bytes.
> 
> Does that mean that with Python  3 "Tarfile" is  no longer able to write
> the "tar" file  to a pipe?   Or is there now  another way  to write to a
> pipe?   And if that new way also  worked with Python  2, it would be even
> better ... :-)
> 
>> There are a couple solutions to the Python 3 aspect of the problem here:
>> 
>>https://stackoverflow.com/q/908331/208880
> 
> Using "sys.stdout.buffer"  seems to work  in Python 3  (at least with my
> current rather trivial test case) but does not work in Python 2.  Quest-
> ion: what is the cheapest way  to retrieve the Python version the script
> is executing in?

While I didn't look into the stackoverflow page an easy way to get something 
that accepts bytes may be

# untested
stdout = sys.stdout
try:
stdout = stdout.buffer
except AttributeError:
pass

tarfile.open(fileobj=stdout, ...)

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


[issue23868] Uninitialized objects are tracked by the garbage collector

2019-12-20 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

If I understand what you say correctly, it does not seem correct, the object 
will only be tracked by the collector when you call PyObject_GC_Track. indeed, 
the documentation warns about this:

void PyObject_GC_Track(PyObject *op)¶
Adds the object op to the set of container objects tracked by the collector. 
The collector can run at unexpected times so objects must be valid while being 
tracked. This should be called once all the fields followed by the tp_traverse 
handler become valid, usually near the end of the constructor.

--

___
Python tracker 

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



[issue26845] Misleading variable name in exception handling

2019-12-20 Thread STINNER Victor


STINNER Victor  added the comment:

Variable names have no impact on the execution. Sometimes, it's called "exc", 
sometimes "val", sometimes "exc_val" :-) This issue is not a bug.

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



Re: on sorting things

2019-12-20 Thread Peter Otten
Chris Angelico wrote:

> On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__pete...@web.de> wrote:
>> PS: If you are sorting files by size and checksum as part of a
>> deduplication effort consider using dict-s instead:
> 
> Yeah, I'd agree if that's the purpose. But let's say the point is to
> have a guaranteed-stable ordering of files that are primarily to be
> sorted by file size - in order to ensure that two files are in the
> same order every time you refresh the view, they get sorted by their
> checksums.

One thing that struck me about Eli's example is that it features two key 
functions rather than a complex comparison. 

If sort() would accept a sequence of key functions each function could be 
used to sort slices that compare equal when using the previous key.

> There ARE good reasons to do weird things with sorting, and a custom
> key object (either with cmp_to_key or directly implemented) can do
> that.

Indeed.

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


[issue39042] Use the runtime's main thread ID in the threading module.

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

I don't see a reason not to consider this is a regression.

The only problem with the fix would be for any users that rely on the 
inaccurate reporting of the threading module.  Considering that possibly 
includes only some embedders (and folks using _thread module directly), I 
expect the impact would be extremely small.  A porting entry in the whats-new 
doc.

--
keywords: +3.8regression
priority: normal -> release blocker
stage: test needed -> needs patch
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



[issue39102] Increase Enum performance

2019-12-20 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue39046] collections.abc.Reversible should not be a subclass of Hashable

2019-12-20 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue39111] Misleading documentation

2019-12-20 Thread Murali Ganapathy


Murali Ganapathy  added the comment:

===
# python3
class Base:
  def __eq__(self, other):
print("base called")
return super().__eq__(other)


class Foo(Base):

  def __eq__(self, other):
print("foo called")
return NotImplemented

Foo() == Foo()
# foo called
# foo called
False


Base.__eq__ is not called here. Is calling of object.__eq__ special cased?

--

___
Python tracker 

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



Re: Cython, producing different modules from the same .pyx

2019-12-20 Thread Lele Gaifax
Ethan Furman  writes:

> If you don't get an answer here, you can try the Cython Users group:

Thanks, reposted the same question there.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: Cython, producing different modules from the same .pyx

2019-12-20 Thread Lele Gaifax
Greg Ewing  writes:

> You could try creating a set of top-level .pyx stubs, each of
> which just 'include' the real code.

Thank you, will try this approach!

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


Re: on sorting things

2019-12-20 Thread Chris Angelico
On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__pete...@web.de> wrote:
> PS: If you are sorting files by size and checksum as part of a deduplication
> effort consider using dict-s instead:

Yeah, I'd agree if that's the purpose. But let's say the point is to
have a guaranteed-stable ordering of files that are primarily to be
sorted by file size - in order to ensure that two files are in the
same order every time you refresh the view, they get sorted by their
checksums.

There ARE good reasons to do weird things with sorting, and a custom
key object (either with cmp_to_key or directly implemented) can do
that.

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


[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread Eric Snow


Eric Snow  added the comment:

Your problem is with UserList.  This is from the implementation:

def __getitem__(self, i):
if isinstance(i, slice):
return self.__class__(self.data[i])
else:
return self.data[i]

So each slice is creating a new Tree.  Then the __setitem__() of that new Tree 
gets triggered for each item, causing the owner to be set to the new Tree.  So 
that's the cause.

Is there a particular reason you are subclassing UserList?  Consider 
subclassing list or collections.abc.MutableSequence instead.  Or deal with the 
slice semantics manually.

Also, perhaps you expected that a slice would produce a view into the sequence? 
 I know that's how it works in some programming languages (but not Python, 
though you could make it do that if you wanted to).

Regardless, as far as I can tell everything is working as designed.  I 
recommend closing this.

--
nosy: +eric.snow
resolution:  -> not a bug
status: open -> pending
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



Re: on sorting things

2019-12-20 Thread Peter Otten
Eli the Bearded wrote:

> In comp.lang.python, Peter Otten  <__pete...@web.de> wrote:
>> Eli the Bearded wrote:
>>> But what caught my eye most, as someone relatively new to Python but
>>> with long experience in C in Perl, is sorting doesn't take a
> 
> s/C in /C and/
> 
> Ugh.
> 
>>> *comparison* function, it takes a *key generator* function, and that
>>> function is supposed to transform the thing into something that the
>>> native comparison knows how to compare.
>>> 
>>> This seems a strange choice, and I'm wondering if someone can explain
>>> the benefits of doing it that way to me.
>> 
>> Python 2 started with a comparison function and then grew a key function.
>> With a key function you still have to compare items, you are just
>> breaking the comparison into two steps:
> 
> [snip]
> 
> Thanks for that good explanation. The benchmark comparison makes it
> very thorough.
> 
> In my mind I gravitate towards the complicated sorts of sort that can be
> quickly compared for some sorts of keys and not as quickly for others.
> 
> Consider a sort that first compares file size and if the same number of
> bytes, then compares file checksum. Any decently scaled real world
> implementation would memoize the checksum for speed, but only work it out
> for files that do not have a unique file size. The key method requires
> it worked out in advance for everything.

Oscar already mentioned the functools.cmp_to_key decorator which makes this 
a non-issue:

def mycmp(a, b): ...

files.sort(key=cmp_to_key(mycmp))


Applied to your example, with memoization:

# untested

def cmp(a, b):
return (a > b)-(a < b)

def make_file_key():
size = functools.lru_cache(None)(getsize)
checksum = functools.lru_cache(None)(getchecksum)

@functools.cmp_to_key
def file_key(a, b):
return cmp(size(a), size(b)) or cmp(checksum(a), checksum(b))
return file_key

files.sort(key=make_file_key())

> But I see the key method handles the memoization under the hood for you,
> so those simpler, more common sorts of sort get an easy to see benefit.
> 
> Elijah
> --
> even memoizing the stat() calls would help for large lists

PS: If you are sorting files by size and checksum as part of a deduplication 
effort consider using dict-s instead:

def grouped(items, key):
result = defaultdict(list)
for item in items:
result[key(item)].append(item)
return result

for same_size in grouped(files, key=getsize).values():
if len(same_size) > 1:
for same_checksum in grouped(same_size, key=getchecksum).values():
if len(same_checksum) > 1:
print(same_checksum)


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


[issue26767] Inconsistant error messages for failed attribute modification

2019-12-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Not all error messages contain an attribute name, an object type name and a 
reason.

--

___
Python tracker 

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



[issue39111] Misleading documentation

2019-12-20 Thread Brett Cannon


Brett Cannon  added the comment:

And to be more specific, == is guaranteed to work by falling back to 
object.__eq__() which falls back to object identity if the object doesn't have 
a custom __eq__() method.

--

___
Python tracker 

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



[issue39111] Misleading documentation

2019-12-20 Thread Brett Cannon


Brett Cannon  added the comment:

This is because your class implicitly inherits from object and object.__eq__() 
is implemented and does not return NotImplemented.

--
nosy: +brett.cannon
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



[issue39103] [linux] strftime renders %Y with only 3 characters

2019-12-20 Thread Brett Cannon


Brett Cannon  added the comment:

Due note, though, that there's a difference in the implementation of strftime 
versus strptime, as the former (at least the last time I looked ages ago) uses 
the libc version of the function and thus probably doesn't try to smooth out 
differences like this, while the latter is implemented in Python code in the 
stdlib itself.

--
nosy: +brett.cannon

___
Python tracker 

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



Re: Problems with "Tarfile.close()"

2019-12-20 Thread Dr Rainer Woitok
Ethan,

On Friday, 2019-12-20 07:41:51 -0800, you wrote:

> ...
> In Python 3 `sys.stdout` is a character interface, not bytes.

Does that mean that with Python  3 "Tarfile" is  no longer able to write
the "tar" file  to a pipe?   Or is there now  another way  to write to a
pipe?   And if that new way also  worked with Python  2, it would be even
better ... :-)

> There are a couple solutions to the Python 3 aspect of the problem here:
> 
>https://stackoverflow.com/q/908331/208880

Using "sys.stdout.buffer"  seems to work  in Python 3  (at least with my
current rather trivial test case) but does not work in Python 2.  Quest-
ion: what is the cheapest way  to retrieve the Python version the script
is executing in?

Sincerely,
  Rainer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [HN] How to Make Python Wait

2019-12-20 Thread p4j
>> https://news.ycombinator.com/item?id=21834408
> Did you just post a blog article, then spam everywhere to try to get
> traffic, where your entire blog post is telling people worse ways to
> do a time.sleep()?

Blog post is not mine. I have a habit of posting good things to HN. When
I got notification that it is getting good traction, people are
discussing, then I posted the discussion link here. If that is not liked
here then I won't post again.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39107] Consider building Tkinter with Tk 8.6.10

2019-12-20 Thread Zachary Ware


Zachary Ware  added the comment:

Looks like some enhancements on Windows as well; we should upgrade at least 3.9.

--
components: +Windows
nosy: +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



[issue39105] Spam

2019-12-20 Thread Zachary Ware


Change by Zachary Ware :


--
type: resource usage -> 
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



[issue39105] Spam

2019-12-20 Thread Zachary Ware


Change by Zachary Ware :


--
Removed message: https://bugs.python.org/msg358698

___
Python tracker 

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



[issue39105] Spam

2019-12-20 Thread Zachary Ware


Change by Zachary Ware :


Removed file: https://bugs.python.org/file48795/Roko-Logo-2-fi18353094x260.png

___
Python tracker 

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



[issue39111] Misleading documentation

2019-12-20 Thread Murali Ganapathy


New submission from Murali Ganapathy :

The documentation at 
https://docs.python.org/3.6/library/constants.html#NotImplemented states

If all attempts return NotImplemented, the interpreter will raise an 
appropriate exception. However this is not true for __eq__.

===
class Foo:
  def __eq__(self, other):
return NotImplemented

Foo() == Foo() # returns False, does not throw an exception


--
assignee: docs@python
components: Documentation
messages: 358719
nosy: docs@python, murali
priority: normal
severity: normal
status: open
title: Misleading documentation
versions: Python 3.5, 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



[issue34938] Fix mimetype.init() to account for from import

2019-12-20 Thread YoSTEALTH


YoSTEALTH  added the comment:

I didn't receive any notification of replay on this topic.

`_default_mime_types()` should never have been a function. This function should 
be safe to remove as its an internal function. This would avoid unneeded 
function call and globals used.

Stuff like `_suffix_map_default` could be constants like `SUFFIX_MAP_DEFAULT` 
with `suffix_map = SUFFIX_MAP_DEFAULT.copy()`

Ashley if you feel like making these changes (optional)

--

___
Python tracker 

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



[issue26767] Inconsistant error messages for failed attribute modification

2019-12-20 Thread Batuhan


Batuhan  added the comment:

> I think it would be nice to unify error messages and make them more specific.

How can they can be more specific when they are unified?

--
nosy: +BTaskaya
versions: +Python 3.9 -Python 3.6

___
Python tracker 

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



[issue26845] Misleading variable name in exception handling

2019-12-20 Thread Batuhan


Batuhan  added the comment:

I am not sure if calls like this constitutes a problem. By the way most of the 
things changed in Python/ceval.c including removal of END_FINALLY (issue 33387) 
but calls to _PyErr_Restore is still there with that same arguments.

--
nosy: +BTaskaya, vstinner

___
Python tracker 

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



[issue23868] Uninitialized objects are tracked by the garbage collector

2019-12-20 Thread Batuhan


Change by Batuhan :


--
nosy: +BTaskaya, pablogsal
type:  -> behavior

___
Python tracker 

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



[issue18930] os.spawnXX functions terminates process if second argument is empty list

2019-12-20 Thread Batuhan


Batuhan  added the comment:

@SSchukat can you reproduce this issue in python 3?

--
components: +Windows -Interpreter Core
nosy: +BTaskaya, paul.moore, steve.dower, tim.golden, zach.ware
type:  -> behavior

___
Python tracker 

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



Re: How to improve epoll speed when recv from kernel via netlink?

2019-12-20 Thread Barry Scott



> On 20 Dec 2019, at 04:33, lampahome  wrote:
> 
> I tried to receive msg from kernel via netlink of socket.
> 
> And I use epoll to receive netlink events whenever it comes from kernel to
> user space.
> 
> But I found the performance is poor e.g. epoll costs 90% time of execution
> time after I profile it by cProfile module.
> 
> Are there any tips to improve this?

cProfile is telling you how long the code is waiting for epoll to return.
It is not telling that epoll is a problem.

Barry



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

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


  1   2   >