[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-19 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Replicated on Linux, Python 3.10.

It looks like mousewheel scrolling jumps by the wrong amount as it pages down 
(or up), and consequently some lines never appear in the view area.

I ran a slightly modified version of the code that had 16 entries instead of 
just seven. By default, just three entries are visible at a time. If we number 
the lines 1-16, and start with lines 1-3 visible, then we get:

* Initial view: lines 1, 2, 3 visible, 4-16 below the view area.
* Scrollwheel down.
* Lines 6-8 visible, 1-5 above the view area, 9-16 below.
* Scrollwheel down.
* Lines 11-13 visible, 1-10 above the view area, 14-16 below.
* Scrollwheel down.
* Lines 14-16 visible, 1-13 above the view area.

So the scrollwheel scrolls down by: 5 lines, 5 lines, 3 lines.

Going back the otherway, the scrollwheel scrolls up by 5, 5, 3.

Why five lines? My guess is that it might have something to do with 16//3 = 5.

I don't know if this is something we can fix, or we're stuck with whatever 
tk/tcl does.

I don't know if this is related, or should be a separate issue, but I see that 
the keyboard PageUp and PageDown keys don't scroll up or down by a page, but by 
a single line -- and they don't correctly highlight the selected line either.

Paging should scroll up or down by N-1 lines, where N is the number of visible 
lines in the view area.

Likewise for clicking in the scrollbar's PageUp/PageDown region, which also 
scrolls by a single line.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue46803] Item not shown when using mouse wheel to scroll for Listbox/Combobox

2022-02-19 Thread Jason Yang


New submission from Jason Yang :

When scrolled items by mouse wheel in tk.Listbox/ttk.Combobox, some items not 
shown.

Is it a bug ? or I did something wrong ?

In following case, 'Wednesday' will not shown when scroll mouse wheel at

- tk.Listbox or vertical scrollbar of tk.Listbox, or
- listbox of ttk.Combo

```python
from tkinter import *
from tkinter import ttk

font = ('Courier New', 24)
lst = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 
'Saturday')

root = Tk()

frame1 = Frame(root)
frame1.pack(side=LEFT)
vsb1 = Scrollbar(frame1, orient='v')
vsb1.pack(side=RIGHT, fill='y')
var = StringVar()
var.set(lst)
listbox = Listbox(frame1, width=10, height=3, listvariable=var, font=font, 
yscrollcommand=vsb1.set)
listbox.pack(side=LEFT)
vsb1.configure(command=listbox.yview)

frame2 = Frame(root)
frame2.pack(side=LEFT, fill='y')
combobox = ttk.Combobox(frame2, values=lst, width=10, height=3, font=font)
combobox.pack()

root.mainloop()
```

Platform: WIN10

--
components: Tkinter
files: PeS9r.png
messages: 413564
nosy: Jason990420
priority: normal
severity: normal
status: open
title: Item not shown when using mouse wheel to scroll for Listbox/Combobox
type: behavior
versions: Python 3.8, Python 3.9
Added file: https://bugs.python.org/file50634/PeS9r.png

___
Python tracker 

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



[issue39298] add BLAKE3 to hashlib

2022-02-19 Thread Jack O'Connor


Jack O'Connor  added the comment:

Yes, everything in https://github.com/BLAKE3-team/BLAKE3 and 
https://github.com/oconnor663/blake3-py is public domain via CC0, and dual 
licensed under Apache for good measure. Hopefully that makes it easy to use it 
anywhere.

--

___
Python tracker 

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



[issue45116] Performance regression 3.10b1: inlining issue in the big _PyEval_EvalFrameDefault() function with Visual Studio (MSC)

2022-02-19 Thread neonene


Change by neonene :


--
pull_requests: +29570
pull_request: https://github.com/python/cpython/pull/31436

___
Python tracker 

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



[issue46066] Deprecate keyword args syntax for TypedDict definition

2022-02-19 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:


New changeset 0a8a8e7454c6565cf1554d5f23314e4c70960bcd by Jelle Zijlstra in 
branch 'main':
bpo-46066: Check DeprecationWarning in test_typing (GH-31428)
https://github.com/python/cpython/commit/0a8a8e7454c6565cf1554d5f23314e4c70960bcd


--

___
Python tracker 

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



Re: PYT - The expressions described in the Python language reference yield only boolean values

2022-02-19 Thread Chris Angelico
On Sun, 20 Feb 2022 at 12:00, vanyp  wrote:
>
> *I am trying to learn Python from the grammar given in the Python
> language reference and I am surprised.*
>

The grammar is not the best way to learn the language. It'll show you
a lot of unnecessary details. For technical reasons, Python's grammar
defines expressions in a nested way, but the way most programmers want
to think of it is that there is operator precedence.

https://docs.python.org/3/reference/expressions.html#operator-precedence

The grammar considers that these are different types of expressions,
but they're not really different in actual usage.

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


PYT - The expressions described in the Python language reference yield only boolean values

2022-02-19 Thread vanyp
*I am trying to learn Python from the grammar given in the Python 
language reference and I am surprised.*


*Lets start here:*

*"*
*6.3.4. Calls*

A call calls a callable object (e.g., a function 
) with a possibly 
empty series of arguments 
:


*call *::= |primary 
|"(" [|argument_list 
|[","] | |comprehension 
|] ")"
*argument_list *::= |positional_arguments 
|["," |starred_and_keywords 
|]
["," |keywords_arguments 
|]
| |starred_and_keywords 
|["," |keywords_arguments 
|]
| |keywords_arguments 
|

*positional_arguments*::= positional_item ("," positional_item)*
*positional_item *::= |assignment_expression 
|| "*" |expression 
|

*"*

*continued by:*
*"*
*6.12. Assignment expressions*
*assignment_expression*::= [|identifier 
|":="] |expression 
|

*"*

*Now I look at the following productions:*

*"*
*6.13. Conditional expressions*
*conditional_expression*::= |or_test 
|["if" |or_test 
|"else" |expression 
|]
*expression *::= |conditional_expression 
|| |lambda_expr 
|

*"*

*The first or_test is strange, I assume it should be replaced by expression.*

*But even so I think that the only ways out of the recursion are the 
or_test or the lambda_expr.*


*And by the grammar, those evaluate to booleans as follows:*


*"*
*6.14. Lambdas*
*lambda_expr*::= "lambda" [|parameter_list 
|] ":" |expression 
|

*"*

*and I conclude that the only way out of that branch is also or_test.*

*I then look at or_test:*

*"*
*6.11. Boolean operations*
*or_test *::= |and_test 
|| |or_test 
|"or" |and_test 
|
*and_test*::= |not_test 
|| |and_test 
|"and" |not_test 
|
*not_test*::= |comparison 
|| "not" |not_test 
|

*"*

*and the ony way out is comparison, which by the semantics should return 
a boolean.*


*Looking at comparison gives:*

*"*
**6.10. Comparisons**
*comparison *::= |or_expr 
|(|comp_operator 
||or_expr 
|)*

*comp_operator*::= "<" | ">" | "==" | ">=" | "<=" | "!="
| "is" 

[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Jonathan


Jonathan  added the comment:

True, have to admit, that I forgot to search first, that really looks like it 
is the same problem, especially when looking at 
https://bugs.python.org/msg289212. Would say this one can be closed.

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Possible duplicate of https://bugs.python.org/issue29753

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Jonathan


Change by Jonathan :


--
nosy:  -helo9

___
Python tracker 

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Jonathan


New submission from Jonathan :

I have issues unpacking binary data, produced by C++. The appended jupyter 
notebook shows the problem. It is also uploaded to github gist: 
https://gist.github.com/helo9/04125ae67b493e505d5dce4b254a2ccc

--
components: ctypes
files: ctypes_bitfield_problem.ipynb
messages: 413559
nosy: helo9
priority: normal
severity: normal
status: open
title: Wrong result unpacking binary data with ctypes bitfield.
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50633/ctypes_bitfield_problem.ipynb

___
Python tracker 

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



Re: Long running process - how to speed up?

2022-02-19 Thread Avi Gross via Python-list
Indeed not a clear request. Timing is everything but there are times ...
For many purposes, people may read in the entire CSV at a gulp into some data 
structure like a pandas DataFrame. The file is then closed and any processing 
done later does whatever you want.
Of course you can easily read on line at a time in Python and parse it by comma 
and any other processing and act on one row at a time or in small batches so 
you never need huge amounts of memory. But using other methods to read in the 
entire set of data is often better optimized and faster, and being able to do 
some things with the data is faster if done in vectorized fashion using add-ons 
like numpy and pandas. We have no idea what is being used and none of this 
explains a need to use some form of sleep.
Multi-processing helps only if you can make steps in the processing run in 
parallel without interfering with each other or making things happen out of 
order. Yes, you could read in the data and assign say 10,000 rows to a thread 
to process and then get more and assign, if done quite carefully. The results 
might need to be carefully combined and any shared variables might need locks 
and so on. Not necessarily worth it if the data is not too large and the 
calculations are small.

And it remains unclear where you want to sleep or why. Parallelism can be 
important if the sleep is to wait for the user to respond to something while 
processing continues in the background. Is it possible that whatever you are 
calling to do processing has some kind of sleep within it and you may be 
calling it as often as per row? In that case, ask why it does that and can you 
avoid that? Yes, running in parallel may let you move forward but again, it has 
to be done carefully and having thousands of processes sleeping at the same 
time may be worse!
I note badly defined questions get horrible answers. Mine included.
-Original Message-
From: Alan Gauld 
To: python-list@python.org
Sent: Sat, Feb 19, 2022 7:33 am
Subject: Fwd: Re: Long running process - how to speed up?

On 19/02/2022 11:28, Shaozhong SHI wrote:

> I have a cvs file of 932956 row 

That's not a lot in modern computing terms.

> and have to have time.sleep in a Python
> script. 

Why? Is it a requirement by your customer? Your manager?
time.sleep() is not usually helpful if you want to do
things quickly.

> It takes a long time to process.

What is a "long time"? minutes? hours? days? weeks?

It should take a million times as long as it takes to
process one row. But you have given no clue what you
are doing in each row.
- reading a database?
- reading from the network? or the internet?
- writing to a database? or the internet?
- performing highly complex math operations?

Or perhaps the processing load is in analyzing the totality
of the data after reading it all? A very different type
of problem. But we just don't know.

All of these factors will affect performance.

> How can I speed up the processing? 

It all depends on the processing.
You could try profiling your code to see where the time is spent.

> Can I do multi-processing?

Of course. But there is no guarantee that will speed things
up if there is a bottleneck on a single resource somewhere.
But it might be possible to divide and conquer and get better
speed. It all depends on what you are doing. We can't tell.

We cannot answer such a vague question with any specific
solution.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

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


Aw: PYT - How can I subscribe to a topic in the mailing list?

2022-02-19 Thread Karsten Hilbert
> Betreff: PYT - How can I subscribe to a topic in the mailing list?

Mailing lists don't subdivide by topic.

Your mailer may allow you to filter by Subject:.

> And h*ow do I set the topic in my messages?*

not applicable

The equivalent would be the Subject: header.

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


PYT - How can I subscribe to a topic in the mailing list?

2022-02-19 Thread vanyp

And h*ow do I set the topic in my messages?*
--
https://mail.python.org/mailman/listinfo/python-list


[issue46801] test_typing emits deprecation warnings

2022-02-19 Thread Irit Katriel


Change by Irit Katriel :


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



Re: Long running process - how to speed up?

2022-02-19 Thread Mats Wichmann
On 2/19/22 05:09, Shaozhong SHI wrote:
> Can it be divided into several processes?
> Regards,
> David

The answer is: "maybe".  Multiprocessing doesn't happen for free, you
have to figure out how to divide the task up, requiring thought and
effort. We can't guess to what extent the problem you have is amenable
to multiprocessing.

Google for "dataframe" and "multiprocessing" and you should get some
hits (in my somewhat limited experience in this area, people usually
load the csv data into Pandas before they get started working with it).


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


[issue46801] test_typing emits deprecation warnings

2022-02-19 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue46801] test_typing emits deprecation warnings

2022-02-19 Thread Irit Katriel


New submission from Irit Katriel :

==
ERROR: test_typeddict_create_errors (test.test_typing.TypedDictTests)
--
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-1/Lib/test/test_typing.py", line 4589, 
in test_typeddict_create_errors
TypedDict('Emp', _fields={'name': str, 'id': int})
^^
  File "/Users/iritkatriel/src/cpython-1/Lib/typing.py", line 2609, in TypedDict
warnings.warn(
^^
DeprecationWarning: The kwargs-based syntax for TypedDict definitions is 
deprecated in Python 3.11, will be removed in Python 3.13, and may not be 
understood by third-party type checkers.

==
ERROR: test_typeddict_errors (test.test_typing.TypedDictTests)
--
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-1/Lib/test/test_typing.py", line 4602, 
in test_typeddict_errors
TypedDict('Hi', x=1)

  File "/Users/iritkatriel/src/cpython-1/Lib/typing.py", line 2609, in TypedDict
warnings.warn(
^^
DeprecationWarning: The kwargs-based syntax for TypedDict definitions is 
deprecated in Python 3.11, will be removed in Python 3.13, and may not be 
understood by third-party type checkers.

--
components: Tests
messages: 413558
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: test_typing emits deprecation warnings
versions: Python 3.11

___
Python tracker 

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



Re: library not initialized (pygame)

2022-02-19 Thread Martin Di Paola

Could you share the traceback / error that you are seeing?


On Sun, May 02, 2021 at 03:23:21PM -0400, Quentin Bock wrote:

Code:
#imports and variables for game
import pygame
from pygame import mixer
running = True

#initializes pygame
pygame.init()

#creates the pygame window
screen = pygame.display.set_mode((1200, 800))

#Title and Icon of window
pygame.display.set_caption("3.02 Project")
icon = pygame.image.load('3.02 icon.png')
pygame.display.set_icon(icon)

#setting up font
pygame.font.init()
font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16)
font_x = 10
font_y = 40
items_picked_up = 0
items_left = 3

def main():
   global running, event

   #Game Loop
   while running:
   #sets screen color to black
   screen.fill((0, 0, 0))

   #checks if the user exits the window
   for event in pygame.event.get():
   if event.type == pygame.QUIT:
   running = False
   pygame.quit()

   def display_instruction(x, y):
   instructions = font.render("Each level contains 3 items you
must pick up in each room.", True, (255, 255, 255))
   instructions_2 = font.render("When you have picked up 3 items,
you will advance to the next room, there are 3.", True, (255, 255, 255))
   instructions_3 = font.render("You will be able to change the
direction you are looking in the room, this allows you to find different
objects.", True, (255, 255, 255))
   clear = font.render("Click to clear the text.", True, (255,
255, 255))
   screen.blit(instructions, (10, 40))
   screen.blit(instructions_2, (10, 60))
   screen.blit(instructions_3, (10, 80))
   screen.blit(clear, (10, 120))

   if event.type == pygame.MOUSEBUTTONDOWN:
   if event.type == pygame.MOUSEBUTTONUP:
   screen.fill(pygame.Color('black'))  # clears the screen text

   display_instruction(font_x, font_y)
   pygame.display.update()


main()

the error apparently comes from the first instructions variable saying
library not initialized not sure why, its worked before but not now :/
--
https://mail.python.org/mailman/listinfo/python-list

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


Re: Long running process - how to speed up?

2022-02-19 Thread Dennis Lee Bieber
On Sat, 19 Feb 2022 11:28:31 +, Shaozhong SHI 
declaimed the following:

>I have a cvs file of 932956 row and have to have time.sleep in a Python
>script.  It takes a long time to process.
>
I'd echo the others... Unless you better explain WHY you have .sleep()
(along with how often it is called, and what duration you sleep) the first
recommendation would be to remove it.

The most common justification for .sleep() is that one has CPU-BOUND
processing and needs to force context switches to let other operations
proceed more often than the system quantum time. Not normally a concern
given Python's GIL and the presence of multi-core chips.

How are you processing the (near) million rows of that CSV? If you are
loading all of them into a large list you could be running Python list
reallocations, or OS page swapping (though I wouldn't expect that on most
modern systems -- maybe on a Raspberry-Pi/BeagleBone Black). Note:

>>> import sys
>>> sys.getsizeof("a")
50
>>> 

even a one-character string expands to 50 bytes. An EMPTY string takes up
51 bytes... Except for the empty string, that comes to about 49+<#chars> IF
all characters fit an 8-bit encoding -- if any non 8-bit characters are in
the string, the #chars needs to be multiplied by either 2 or 4 depending
upon the widest representation needed.

If you are doing read-one-record, process-one-record, repeat -- and
have the .sleep() inside that loop... definitely remove the .sleep(). That
loop is already I/O bound, the fastest you can obtain is determined by how
rapidly the OS can transfer records from the file system to your program.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Re: Long running process - how to speed up?

2022-02-19 Thread Alan Gauld
On 19/02/2022 11:28, Shaozhong SHI wrote:

> I have a cvs file of 932956 row 

That's not a lot in modern computing terms.

> and have to have time.sleep in a Python
> script. 

Why? Is it a requirement by your customer? Your manager?
time.sleep() is not usually helpful if you want to do
things quickly.

> It takes a long time to process.

What is a "long time"? minutes? hours? days? weeks?

It should take a million times as long as it takes to
process one row. But you have given no clue what you
are doing in each row.
- reading a database?
- reading from the network? or the internet?
- writing to a database? or the internet?
- performing highly complex math operations?

Or perhaps the processing load is in analyzing the totality
of the data after reading it all? A very different type
of problem. But we just don't know.

All of these factors will affect performance.

> How can I speed up the processing? 

It all depends on the processing.
You could try profiling your code to see where the time is spent.

> Can I do multi-processing?

Of course. But there is no guarantee that will speed things
up if there is a bottleneck on a single resource somewhere.
But it might be possible to divide and conquer and get better
speed. It all depends on what you are doing. We can't tell.

We cannot answer such a vague question with any specific
solution.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

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


Re: library not initialized (pygame)

2022-02-19 Thread Cosmo Hope
On Sunday, 2 May 2021 at 21:04:40 UTC+1, Michael Torrie wrote:
> On 5/2/21 1:23 PM, Quentin Bock wrote: 
> > the error apparently comes from the first instructions variable saying 
> > library not initialized not sure why, its worked before but not now :/
> I don't get that error on my Fedora 32 machine. The script ultimately 
> doesn't run because it can't find the icon png file. But the window 
> briefly appears and it seems like pygame is being initialized properly.

i have the same problem currently
have you found a solution by chance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting py files to .exe and .dmg

2022-02-19 Thread Techtask Technologies
On Monday, December 28, 2015 at 4:35:41 PM UTC+1, Brian Simms wrote:
> Hi there, 
> 
> I have done a lot of looking around online to find out how to convert Python 
> files to .exe and .dmg files, but I am confused. Could someone provide 
> pointers/advice as to how I can turn a Python file into a Windows .exe and 
> Mac .dmg file. 
> 
> Thanks for any help.

You can convert Python Files to exe using Pyinstaller, this are the procedures 
below:
Run this commands on your terminal:
pip install pyinstaller
pyinstaller nameofyourfile.py --onefile
after that a folder should be created named Dist open it and you would see your 
Python file in an executable format.
I think this would help you.
~Paul Fruitful
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-19 Thread Larry Hastings


Larry Hastings  added the comment:

Yury, Ka-Ping, can you guys shed any light on this?  Your names are still on 
inspect.py.

--
nosy: +ping, yselivanov

___
Python tracker 

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



[issue46800] Support for pause(2)

2022-02-19 Thread Zachary Ware


Zachary Ware  added the comment:

See signal.pause: https://docs.python.org/3/library/signal.html#signal.pause

--
nosy: +zach.ware

___
Python tracker 

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



[issue46757] dataclasses should define an empty __post_init__

2022-02-19 Thread Eric V. Smith


Eric V. Smith  added the comment:

The fact that it's never been needed in the years that dataclasses and attrs 
have existed tell me it's kind of a niche requirement.

This does not seem like the ugliest code I've ever seen:

if hasattr(super(), "__post_init__"):
super().__post_init__()

or the probably more efficient, but more lines of code:

try:
post_init = super().__post_init__
except AttributeError:
pass
else:
post_init()

As always with calling super functions, the whole hierarchy needs to cooperate. 
Say you had a dataclass:

@dataclass
class Base:
def __post_init__(self, some_arg):
pass

How would an arbitrary derived class know how to call this? It can't. There has 
to be knowledge of the base class's requirements already. Surely knowing 
"__post_init__ must be called with some_arg" isn't too different from "I know 
__post_init__ doesn't exist". I don't think adding ways to make the "always 
call super" pattern easier is a good idea.

I'm still unconvinced, but I'll hold off on making a decision to see if there's 
more support. Maybe taking it to python-ideas would be worthwhile.

--

___
Python tracker 

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



[issue46800] Support for pause(2)

2022-02-19 Thread Philip Rowlands


New submission from Philip Rowlands :

Went looking for os.pause() but found nothing in the docs, bpo, or Google.
https://man7.org/linux/man-pages/man2/pause.2.html

Obviously not a popular syscall, but I have a use case for it.

--
components: Library (Lib)
messages: 413554
nosy: philiprowlands
priority: normal
severity: normal
status: open
title: Support for pause(2)
type: enhancement

___
Python tracker 

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



[issue46757] dataclasses should define an empty __post_init__

2022-02-19 Thread Neil Girdhar


Neil Girdhar  added the comment:

> I'm not crazy about adding a method to every dataclass just for the 0.1% of 
> the times it's needed.

I'm not sure I totally understand the cost here.  You can have a single shared 
global function that you set on each dataclass.  So the only cost would be an 
entry in each dataclass type's dict.  Even if a user creates a thousand 
dataclasses, that should only be tens of killobytes in pointers.

> I think using hasattr or catching the exception is a better way to go.

If you choose this, then I think this should be documented under the 
__post_init__ saying that any time you define __post_init__, you should either 
be a final class, or else call super.  If you call super, you musteither use 
hasattr(super().__post_init__) or catch the exception.

I have to admit, I find this quite ugly from a user perspective.

--

___
Python tracker 

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



Re: Long running process - how to speed up?

2022-02-19 Thread Dan Stromberg
On Sat, Feb 19, 2022 at 3:29 AM Shaozhong SHI 
wrote:

> I have a cvs file of 932956 row and have to have time.sleep in a Python
> script.  It takes a long time to process.
>
> How can I speed up the processing?  Can I do multi-processing?
>

How are you doing it right now?

Are you using the csv module?

You might be able to use the GNU "split" command as a prelude to using the
csv module in combination with multiprocessing.  GNU split comes with
Linuxes, but I'm sure you can get it for Windows.  MacOS comes with a
rather less powerful "split" command, but it still might work for you.

You also could try Pypy3.

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


[issue46795] Why Does 3rd/Python39/Lib/site-packages/psycopg2/_psycopg.cp39-win_amd64.pyd Have the CVE-2021-3711 CVE-2021-23840 CVE-2021-3450 CVE-2021-3712 CVE-2021-23841 CVE-2021-3449 CVE-2021-4160 V

2022-02-19 Thread Zachary Ware


New submission from Zachary Ware :

Psycopg2 is a third-party package; questions about it should be directed to the 
Users category of discuss.python.org, the python-list mailing list, or a forum 
specific to psycopg2.

Also, note that Python 3.9.2 is well out of date; you should update to 3.9.10 
or 3.10.2.  On Windows, OpenSSL is included with Python, and is most easily 
updated by updating Python.

And lastly, please use the comment field rather than cramming your comments 
into the title field.

--
nosy: +zach.ware
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



[issue46400] Please update bundled libexpat to 2.4.4 with security fixes (CVE-2021-45960)

2022-02-19 Thread sping


sping  added the comment:

Overlooked your reference, so you already know, my bad, nevermind.

--

___
Python tracker 

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



[issue46400] Please update bundled libexpat to 2.4.4 with security fixes (CVE-2021-45960)

2022-02-19 Thread sping


sping  added the comment:

Yes, I have already created bpo-46794 for 2.4.5.

--

___
Python tracker 

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



Re: Error installing requirements

2022-02-19 Thread Marco Sulla
Maybe you compiled Python 2.7 by hand, David? It happened to me when I
tried to compile Python without zlib headers installed on my OS. Don't
know how it can be done on Windows.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45098] asyncio.CancelledError should contain more information on cancellations

2022-02-19 Thread Sam Bull


Sam Bull  added the comment:

I think there's still a problem, in that the user still expects a task to be 
cancelled in the example previously: 
https://github.com/aio-libs/async-timeout/issues/229#issuecomment-908502523

If we encounter the race condition where the timeout cancels the task and then 
the user cancels the task, then we still have the case that async-timeout 
swallows the cancellation and the task will run forever. This would basically 
require the user to check everytime they want to cancel the task, with 
something awkward like:

```
while not task.cancel() and not task.cancelled():
await asyncio.sleep(0)
```

I think this change is still necessary, but rather than adding multiple values 
to e.args, we can use the new ExceptionGroup to raise multiple CancelledErrors. 
So, each call of task.cancel() will create a new CancelledError, and then all 
of those CancelledErrors will get raised together.

For async-timeout, we can then just catch the CancelledError with our sentinel 
and raise a TimeoutError, while reraising any other CancelledErrors.

--

___
Python tracker 

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



[issue46757] dataclasses should define an empty __post_init__

2022-02-19 Thread Eric V. Smith


Eric V. Smith  added the comment:

I'm not crazy about adding a method to every dataclass just for the 0.1% of the 
times it's needed.

I think using hasattr or catching the exception is a better way to go.

--

___
Python tracker 

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



[issue46200] Discourage logging f-strings due to security considerations

2022-02-19 Thread Arie Bovenberg


Arie Bovenberg  added the comment:

Thanks @gregory.p.smith! I didn't know about discuss.python.org. I created a 
new topic there: 
https://discuss.python.org/t/safer-logging-methods-for-f-strings-and-new-style-formatting/13802

--

___
Python tracker 

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



[issue46797] ast.Constant.n deprecated without warning

2022-02-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is because we did not have a plan for removing deprecates features. 
Deprecation in documentation only helps third-party code. Instead of adding a 
complex code which switches between using old and new names depending on Python 
version, the third-party code can continue to use old names without worring 
about deprecation warnings, and switch completely to using new features only 
when support of old Python versions be dropped. 3.7 and 3.8 are not so old and 
may be still supported in third-party code.

I have created a PR which adds deprecation warnings, but I am not sure that it 
is worth to include it in 3.11.

--
priority: normal -> low
resolution:  -> postponed

___
Python tracker 

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



Re: Long running process - how to speed up?

2022-02-19 Thread Kirill Ratkin

Hi,

How I understand your script starts another script and should wait until 
second one completes its job. Right?


If so you have several options depend on how your first script is written.

If your script is async then ... there is good asyncio option

proc = await asyncio.create_subprocess_shell(
f"{execcmd}{execargs}", stdin=None, stdout=None
)
await proc.wait() In this way you can starn many workers and you don't neet to 
wait then in sync manner.


Anyway, just please give more info about what problem you face.

19.02.2022 14:28, Shaozhong SHI пишет:

I have a cvs file of 932956 row and have to have time.sleep in a Python
script.  It takes a long time to process.

How can I speed up the processing?  Can I do multi-processing?

Regards,

David

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


[issue46797] ast.Constant.n deprecated without warning

2022-02-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



Re: Long running process - how to speed up?

2022-02-19 Thread Shaozhong SHI
Can it be divided into several processes?
Regards,
David

On Saturday, 19 February 2022, Chris Angelico  wrote:

> On Sat, 19 Feb 2022 at 22:59, Karsten Hilbert 
> wrote:
> >
> > > > I have a cvs file of 932956 row and have to have time.sleep in a
> Python
> > > > script.  It takes a long time to process.
> > > >
> > > > How can I speed up the processing?  Can I do multi-processing?
> > > >
> > > Remove the time.sleep()?
> >
> > He's attesting to only having "time.sleep" in there...
> >
> > I doubt removing that will help much ;-)
>
> I honestly don't understand the question, hence offering the
> stupidly-obvious suggestion in the hope that it would result in a
> better question. A million rows of CSV, on its own, isn't all that
> much to process, so it must be the processing itself (of which we have
> no information other than this reference to time.sleep) that takes all
> the time.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Long running process - how to speed up?

2022-02-19 Thread Albert-Jan Roskam
   On Feb 19, 2022 12:28, Shaozhong SHI  wrote:

 I have a cvs file of 932956 row and have to have time.sleep in a Python
 script.  It takes a long time to process.

 How can I speed up the processing?  Can I do multi-processing?

   
   Perhaps a dask df: 
   https://docs.dask.org/en/latest/generated/dask.dataframe.read_csv.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Re: Long running process - how to speed up?

2022-02-19 Thread Chris Angelico
On Sat, 19 Feb 2022 at 22:59, Karsten Hilbert  wrote:
>
> > > I have a cvs file of 932956 row and have to have time.sleep in a Python
> > > script.  It takes a long time to process.
> > >
> > > How can I speed up the processing?  Can I do multi-processing?
> > >
> > Remove the time.sleep()?
>
> He's attesting to only having "time.sleep" in there...
>
> I doubt removing that will help much ;-)

I honestly don't understand the question, hence offering the
stupidly-obvious suggestion in the hope that it would result in a
better question. A million rows of CSV, on its own, isn't all that
much to process, so it must be the processing itself (of which we have
no information other than this reference to time.sleep) that takes all
the time.

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


[issue46791] Allow os.remove to defer to rmdir

2022-02-19 Thread Eryk Sun


Eryk Sun  added the comment:

In Windows, checking for a directory in order to defer to either 
os_rmdir_impl() or os_unlink_impl() would lead to a redundant directory check. 
os_unlink_impl() already has to check for a directory in order to delete a 
directory symlink or mountpoint. I suggest implementing a common _Py_remove() 
function in Windows. For example:

typedef enum {
REMOVE_FILE,
REMOVE_DIR,
REMOVE_BOTH,
} _Py_remove_mode;

int
_Py_remove(path_t *path, _Py_remove_mode mode)
{
BOOL isDir = FALSE;
BOOL isLnk = FALSE;
BOOL success = FALSE;

if (mode != REMOVE_DIR) {
DWORD fileAttributes = GetFileAttributesW(path->wide);
if (fileAttributes != INVALID_FILE_ATTRIBUTES) {
isDir = fileAttributes & FILE_ATTRIBUTE_DIRECTORY;
}

if (isDir && (mode == REMOVE_FILE)) {
WIN32_FIND_DATAW data;
HANDLE hFind = FindFirstFileW(path->wide, );
if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
isLnk = IsReparseTagNameSurrogate(data.dwReserved0);
}
}
}
}

if (mode == REMOVE_DIR || isDir && (mode == REMOVE_BOTH || isLnk)) {
success = RemoveDirectoryW(path->wide);
} else {
success = DeleteFileW(path->wide);
}

return success ? 0 : -1;
}

The multiple opens for GetFileAttributesW(), FindFirstFileW() and DeleteFileW() 
add up to make the delete more expensive and more race prone than it has to be. 
It would be nice to use a single open for all operations. But the Windows API 
just has CreateFileW(), which requires SYNCHRONIZE access. The latter can't be 
granted by the parent directory, unlike FILE_READ_ATTRIBUTES and DELETE access. 
We could implement a version that uses CreateFileW(), and fall back on the 
above version when access is denied, similar to what we do for os.stat(). Also, 
Python is limited to the Windows 8.1 SDK, which makes it awkward to use 
FileDispositionInfoEx (POSIX delete) like DeleteFileW() does in Windows 10, but 
it should still be possible.

--
nosy: +eryksun
stage:  -> needs patch
versions: +Python 3.11

___
Python tracker 

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



[issue46799] ShareableList memory bloat and performance improvement

2022-02-19 Thread Ting-Che Lin


New submission from Ting-Che Lin :

The current implementation of ShareableList keeps an unnecessary list of 
offsets in self._allocated_offsets. This list could have a large memory 
footprint if the number of items in the list is high. Additionally, this list 
will be copied in each process that needs access to the ShareableList, 
sometimes negating the benefit of the shared memory. Furthermore, in the 
current implementation, different metadata is kept at different sections of 
shared memory, requiring multiple struck.unpack_from calls for a __getitem__ 
call. I have attached a prototype that merged the allocated offsets and packing 
format into a single section in the shared memory. This allows us to use single 
struck.unpack_from operation to obtain both the allocated offset and the 
packing format. By removing the self._allocated_offset list and reducing the 
number of struck.unpack_from operations, we can drastically reduce the memory 
usage and increase the reading performance by 10%. In the case where there are 
only intege
 rs in the ShareableList, we can reduce the memory usage by half. The attached 
implementation also fixed the issue https://bugs.python.org/issue44170 that 
causes error when reading some Unicode characters. I am happy to adapt this 
implementation into a proper bugfix/patch if it is deemed reasonable.

--
components: Library (Lib)
files: shareable_list.py
messages: 413544
nosy: davin, pitrou, tcl326
priority: normal
severity: normal
status: open
title: ShareableList memory bloat and performance improvement
type: performance
versions: Python 3.10, Python 3.11, Python 3.9
Added file: https://bugs.python.org/file50632/shareable_list.py

___
Python tracker 

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



Aw: Re: Long running process - how to speed up?

2022-02-19 Thread Karsten Hilbert
> > I have a cvs file of 932956 row and have to have time.sleep in a Python
> > script.  It takes a long time to process.
> >
> > How can I speed up the processing?  Can I do multi-processing?
> >
> Remove the time.sleep()?

He's attesting to only having "time.sleep" in there...

I doubt removing that will help much ;-)

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


Re: Long running process - how to speed up?

2022-02-19 Thread Chris Angelico
On Sat, 19 Feb 2022 at 22:30, Shaozhong SHI  wrote:
>
> I have a cvs file of 932956 row and have to have time.sleep in a Python
> script.  It takes a long time to process.
>
> How can I speed up the processing?  Can I do multi-processing?
>
Remove the time.sleep()?

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


[issue46798] xml.etree.ElementTree: get() doesn't return default value, always ATTLIST value

2022-02-19 Thread padremayi


New submission from padremayi :

XML test file:









]>



This is a simple object
2022
Myself




Python code:
import xml.etree.ElementTree


try:
xml_data = xml.etree.ElementTree.iterparse("test.xml", events=("start", 
"end"))

for event, xml_tag in xml_data:
if event == "end" and xml_tag.tag == "object":
object_name = xml_tag.get("name")
object_description = xml_tag.find("description").text
works = xml_tag.get("works", default="foo")

print("works value: " + str(works))

xml_tag.clear()

print("Done!")

except (NameError, xml.etree.ElementTree.ParseError):
print("XML error!")


Output:
works value: yes
Done!


Expected behaviour:
works value: foo
Done!

--
components: XML
messages: 413543
nosy: padremayi
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree: get() doesn't return default value, always 
ATTLIST value
type: behavior
versions: Python 3.8

___
Python tracker 

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



Long running process - how to speed up?

2022-02-19 Thread Shaozhong SHI
I have a cvs file of 932956 row and have to have time.sleep in a Python
script.  It takes a long time to process.

How can I speed up the processing?  Can I do multi-processing?

Regards,

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


[issue46782] Docs error for 3.10

2022-02-19 Thread Éric Araujo

Éric Araujo  added the comment:

Octal 777 is really the same as decimal 511.
If you are calling mkdir and looking at the permissions on the created 
directory, you may think the mode is wrong because of umask (default permission 
bitmask that’s applied to the mode).  But the numbers are really equivalent, we 
are only talking about a doc presentation issue here, not any problem in code.

--

___
Python tracker 

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



Re: Error installing requirements

2022-02-19 Thread Albert-Jan Roskam
   On Feb 18, 2022 08:23, Saruni David  wrote:
   >> Christian Gohlke's site has a Pillow .whl for python
   2.7: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46795] Why Does 3rd/Python39/Lib/site-packages/psycopg2/_psycopg.cp39-win_amd64.pyd Have the CVE-2021-3711 CVE-2021-23840 CVE-2021-3450 CVE-2021-3712 CVE-2021-23841 CVE-2021-3449 CVE-2021-4160 V

2022-02-19 Thread zjmxq


Change by zjmxq :


--
title: Why Does 
3rd/Python39/Lib/site-packages/psycopg2/_psycopg.cp39-win_amd64.pyd Have the 
CVE-20211-4160 Vulnerability? I Use Python 3.9.2? Where Is OpenSSL Used? -> Why 
Does 3rd/Python39/Lib/site-packages/psycopg2/_psycopg.cp39-win_amd64.pyd Have 
the CVE-2021-3711 CVE-2021-23840 CVE-2021-3450 CVE-2021-3712 CVE-2021-23841 
CVE-2021-3449 CVE-2021-4160 Vulnerability? I Use Python 3.9.2? Where Is OpenSSL 
Used?

___
Python tracker 

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



[issue46797] ast.Constant.n deprecated without warning

2022-02-19 Thread Jakub Wilk


New submission from Jakub Wilk :

ast.Constant.n is documented to be deprecated, but you don't get any warning 
when you use it:

$ python3.11 -Wd
Python 3.11.0a5 (main, Feb 12 2022, 17:11:59) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> help(ast.Constant.n)
Help on property:

Deprecated. Use value instead.

>>> ast.Constant(value=42).n
42

--
components: Library (Lib)
messages: 413541
nosy: jwilk, serhiy.storchaka
priority: normal
severity: normal
status: open
title: ast.Constant.n deprecated without warning
versions: Python 3.11

___
Python tracker 

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



[issue46757] dataclasses should define an empty __post_init__

2022-02-19 Thread Neil Girdhar

Neil Girdhar  added the comment:

On Sat, Feb 19, 2022 at 2:51 AM Vedran Čačić  wrote:

>
> Vedran Čačić  added the comment:
>
> That "except AttributeError" approach is a powerful bug magnet, since it
> can very easily mask real attribute errors stemming from misspelled
> attribute names in the __post_init__ call itself. What you should _really_
> do is
>
> def __post_init__(self):
> with contextlib.suppress(AttributeError):
> post_init = super().__post_init__
> post_init()
>
> But of course, nobody will ever write that.
>
> Great point!

Raymond in his "super considered super" video (
> https://youtu.be/xKgELVmrqfs?t=2068) says the right thing to do is to
> make your own root which knows exactly what classes it manages, and drops
> the supercalls from them (after possibly verifying that all kwargs have
> actually been used and so on).
>
> But in case of dataclasses, usually any class can serve as such a root,
> and the main reason people use dataclasses is to avoid boilerplate code. So
> I think it would be a nice compromise.
>

I'm not sure I understand what you're saying here.  Anyone can inherit from
a class C with the special root and some other class D, and then your
introduced root won't catch D's super calls.

>
> --
> nosy: +veky
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue46777] Fix incorrect use of directives in asyncio documentation

2022-02-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue24053] Define EXIT_SUCCESS and EXIT_FAILURE constants in sys

2022-02-19 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy:  -mark.dickinson

___
Python tracker 

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