[issue45067] Failed to build _curses on CentOS 7

2021-09-06 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

According to https://invisible-island.net/ncurses/NEWS.html#index-t20170401 the 
function extended_color_content was introduced in 2017, maybe the detection of 
support for this function doesn't work properly for some reason (although the 
preprocessor logic in Modules/_cursesmodule.c looks sane).

That said, I don't have a CentOS VM at the moment so cannot debug this myself.

--

___
Python tracker 

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



[issue45111] whole website translation error

2021-09-06 Thread W Huang


New submission from W Huang :

Traditional Chinese is translated incorrectly into Simplified Chinese.
But Taiwanese CAN NOT read Simplified Chinese fluently.
In addition, there are many words called by different name between Chinese and 
Taiwanese.
Sometimes Taiwanese CAN NOT understand what a word used in China means.

--
messages: 401126
nosy: m4jp62
priority: normal
severity: normal
status: open
title: whole website translation error

___
Python tracker 

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



[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread paul j3


paul j3  added the comment:

The idea of combining help features by defining a subclass that inherits from 
other subclasses was endorsed by the original developer (we could dig up an old 
bug/issue to prove that).

The provided subclasses all tweak a "private" method, often one that's buried 
deep in the calling stack.

I can't quote any official policy, but my sense is that Python developers are 
ok with users subclassing and modifying "private" methods.  Methods, functions 
and classes (and variables) with leading '_' aren't documented, or imported via 
`__all__`, but otherwise the boundary between what is part of the user API and 
what's "hidden" is loose in Python.  

Apparently some corporate policies prohibit use or modification of things that 
aren't in the public API, but I don't think that policy protects you from 
changes.  'argparse' changes at a glacial rate, with a lot of concern for 
backward compatibility.  In fact it's that fear of unintended consequences that 
slows down the pace of change.  Subclassing a help formatter is preferred 
because it minimizes the chance of hurting existing users.

--

___
Python tracker 

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



[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread Forest


Forest  added the comment:

>Subclassing a help formatter is preferred because it minimizes the chance of 
>hurting existing users.

Fair enough.

Whatever the approach, I hope argparse can be made to support this through a
simple, documented interface.  I had to grovel through standard library code
to figure out what to override and what to duplicate in order to get the
output I want.  That seems like a needlessly high barrier for such a common
(and apparently oft-requested) format.

--

___
Python tracker 

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



[issue45112] Python exception object is different after pickle.dumps and pickle.loads

2021-09-06 Thread Chen Zero


Change by Chen Zero :


--
title: Python exception object is different after pickle.loads and pickle.dumps 
-> Python exception object is different after pickle.dumps and pickle.loads

___
Python tracker 

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



[issue45106] Issue formating for log on Linux machines

2021-09-06 Thread Inada Naoki


Inada Naoki  added the comment:

It is fixed in Python 3.9.

* https://github.com/python/cpython/pull/14008
* https://bugs.python.org/issue37111

Python 3.8 is "security" status for now. Non-security issues won't be fixed.
Please migrate to Python 3.9.

--
nosy: +methane
resolution:  -> wont fix
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



[issue45112] Python exception object is different after pickle.loads and pickle.dumps

2021-09-06 Thread Chen Zero


New submission from Chen Zero :

Hi, when I'm trying to serialize/deserialize python exception object through 
pickle, I found that deserialize result is not the same as the original 
object...

My python version is 3.9.1, working os: macOS Big Sur 11.4

Here is minimum reproducing code example:

import pickle

class ExcA(Exception):
def __init__(self, want):
msg = "missing "
msg += want
super().__init__(msg)

ExcA('bb')   # this will output ExcA("missing bb"), which is good
pickle.loads(pickle.dumps(ExcA('bb')))  # this will output ExcA("missing 
missing bb"), which is different from `ExcA('bb')`

--
files: screenshot.png
messages: 401128
nosy: yonghengzero
priority: normal
severity: normal
status: open
title: Python exception object is different after pickle.loads and pickle.dumps
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50262/screenshot.png

___
Python tracker 

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



[issue42959] AttributeError: module 'signal' has no attribute 'SIGHUP'

2021-09-06 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +iritkatriel
nosy_count: 6.0 -> 7.0
pull_requests: +26608
pull_request: https://github.com/python/cpython/pull/23688

___
Python tracker 

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



[issue42238] Deprecate suspicious.py?

2021-09-06 Thread Julien Palard


Julien Palard  added the comment:


New changeset 37272f5800ee1e9fcb2da4a1766366519b9b3d94 by Julien Palard in 
branch 'main':
bpo-42238: [doc] remove unused, and deduplicate, suspicious ignore rules. 
(GH-28137)
https://github.com/python/cpython/commit/37272f5800ee1e9fcb2da4a1766366519b9b3d94


--

___
Python tracker 

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



[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread Forest


Forest  added the comment:

Here's another working example, allowing alternate separator strings (as
requested in #33389) via subclassing:

class OneMetavarHelpFormatter(argparse.HelpFormatter):
"""A formatter that avoids repeating action metavars.
"""
OPTION_SEPARATOR = ', '
METAVAR_SEPARATOR = ' '

def _format_action_invocation(self, action):
"""Format action help without repeating the argument metavar
"""
if not action.option_strings or action.nargs == 0:
return super()._format_action_invocation(action)

default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
options_string = self.OPTION_SEPARATOR.join(action.option_strings)
return options_string + self.METAVAR_SEPARATOR + args_string

--

___
Python tracker 

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



[issue40512] [subinterpreters] Meta issue: per-interpreter GIL

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

Hai Shi:
> IMO, I suggest to create a new function, PyStructSequence_FromModuleAndDesc()

Please create a new issue. If possible, I would prefer to have a sub-issue for 
that, to keep this issue as a tracking issue for all issues related to 
subinterpreters.

--

___
Python tracker 

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



[issue42959] AttributeError: module 'signal' has no attribute 'SIGHUP'

2021-09-06 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests:  -26608

___
Python tracker 

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



[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread Forest


Forest  added the comment:

To be clear, I wrote those examples to be non-invasive, not patch proposals.
A cleaner approach would be possible if patching argparse is an option.  (I
believe the patch in #42980 proposes such an approach.)

--

___
Python tracker 

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



[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-09-06 Thread Hai Shi


Hai Shi  added the comment:

> But I encourage you to try, so you get a better understanding of the problem 
> :)

OK, thanks, Petr. I try to add this C API to see what will happen :)

--

___
Python tracker 

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



[issue45112] Python exception object is different after pickle.dumps and pickle.loads

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

The default __reduce__ method of Exception returns the arg you pass to the 
Exception constructor:

>>> a = ExcA("a banana")
>>> a.__reduce__()
(, ('missing a banana',))
>>> 


This is then pickled, and when unpickled the arg is passed to the ExcA 
constructor. 

If you want to change this, you can implement __reduce__ on ExcA o return just 
the part you want it to return.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue45112] Python exception object is different after pickle.dumps and pickle.loads

2021-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution: not a bug -> 
status: closed -> open

___
Python tracker 

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



RE: on writing a while loop for rolling two dice

2021-09-06 Thread Avi Gross via Python-list
For some people the "while true" method seems reasonable but it has a
problem if the internal body does not have some guarantee of an exit. And
that exit can be subtle. Many have mentioned ways an end condition can fail
due to rounding errors not being exactly equal to what you are looking for,
or an asymptotic process that approaches zero with a cutoff that is thus
never reached.

But I have seen some cases where you want a process or thread to run
indefinitely until it is killed by another process or you reboot. You could
of course use something like flag="green" and have your while keep testing
that value but that is just wasted motion. Of course, properly used, it does
help explain to the reader what your intention is, if done properly. It also
can confuse if you put in "while 5 < 6" or other weird ways to say do this
indefinitely.

I think part of this conversation is about programming styles and what we
should teach new students versus those who are trying to find more creative
ways to do things or more efficiently or more generality. Sometimes a more
direct method may be reasonable. On another forum, I saw someone write
somewhat lengthy and redundant code on how to deal with partitioning data
into three clusters randomly. My algorithm was general and handled any
number of N clusters and since N often does not cleanly divide the number of
items, has to place the remaining items into one of the N clusters or
distribute them one at a time into some to make them almost even in size.

His solution was to repeat large sections of code, three times, with some
modification, for the cases where the remainder (modulo N) was 0, 1 or 2.
The latter method was longer but in an odd way, much easier to understand.
It boiled down to, if you have one extra put it here. If you have two, put
one here and one there. My method had all kinds of bells and whistles that
this specific case did not need.

Let me end with asking if anyone has ever seen a mild variant of this:

... # code

while false
   apologize()

... # more code

-Original Message-
From: Python-list  On
Behalf Of Hope Rouselle
Sent: Thursday, September 2, 2021 10:42 AM
To: python-list@python.org
Subject: Re: on writing a while loop for rolling two dice

David Raymond  writes:

>> def how_many_times():
>>   x, y = 0, 1
>>   c = 0
>>   while x != y:
>> c = c + 1
>> x, y = roll()
>>   return c, (x, y)
>
> Since I haven't seen it used in answers yet, here's another option 
> using our new walrus operator
>
> def how_many_times():
> roll_count = 1
> while (rolls := roll())[0] != rolls[1]:
> roll_count += 1
> return (roll_count, rolls)

That's nice, although it doesn't seem more readable to a novice seeing a
while for the first time, seeing a loop for the first time, than that
while-True version.  In fact, I think the while-True is the clearest so far.
But it's always nice to spot a walrus in the wild!  (If you're somewhere
safe, that is.)
--
https://mail.python.org/mailman/listinfo/python-list

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


[issue45115] Windows: enable compiler optimizations when building Python in debug mode

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


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

___
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 and later on Windows

2021-09-06 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy:  -pablogsal

___
Python tracker 

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



[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue45105] Incorrect handling of unicode character \U00010900

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue45115] Windows: enable compiler optimizations when building Python in debug mode

2021-09-06 Thread Steve Dower


Steve Dower  added the comment:

I strongly disagree. If CI needs to be faster, please just change the CI 
configuration. If contributors have to wait a few minutes longer, they can wait 
- they'll save that time in local compilations.

Local debugging absolutely relies on debug builds. You'd be destroying the 
workflow of most Windows-based developers with this change. It's not worth it.

--

___
Python tracker 

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



[issue28978] a redundant right parentheses in the EBNF rules of parameter_list

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

This doc has changed, and it's now like this:

parameter_list::=  defparameter ("," defparameter)* "," "/" ["," 
[parameter_list_no_posonly]]
 | parameter_list_no_posonly
parameter_list_no_posonly ::=  defparameter ("," defparameter)* ["," 
[parameter_list_starargs]]
   | parameter_list_starargs
parameter_list_starargs   ::=  "*" [parameter] ("," defparameter)* ["," ["**" 
parameter [","]]]
   | "**" parameter [","]

--
nosy: +iritkatriel
resolution:  -> out of date
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue29232] Quiet Install

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

Earl, is there still an open problem to look into here or can this be closed?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue34561] Replace list sorting merge_collapse()?

2021-09-06 Thread Tim Peters


Tim Peters  added the comment:


New changeset 5cb4c672d855033592f0e05162f887def236c00a by Tim Peters in branch 
'main':
bpo-34561: Switch to Munro & Wild "powersort" merge strategy. (#28108)
https://github.com/python/cpython/commit/5cb4c672d855033592f0e05162f887def236c00a


--

___
Python tracker 

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



[issue45119] test_signal.test_itimer_virtual() failed on AMD64 Fedora Rawhide 3.x

2021-09-06 Thread STINNER Victor

STINNER Victor  added the comment:

It seems like the kernel was just upgrade from 5.14 to 5.15.rc0:

vstinner@python-builder-rawhide$ date
lun. 06 sept. 2021 14:05:43 EDT

vstinner@python-builder-rawhide$ grep kernel /var/log/dnf.log
2021-09-03T06:35:58-0400 DEBUG Installed: 
kernel-5.15.0-0.rc0.20210901git9e9fb7655ed5.2.fc36.x86_64
...
2021-09-04T06:31:34-0400 DEBUG Installed: 
kernel-5.15.0-0.rc0.20210902git4ac6d90867a4.4.fc36.x86_64
...

vstinner@python-builder-rawhide$ rpm -q kernel
kernel-5.14.0-0.rc5.20210813gitf8e6dfc64f61.46.fc36.x86_64
kernel-5.15.0-0.rc0.20210901git9e9fb7655ed5.2.fc36.x86_64
kernel-5.15.0-0.rc0.20210902git4ac6d90867a4.4.fc36.x86_64

vstinner@python-builder-rawhide$ uptime
 14:06:00 up  3:14,  1 user,  load average: 2,47, 2,58, 3,11

vstinner@python-builder-rawhide$ journalctl --list-boots
-1 04d2796c1f374367add41a55f48c7dad Sat 2021-08-28 14:55:16 EDT—Mon 2021-09-06 
10:50:57 EDT
 0 1a10ace470bd4016ad19fd25d248fc57 Mon 2021-09-06 10:51:11 EDT—Mon 2021-09-06 
14:12:36 EDT

--

___
Python tracker 

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



[issue45111] whole website translation error

2021-09-06 Thread Ned Deily


Change by Ned Deily :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker 

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



[issue45103] IDLE: make configdialog font page survive font failures

2021-09-06 Thread E. Paine


E. Paine  added the comment:

> did problems occur without displaying any emoji

I was using an unmodified version of IDLE.

> If they include one of those characters in the font name displayed in the 
> font list

This is not the case. It is listed simply as "Phaistos", when calling 
`tkinter.font.families()`.

> if we verify the report

Report verified. Behaviour is exactly as described, hanging when trying to load 
the "Configure IDLE" window. I will look into exactly which line is the problem 
soon.

--

___
Python tracker 

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



[issue32750] lib2to3 log_error method behavior is inconsitent with documentation

2021-09-06 Thread Irit Katriel


Change by Irit Katriel :


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



Re: Problem with python

2021-09-06 Thread Grant Edwards
On 2021-09-04, Hope Rouselle  wrote:
> Igor Korot  writes:
>
>> Hi,
>> Will this syntax work in python 2?
>
> If you say
>
>   print(something)
>
> it works in both.

But it doesn't always work the _same_ in both. If you're expecting
some particular output, then one or the other might not won't "work".

> So, stick to this syntax.

Only if you import print_function from __future__ in 2.x

--
Grant


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


Re: on writing a while loop for rolling two dice

2021-09-06 Thread Dennis Lee Bieber
On Sat, 4 Sep 2021 12:27:55 -0500, "Michael F. Stemper"
 declaimed the following:

>
>Kernighan and Ritchie agree(d) with you. Per _The C Programming
>Language__:
>   Experience shows that do-while is much less used that while
>   and for.
>

And just for confusion, consider languages with "repeat / until"...

"do / while" repeats so long as the condition evaluates to "true";
"repeat / until" /exits/ when the condition evaluates to "true".

Then... there is Ada...

While one is most likely to encounter constructs:

for ix in start..end loop
...
end loop;

and

while condition loop
...
end loop;

the core construct is just a bare

loop
...
end loop;

which, with the "exit when condition" statement allows low-level emulation
of any loop... (same as Python "if condition: break"

loop-- "while" loop
exit when not condition;
...
end loop;

loop-- "repeat / until"
...
exit when condition;
end loop;

loop-- split
...
exit when condition;
...
end loop;

{I'm not going to do the "for" loop, but one can easily manage
initialization/increment/test statements}.


To really get your mind blown, look at loops in REXX...

do while condition
...
end

do until condition
/* note that the termination parameter is listed at top, */
/* but takes effect at the bottom, so always one pass */
...
end

do forever
...
if condition then
leave
...
end

do idx = start to end /* optional: by increment */
...
end

do idx = 1 by increment for repetitions
...
end

AND worse! You can combine them...

do idx = start for repetitions while condition1 until condition2
...
end

{I need to check if both while and until can be in the same statement}


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

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


Re-design the position of the RPROMPT string.

2021-09-06 Thread hongy...@gmail.com
I forked and made some improvements to the ariadne package [1]. I noticed that 
the current RPROMPT line is composed by percol.view.PROMPT [2] and 
percol.view.__class__.RPROMPT [3], as shown below:

X10DAi-00 (M-h/M-n)> M-m:string Path:C-d Local:C-l Unique:M-r Exit0:M-t 
Fold:F1,F2,F3

But this leaves very little room for the search string used to filter the 
history. So, I want to split the RPROMPT line into two lines as follows:

M-m:string Path:C-d Local:C-l Unique:M-r Exit0:M-t Fold:F1,F2,F3
X10DAi-00 (M-h/M-n)>

But I've tried a lot and still don't know how to do it. Any hints will be 
highly appreciated.

Regareds,
HY

[1] https://github.com/hongyi-zhao/ariadne
[2] 
https://github.com/hongyi-zhao/ariadne/blob/ec864434b8a947b801f019e84c827c3a96dcf7e4/rc.py#L56
[3] 
https://github.com/hongyi-zhao/ariadne/blob/ec864434b8a947b801f019e84c827c3a96dcf7e4/rc.py#L73
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45112] Python exception object is different after pickle.dumps and pickle.loads

2021-09-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

It would be nice if exception pickling was more friendly to subclasses.  
Perhaps, the default should be to store and restore all state including args 
and a __dict__ if any.

--

___
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 and later on Windows

2021-09-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Perhaps these critical code sections should have been left as macros. It is 
difficult to assuring system wide inlining across modules.

--
nosy: +rhettinger

___
Python tracker 

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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread Steve Dower


Steve Dower  added the comment:


New changeset 19871fce3b74fc3f37e334a999e00d0ef65a8f1e by Nikita Sobolev in 
branch 'main':
bpo-45052: Unskips a failing `test_shared_memory_basics` test (GH-28182)
https://github.com/python/cpython/commit/19871fce3b74fc3f37e334a999e00d0ef65a8f1e


--

___
Python tracker 

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



[issue41082] Error handling and documentation of Path.home()

2021-09-06 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I looked a bit more into this, it's been fixed in 3.10, in this PR: 
https://github.com/python/cpython/pull/18841

It wasn't backported to 3.9. I'm not quite sure if it's best to backport to 3.9 
or fix via docs for 3.9. Just in case I've put up a small PR for such a docfix.

--

___
Python tracker 

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



[issue41082] Error handling and documentation of Path.home()

2021-09-06 Thread Andrei Kulakov


Change by Andrei Kulakov :


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



[issue39899] `pathlib.Path.expanduser()` does not call `os.path.expanduser()`

2021-09-06 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Note this change also fixes https://bugs.python.org/issue41082 . I'm guessing 
it's too much of an edge case to backport this fix to 3.9, so I've put up a 
possible fix via docs update on that issue.

--
nosy: +andrei.avk, kj

___
Python tracker 

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



[issue39899] `pathlib.Path.expanduser()` does not call `os.path.expanduser()`

2021-09-06 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

To be more precise, this change fixes https://bugs.python.org/issue41082 by 
raising RuntimeError instead of KeyError and also by documenting it, which 
means matplotlib can fix it by either using os.path.expanduser or catching 
RuntimeError, whichever might work better in their case.

I will let them know once we sort this out.

--

___
Python tracker 

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



[issue45119] test_signal.test_itimer_virtual() failed on AMD64 Fedora Rawhide 3.x

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

I rewrote the test in C, see attached setitimer.c.

On Fedora 34:
---
$ rpm -q glibc
glibc-2.33-20.fc34.x86_64
$ uname -r
5.13.8-200.fc34.x86_64

$ gcc setitimer.c -o setitimer && ./setitimer
setitimer(<0.5, 0.5>)
SIGVTALRM
SIGVTALRM
SIGVTALRM
SIGVTALRM
setitimer(<0, 0>) ok
SIGVTALRM is disarmed
wait 3 seconds
setitimer(<0, 0>) ok
exit
---

On Fedora Rawhide:
---
$ rpm -q glibc
glibc-2.34.9000-5.fc36.x86_64
$ uname -r
5.15.0-0.rc0.20210902git4ac6d90867a4.4.fc36.x86_64

$ gcc setitimer.c -o setitimer && ./setitimer
setitimer(<0.5, 0.5>)
SIGVTALRM
SIGVTALRM
SIGVTALRM
SIGVTALRM
setitimer(<0, 0>) ok
SIGVTALRM
FATAL ERROR: SIGVTALRM timer not disarmed!
Abandon (core dumped)
---

--
Added file: https://bugs.python.org/file50265/setitimer.c

___
Python tracker 

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



[issue45103] IDLE: make configdialog font page survive font failures

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

If nothing else, I should amend the doc note about font problems to include 
Windows if we verify the report.

--

___
Python tracker 

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



[issue45118] regrtest no longer lists "re-run tests" in the second summary

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue7391] [doc] restore the "Idioms and Anti-Idioms in Python" document

2021-09-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The document out of date when it was removed and is now another dozen years 
older.  Since then no one has expresses any interest with this and other tools 
have emerged to deal with code formatting.

--
resolution:  -> out of date
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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread Steve Dower


Steve Dower  added the comment:

The test fix looks good to me. That resolves this issue, yes? The other work is 
going on elsewhere?

--
nosy:  -miss-islington

___
Python tracker 

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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 9.0 -> 10.0
pull_requests: +26613
pull_request: https://github.com/python/cpython/pull/28185

___
Python tracker 

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



[issue25066] Better repr for multiprocessing.synchronize objects

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

The patch need to be converted to a GitHub PR.

--
keywords: +easy -patch
nosy: +iritkatriel
stage: patch review -> needs patch
versions: +Python 3.11 -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



[issue45119] test_signal.test_itimer_virtual() failed on AMD64 Fedora Rawhide 3.x

2021-09-06 Thread STINNER Victor


New submission from STINNER Victor :

AMD64 Fedora Rawhide 3.x:
https://buildbot.python.org/all/#/builders/285/builds/685

It is likely test_itimer_virtual() of test_signal which failed.

On the buildbot worker:

$ rpm -q glibc
glibc-2.34.9000-5.fc36.x86_64
$ uname -r
5.15.0-0.rc0.20210902git4ac6d90867a4.4.fc36.x86_64

test.pythoninfo:

platform.libc_ver: glibc 2.34.9000
platform.platform: 
Linux-5.15.0-0.rc0.20210902git4ac6d90867a4.4.fc36.x86_64-x86_64-with-glibc2.34.9000

Logs:

test test_signal crashed -- Traceback (most recent call last):
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/libregrtest/runtest.py",
 line 340, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
  ^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/libregrtest/runtest.py",
 line 297, in _runtest_inner2
test_runner()
^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/libregrtest/runtest.py",
 line 261, in _test_module
support.run_unittest(tests)
^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/support/__init__.py",
 line 1123, in run_unittest
_run_suite(suite)
^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/support/__init__.py",
 line 998, in _run_suite
result = runner.run(suite)
 ^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/runner.py",
 line 176, in run
test(result)

  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/suite.py",
 line 84, in __call__
return self.run(*args, **kwds)
   ^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/suite.py",
 line 122, in run
test(result)

  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/suite.py",
 line 84, in __call__
return self.run(*args, **kwds)
   ^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/suite.py",
 line 122, in run
test(result)

  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/suite.py",
 line 84, in __call__
return self.run(*args, **kwds)
   ^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/suite.py",
 line 122, in run
test(result)

  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/case.py",
 line 652, in __call__
return self.run(*args, **kwds)
   ^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/case.py",
 line 569, in run
result.startTest(self)
^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/support/testresult.py",
 line 41, in startTest
super().startTest(test)
^^^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/runner.py",
 line 54, in startTest
self.stream.write(self.getDescription(test))
  ^
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/unittest/runner.py",
 line 44, in getDescription
def getDescription(self, test):
  File 
"/home/buildbot/buildarea/3.x.cstratak-fedora-rawhide-x86_64/build/Lib/test/test_signal.py",
 line 739, in sig_vtalrm
raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL "
^^^
signal.itimer_error: setitimer didn't disable ITIMER_VIRTUAL timer.


Code of the test:

def sig_vtalrm(self, *args):
self.hndl_called = True

if self.hndl_count > 3:
# it shouldn't be here, because it should have been disabled.
raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL " 
 # < HERE
"timer.") # 
<=== HERE
elif self.hndl_count == 3:
# disable ITIMER_VIRTUAL, this function shouldn't be called anymore
signal.setitimer(signal.ITIMER_VIRTUAL, 0)

self.hndl_count += 1

# Issue 3864, unknown if this affects earlier versions of freebsd also  
  
@unittest.skipIf(sys.platform in ('netbsd5',),  
  
'itimer not reliable (does not mix well with threading) on some BSDs.') 
  
def test_itimer_virtual(self):  
  
self.itimer = signal.ITIMER_VIRTUAL

[issue45119] test_signal.test_itimer_virtual() failed on AMD64 Fedora Rawhide 3.x

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +cstratak

___
Python tracker 

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



[issue34561] Replace list sorting merge_collapse()?

2021-09-06 Thread Tim Peters


Change by Tim Peters :


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



[issue30637] Syntax error reported on compile(...), but not on compile(..., ast.PyCF_ONLY_AST)

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The doc section in question is
https://docs.python.org/3/library/ast.html#ast.parse

I confirmed that 'break', 'continue', 'yield', and 'return' still parse, with 
the results how having "type_ignores=[]" added.
  'Module(body=[Expr(value=Yield())], type_ignores=[])'
I do not understand Nick's comment about 'await' as 'await' is not a legal 
statement'

The current initial paragraph says:
  "Parse the source into an AST node. Equivalent to compile(source, filename, 
mode, ast.PyCF_ONLY_AST)."

I suggest following this with:
  "If the AST node is compiled to a code object, there are additional syntax 
checks that can raise errors.  "For example, 'return' parses to a node, but is 
not legal outside of a def statement."

Hrvoje's suggested adding something like
  "If source contains a null character ('\0'), ValueError is raised."

I don't think that this is needed as ast.parse is explicitly noted as 
equivalent to a compile call, and the compile doc says "This function raises 
SyntaxError if the compiled source is invalid, and ValueError if the source 
contains null bytes."  (Should not that be 'null characters' given that 
*source* is now unicode?) This statement need not be repeated here.

--
versions: +Python 3.11 -Python 2.7, Python 3.7

___
Python tracker 

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



[issue30637] Syntax error reported on compile(...), but not on compile(..., ast.PyCF_ONLY_AST)

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

Re null in source code, see issue20115.

--

___
Python tracker 

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



[issue34561] Replace list sorting merge_collapse()?

2021-09-06 Thread Carl Friedrich Bolz-Tereick


Carl Friedrich Bolz-Tereick  added the comment:

Thanks for your work Tim, just adapted the changes to PyPy's Timsort, using 
bits of runstack.py!

--
nosy: +Carl.Friedrich.Bolz

___
Python tracker 

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



[issue45103] IDLE: make configdialog font page survive font failures

2021-09-06 Thread E. Paine


E. Paine  added the comment:

IDLE is hanging on Lib/idlelib/configdialog.py:94 (`self.wait_window()`). 
Commenting this does not solve the problem: I think it's in the Tk event loop 
somewhere, since my debugger shows the Python callback completing successfully. 
This still doesn't explain the behaviour, however, so I'll need to spend a bit 
more time tracking it down.

--

___
Python tracker 

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



[issue45120] Windows cp encodings "UNDEFINED" entries update

2021-09-06 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 8.0 -> 9.0
pull_requests: +26615
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28189

___
Python tracker 

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



Re: CPython / Decimal and bit length of value.

2021-09-06 Thread jak

Il 03/09/2021 22:09, Nacnud Nac ha scritto:

Hi,
Is there a quick way to get the number of bits required to store the value in a 
Decimal class?
What obvious thing am I missing? I'm working with really large integers, say, 
in the order of 5_000_000 of ASCII base 10 digits.
It seems the function mpd_sizeinbase would be a nice thing to be able to 
call.
It'd be nice to just be able to tell the "size of data", or something like that, that was 
stored in the *data? I note there is len "field" in the structure mpd_t
Sorry for the dumb question
Thanks,Duncan


to semplfy the example I'll use the value 100:

value="100"

exponent in base 10 is len(value) - 1 # (1 * 10^6)

now need change from base 10 to base 2: newexp = 6 / log(2) # 19 (more 
or less)


you will need newexp + 1 bits to represent the number: 2^20 = 1.048.576

hope helps


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


[issue45116] Performance regression 3.10b1 and later on Windows

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

Rather than defining again functions as macro, you should consider using 
__forceinline function attribute: see bpo-45094.

--

___
Python tracker 

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



[issue18534] [doc] State clearly that open() 'file' param is "name" attr of the result

2021-09-06 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy
title: State clearly that open() 'file' param is "name" attr of the result -> 
[doc] State clearly that open() 'file' param is "name" attr of the result
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.3, Python 3.4

___
Python tracker 

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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread Nikita Sobolev

Nikita Sobolev  added the comment:

I think that adding extra tests and docs are two separate new tasks. I will
open them today.

Thanks a lot, everyone!

пн, 6 сент. 2021 г. в 19:56, Steve Dower :

>
> Steve Dower  added the comment:
>
> The test fix looks good to me. That resolves this issue, yes? The other
> work is going on elsewhere?
>
> --
> nosy:  -miss-islington
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-09-06 Thread Steve Dower


Steve Dower  added the comment:

It should also be possible to reduce the stack size of each frame. We've done 
that before, because there were multiple temporary buffers allocated on the 
stack that were trivially moved into functions. I bet we can also reduce the 
number of indirections, as last time I had to investigate a native stack we 
seem to have bloated up to 6-7 C frames for each Python frame.

Failing that, I'd rather have an option to build with higher stack size just 
for tests (or users who care that much - my experience is that people tend to 
care more about many Python processes rather than high recursion). That only 
affects python[w][_uwp].exe.

We could also add a threading API to allow creating new threads with larger 
stack size. That would allow us to write tests that can do it, and also enable 
users who may run into it. I'd prefer Windows just be able to expand the stack 
better at runtime, but the reserved address space apparently wins the 
back-compat argument.

--

___
Python tracker 

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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread miss-islington


miss-islington  added the comment:


New changeset 6b5aea2dc1bf7e117d40d6c9035d5c13124fd968 by Miss Islington (bot) 
in branch '3.10':
bpo-45052: Unskips a failing `test_shared_memory_basics` test (GH-28182)
https://github.com/python/cpython/commit/6b5aea2dc1bf7e117d40d6c9035d5c13124fd968


--
nosy: +miss-islington

___
Python tracker 

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



[issue41082] Error handling and documentation of Path.home()

2021-09-06 Thread Andrei Kulakov


Change by Andrei Kulakov :


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

___
Python tracker 

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



[issue45119] test_signal.test_itimer_virtual() failed on AMD64 Fedora Rawhide 3.x

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

It may be a Linux kernel 5.15 regression. I'm now trying to report this issue 
to the Linux kernel.

--

___
Python tracker 

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



[issue29232] Quiet Install

2021-09-06 Thread Steve Dower


Steve Dower  added the comment:

The underlying issue is known and tracked by issue25166

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
superseder:  -> Windows All Users installation places uninstaller in user 
profile

___
Python tracker 

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



[issue45103] IDLE: make configdialog font page survive font failures

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Thank you for finding what I could not.

Your previous message, referenced above, reporting a problem that remains in 
8.6.11 on linux, was ...

"For me, this is not limited to special characters. Trying to load anything in 
Tk using the 'JoyPixels' font crashes (sometimes it does load but all 
characters are very random - most are whitespace - and it crashes again after a 
call to `fc-cache`). IDLE crashes when trying to preview the font.

I believe this is what is being experienced on 
https://askubuntu.com/questions/1236488/x-error-of-failed-request-badlength-poly-request-too-large-or-internal-xlib-le
 because they are not using any special characters yet are reporting the same 
problem."

JoyPixels is an emoji font.  There are emoji in the BMP, but not in IDLE's 
initial font sample.  Did you add some, or did problems occur without 
displaying any emoji?
---

I presume that the Phaistos 'font' has glyphs for the unicode phaistos block in 
the first astral plane, U+101D0..101FD.
https://en.wikipedia.org/wiki/Phaistos_Disc_(Unicode_block)

If they include one of those characters in the font name displayed in the font 
list (ugh), then a problem is understandable, and the fix would be to filter 
astral chars (and possibly more) out of font names.  But I won't assume this.

Please try the experiments I outlined if you are so inclined.

--

___
Python tracker 

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



[issue45120] Windows cp encodings "UNDEFINED" entries update

2021-09-06 Thread Rafael Belo

New submission from Rafael Belo :

There is a mismatch in specification and behavior in some windows encodings.

Some older windows codepages specifications present "UNDEFINED" mapping, 
whereas in reality, they present another behavior which is updated in a section 
named "bestfit".

For example CP1252 has a corresponding bestfit1525: 
CP1252: 
https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
bestfit1525: 
https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit1252.txt


>From which, in CP1252, bytes \x81 \x8d \x8f \x90 \x9d map to "UNDEFINED", 
>whereas in bestfit1252, they map to \u0081 \u008d \u008f \u0090 \u009d 
>respectively. 

In the Windows API, the function 'MultiByteToWideChar' exhibits the bestfit1252 
behavior.


This issue and PR proposes a correction for this behavior, updating the windows 
codepages where some code points where defined as "UNDEFINED" to the 
corresponding bestfit mapping. 


Related issue: https://bugs.python.org/issue28712

--
components: Demos and Tools, Library (Lib), Unicode, Windows
messages: 401181
nosy: ezio.melotti, lemburg, paul.moore, rafaelblsilva, steve.dower, 
tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: Windows cp encodings "UNDEFINED" entries update
type: behavior

___
Python tracker 

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



Re: on floating-point numbers

2021-09-06 Thread Dennis Lee Bieber
On Sat, 04 Sep 2021 10:40:35 -0300, Hope Rouselle 
declaimed the following:

>course, I don't even have floats to worry about.)  If I'm given 1.17,
>say, I am not confident that I could turn this number into 117 by
>multiplying it by 100.  And that was the question.  Can I always
>multiply such IEEE 754 dollar amounts by 100?
>

HOW are you "given" that 1.17? If that is coming from some
user-readable source (keyboard entry, text-based file [CSV/TSV, even SYLK])
you do NOT have a number -- you have a string, which needs to be converted
by some algorithm.

For money, the best solution, again, is to use the Decimal module and
feed the /string/ to the initialization call. If you want to do it
yourself, to get a scaled integer, you will have to code a
parser/converter.

*   strip extraneous punctuation ($, etc -- but not comma, decimal
point, or + and -)
*   strip any grouping separators (commas, but beware, some 
countries
group using a period -- "1.234,56" vs "1,234.56"). "1,234.56" => "1234.56"
*   ensure there is a decimal point (again, you may have to convert 
a
comma to decimal point), if not append a "." to the input
*   append enough 0s to the end to ensure you have whatever scale
factor you are using behind the decimal point (as mentioned M$ Excel money
type uses four places) "1234.56" => "1234.5600"
*   remove the decimal marker. "1234.5600" => "12345600"
*   convert to native integer. int("12345600") => 12345600 [as 
integer]
{may fail if +/- are not in the required position for Python}

If the number is coming from some binary file format, it is already too
late. And you might need to study any DBMS being used. Some transfer values
as text strings, and reconvert to DBMS numeric types on receipt. Make sure
the DBMS is using a decimal number type and not a floating type for the
field (which leaves out SQLite3  which will store anything in any field,
but uses some slightly obscure logic to determine what conversion is done)


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/

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


Re: on floating-point numbers

2021-09-06 Thread Grant Edwards
On 2021-09-05, Peter J. Holzer  wrote:
> On 2021-09-05 03:38:55 +1200, Greg Ewing wrote:
>> If 7.23 were exactly representable, you would have got
>> 723/1000.
>> 
>> Contrast this with something that *is* exactly representable:
>> 
>> >>> 7.875.as_integer_ratio()
>> (63, 8)
>> 
>> and observe that 7875/1000 == 63/8:
>> 
>> >>> from fractions import Fraction
>> >>> Fraction(7875,1000)
>> Fraction(63, 8)
>> 
>> In general, to find out whether a decimal number is exactly
>> representable in binary, represent it as a ratio of integers where
>> the denominator is a power of 10, reduce that to lowest terms,
>
> ... and check if the denominator is a power of two. If it isn't
> (e.g.  1000 == 2**3 * 5**3) then the number is not exactly
> representable as a binary floating point number.
>
> More generally, if the prime factorization of the denominator only
> contains prime factors which are also prime factors of your base,
> then the number can be exactle represented (unless either the
> denominator or the enumerator get too big).

And once you understand that, ignore it and write code under the
assumumption that nothing can be exactly represented in floating
point.

If you like, you can assume that 0 can be exactly represented without
getting into too much trouble as long as it's a literal constant value
and not the result of any run-time FP operations.

If you want to live dangerously, you can assume that integers with
magnitude less than a million can be exactly represented. That
assumption is true for all the FP representations I've ever used, but
once you start depending on it, you're one stumble from the edge of
the cliff.

--
Grant




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


Re: on floating-point numbers

2021-09-06 Thread Hope Rouselle
"Peter J. Holzer"  writes:

> On 2021-09-05 03:38:55 +1200, Greg Ewing wrote:
>> If 7.23 were exactly representable, you would have got
>> 723/1000.
>> 
>> Contrast this with something that *is* exactly representable:
>> 
>> >>> 7.875.as_integer_ratio()
>> (63, 8)
>> 
>> and observe that 7875/1000 == 63/8:
>> 
>> >>> from fractions import Fraction
>> >>> Fraction(7875,1000)
>> Fraction(63, 8)
>> 
>> In general, to find out whether a decimal number is exactly
>> representable in binary, represent it as a ratio of integers
>> where the denominator is a power of 10, reduce that to lowest
>> terms,
>
> ... and check if the denominator is a power of two. If it isn't (e.g.
> 1000 == 2**3 * 5**3) then the number is not exactly representable as a
> binary floating point number.
>
> More generally, if the prime factorization of the denominator only
> contains prime factors which are also prime factors of your base, then
> the number can be exactle represented (unless either the denominator or
> the enumerator get too big). So, for base 10 (2*5), all numbers which
> have only powers of 2 and 5 in the denominator (e.g 1/10 == 1/(2*5),
> 1/8192 == 1/2**13, 1/1024000 == 1/(2**13 * 5**3)) can represented
> exactly, but those with other prime factors (e.g. 1/3, 1/7,
> 1/24576 == 1/(2**13 * 3), 1/1024001 == 1/(11 * 127 * 733)) cannot.
> Similarly, for base 12 (2*2*3) numbers with 2 and 3 in the denominator
> can be represented and for base 60 (2*2*3*5), numbers with 2, 3 and 5.

Very grateful to these paragraphs.  They destroy all the mystery.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45103] IDLE: make configdialog font page survive font failures

2021-09-06 Thread E. Paine


E. Paine  added the comment:

Apologies, my previous message was not clear. When the segfault occurs is not 
consistent and sometimes occurs when previewing the font (as reported in the 
linked message) but more often when clicking the "ok" button (for which the 
faulthandler details are included).

--

___
Python tracker 

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



[issue45117] `dict` not subscriptable despite using `__future__` typing annotations

2021-09-06 Thread Ștefan Istrate

New submission from Ștefan Istrate :

According to PEP 585 
(https://www.python.org/dev/peps/pep-0585/#implementation), I expect that 
typing aliases could simply use `dict` instead of `typing.Dict`. This works 
without problems in Python 3.9, but in Python 3.8, despite using `from 
__future__ import annotations`, I get the following error:



$ /usr/local/Cellar/python@3.8/3.8.11/bin/python3.8
Python 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import annotations
>>> from typing import Any
>>> JsonDictType = dict[str, Any]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'type' object is not subscriptable



However, `dict` is subscriptable when not used in an alias:



$ /usr/local/Cellar/python@3.8/3.8.11/bin/python3.8
Python 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import annotations
>>> from typing import Any
>>> def f(d: dict[str, Any]):
... print(d)
...
>>> f({"abc": 1, "def": 2})
{'abc': 1, 'def': 2}

--
messages: 401149
nosy: stefanistrate
priority: normal
severity: normal
status: open
title: `dict` not subscriptable despite using `__future__` typing annotations
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



[issue45116] Performance regression 3.10b1 and later on Windows

2021-09-06 Thread neonene


New submission from neonene :

pyperformance on Windows shows some gap between 3.10a7 and 3.10b1.
The following are the ratios compared with 3.10a7 (the higher the slower).

-
Windows x64 |  PGO   release  official-binary
+
20210405|
3.10a7  |  1.00   1.241.00 (PGO?)
20210408-07:58  |
b98eba5 |  0.98
20210408-10:22  |
  * PR25244 |  1.04
20210503|
3.10b1  |  1.07   1.211.07
-
Windows x86 |  PGO   release  official-binary
+
20210405|
3.10a7  |  1.00   1.251.27 (release?)
20210408-07:58  |
b98eba5bc   |  1.00
20210408-10:22  |
  * PR25244 |  1.11
20210503|
3.10b1  |  1.14   1.281.29

Since PR25244 (28d28e053db6b69d91c2dfd579207cd8ccbc39e7),
_PyEval_EvalFrameDefault() in ceval.c has seemed to be unoptimized with PGO 
(msvc14.29.16.10).
At least the functions below have become un-inlined there at all.

  (1) _Py_DECREF() (from Py_DECREF,Py_CLEAR,Py_SETREF)
  (2) _Py_XDECREF()(from Py_XDECREF,SETLOCAL)
  (3) _Py_IS_TYPE()(from PyXXX_CheckExact)
  (4) _Py_atomic_load_32bit_impl() (from CHECK_EVAL_BREAKER)

I tried in vain other linker options like thread-safe-profiling, 
agressive-code-generation, /OPT:NOREF.
3.10a7 can inline them in the eval-loop even if profiling only test_array.py.

I measured overheads of (1)~(4) on my own build whose eval-loop uses macros 
instead of them.

-
Windows x64 |  PGO   patched  overhead in eval-loop
+
3.10a7  |  1.00
20210802|
3.10rc1 |  1.09   1.054%  (slow 43, fast  5, same 10)
20210831-20:42  |
863154c |  0.95   0.905%  (slow 48, fast  3, same  7)
   (3.11a0+)|
-
Windows x86 |  PGO   patched  overhead in eval-loop
+
3.10a7  |  1.00
20210802|
3.10rc1 |  1.15   1.132%  (slow 29, fast 14, same 15)
20210831-20:42  |
863154c |  1.05   1.023%  (slow 44, fast  7, same  7)
   (3.11a0+)|

--
components: C API, Interpreter Core, Windows
files: 310rc1_confirm_overhead.patch
keywords: patch
messages: 401143
nosy: Mark.Shannon, neonene, pablogsal, paul.moore, steve.dower, tim.golden, 
vstinner, zach.ware
priority: normal
severity: normal
status: open
title: Performance regression 3.10b1 and later on Windows
type: performance
versions: Python 3.10, Python 3.11
Added file: https://bugs.python.org/file50263/310rc1_confirm_overhead.patch

___
Python tracker 

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



[issue45115] Windows: enable compiler optimizations when building Python in debug mode

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

This change is motivated by my PR 28128 which converts the Py_TYPE() macro to a 
static inline function. The problem is that by default, MSC disables inlining 
and test_exceptions does crash with a stack overflow, since my change increases 
the usage of the stack memory: see bpo-44348.

By the problem is wider than just Py_TYPE().

See also bpo-45094: "Consider using __forceinline and 
__attribute__((always_inline)) on static inline functions (Py_INCREF, Py_TYPE) 
for debug builds".

--

___
Python tracker 

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



[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

Another *working* approach to fix this issue: bpo-45115 "Windows: enable 
compiler optimizations when building Python in debug mode".

--

___
Python tracker 

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



[issue40512] [subinterpreters] Meta issue: per-interpreter GIL

2021-09-06 Thread hai shi


hai shi  added the comment:

bpo-45113: [subinterpreters][C API] Add a new function to create 
PyStructSequence from Heap.

--
versions: +Python 3.11 -Python 3.10

___
Python tracker 

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



[issue45114] bad example for os.stat

2021-09-06 Thread Harri


New submission from Harri :

The example on https://docs.python.org/3/library/stat.html should be improved 
to avoid endless recursion, if there is a symlink loop. I would suggest to use 
os.lstat instead of os.stat.

--
assignee: docs@python
components: Documentation
messages: 401133
nosy: docs@python, harridu
priority: normal
severity: normal
status: open
title: bad example for os.stat
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



[issue45103] IDLE: make configdialog font page survive font failures

2021-09-06 Thread E. Paine


E. Paine  added the comment:

FTR, the issue mentioned is issue42225.

msg380227 still applies for me (with Tk 8.6.11), with segfaults when I try to 
preview the font. For some reason, however, the segfault appears to be when 
we're closing the options window:

Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> import idlelib.idle
Fatal Python error: Segmentation fault

Current thread 0x7f0ca44c7740 (most recent call first):
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2580 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/idlelib/configdialog.py", line 199 in destroy
  File "/usr/lib/python3.9/idlelib/configdialog.py", line 177 in ok
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1892 in __call__
  File "/usr/lib/python3.9/tkinter/__init__.py", line 696 in wait_window
  File "/usr/lib/python3.9/idlelib/configdialog.py", line 94 in __init__
  File "/usr/lib/python3.9/idlelib/editor.py", line 583 in config_dialog
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1892 in __call__
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1858 in event_generate
  File "/usr/lib/python3.9/idlelib/editor.py", line 1185 in command
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1892 in __call__
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1429 in mainloop
  File "/usr/lib/python3.9/idlelib/pyshell.py", line 1572 in main
  File "/usr/lib/python3.9/idlelib/idle.py", line 14 in 
  File "", line 228 in _call_with_frames_removed
  File "", line 850 in exec_module
  File "", line 680 in _load_unlocked
  File "", line 986 in _find_and_load_unlocked
  File "", line 1007 in _find_and_load
  File "", line 1 in 
fish: Job 1, 'python' terminated by signal SIGSEGV (Address boundary error)

I do not experience any problems loading the IDLE preferences page. I will look 
into whether I can reproduce the problem described on Windows.

--
nosy: +epaine

___
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 and later on Windows

2021-09-06 Thread neonene


Change by neonene :


Added file: https://bugs.python.org/file50264/ceval_310rc1_patched.c

___
Python tracker 

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



[issue45115] Windows: enable compiler optimizations when building Python in debug mode

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

I recently documented the "Python debug build":
https://docs.python.org/dev/using/configure.html#python-debug-build

--

___
Python tracker 

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



[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-09-06 Thread Petr Viktorin


Petr Viktorin  added the comment:

I think you will run into issues with allocating tp_members, because there 
isn't a good mechanism to for type objects to manage C-level data.

But I encourage you to try, so you get a better understanding of the problem :)

--

___
Python tracker 

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



[issue44863] Allow TypedDict to inherit from Generics

2021-09-06 Thread Samodya Abey


Samodya Abey  added the comment:

My initial intention to create this ticket was to explore the idea that if we 
could side step from creating a PEP or updating PEP-589.

IMO only contribution from a new PEP will be:
1. relaxing this line from PEP-589 and be explicit to include Generic: "A 
TypedDict cannot inherit from both a TypedDict type and a non-TypedDict base 
class." (IMO by thinking `Generic` as a mixin even this is not needed)
2. may be syntax for generic in the alternative syntax (side note: collecting 
typevars from the values is hard to implement because of forward refs)
3. Some explicit generic examples for good measure

I believe PEP-589 is complete in covering all semantic details even with 
Generics. Even structural subtyping because it says: "Value types behave 
invariantly, since TypedDict objects are mutable."

My understanding was that during initial implementation this was not done for 
the sake of implementation simplicity (days before PEP-560).

All that said, a new PEP would be a good way to notify the type checkers of 
this capability.

Is there a better place to have this conversation?

--

___
Python tracker 

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



[issue30637] Syntax error reported on compile(...), but not on compile(..., ast.PyCF_ONLY_AST)

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

Adding Pablo, a.k.a The King of Errors.

--
nosy: +iritkatriel, pablogsal

___
Python tracker 

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



[issue45115] Windows: enable compiler optimizations when building Python in debug mode

2021-09-06 Thread STINNER Victor


New submission from STINNER Victor :

The Visual Studio project of Python, PCBuild\ directory, disables compiler 
optimizations when Python is built in debug mode. It seems to be the default in 
Visual Studio.

Disabling compiler optimizations cause two kinds of issues:

* It increases the stack memory: tests using a deep call stack are more likely 
to crash (test_pickle, test_marshal, test_exceptions).

* Running the Python test suite take 19 min 41 sec instead of 12 min 19 sec on 
Windows x64: 1.6x slower. Because of that, we cannot use a debug build in the 
GitHub Action pre-commit CI, and we miss bugs which are catched "too late", in 
Windows buildbots. See my latest attempt to use a debug build in GitHub 
Actions: https://github.com/python/cpython/pull/24914

Example of test_marshal:

# The max stack depth should match the value in Python/marshal.c.
# BUG: https://bugs.python.org/issue33720
# Windows always limits the maximum depth on release and debug builds
#if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
if os.name == 'nt':
MAX_MARSHAL_STACK_DEPTH = 1000
else:
MAX_MARSHAL_STACK_DEPTH = 2000

I propose to only change the compiler options for the pythoncore project which 
builds most important files for the Python "core". See attached PR.

--
components: Windows
messages: 401141
nosy: paul.moore, steve.dower, tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: Windows: enable compiler optimizations when building Python in debug mode
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



[issue45115] Windows: enable compiler optimizations when building Python in debug mode

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +26610
pull_request: https://github.com/python/cpython/pull/28128

___
Python tracker 

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



[issue28451] pydoc.safeimport() raises ErrorDuringImport() if __builtin__.__import__ is monkey patched

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

It is no longer using the traceback check:

https://github.com/python/cpython/blob/37272f5800ee1e9fcb2da4a1766366519b9b3d94/Lib/pydoc.py#L445

--
nosy: +iritkatriel
resolution:  -> out of date
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



[issue30060] Crash with subinterpreters and Py_NewInterpreter()

2021-09-06 Thread Irit Katriel


Irit Katriel  added the comment:

Closing as there was no followup to Eric's question. Please create a new issue 
if you still see this problem on a version >= 3.9.

--
nosy: +iritkatriel
resolution:  -> out of date
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



[issue7391] [doc] restore the "Idioms and Anti-Idioms in Python" document

2021-09-06 Thread Irit Katriel


Change by Irit Katriel :


--
title: Re-title the "Using Backslash to Continue Statements" anti-idiom -> 
[doc] restore the "Idioms and Anti-Idioms in Python" document
versions: +Python 3.11 -Python 3.2, Python 3.3

___
Python tracker 

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



[issue45118] regrtest no longer lists "re-run tests" in the second summary

2021-09-06 Thread STINNER Victor


New submission from STINNER Victor :

When running Python with test -w/--verbose2 command line option to re-run tests 
which failed, the failing tests are listed in the first summary, and they are 
not listed in the final summary.

Example with Lib/test/test_x.py:
---
import builtins
import unittest

class Tests(unittest.TestCase):
def test_succeed(self):
return

def test_fail_once(self):
if not hasattr(builtins, '_test_failed'):
builtins._test_failed = True
self.fail("bug")
---

Current output when running test_sys (success) and test_x (failed once, then 
pass):
---
$ ./python -m test test_sys test_x -w
0:00:00 load avg: 0.80 Run tests sequentially
0:00:00 load avg: 0.80 [1/2] test_sys
0:00:01 load avg: 0.80 [2/2] test_x
test test_x failed -- Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/test_x.py", line 11, in 
test_fail_once
self.fail("bug")

AssertionError: bug

test_x failed (1 failure)

== Tests result: FAILURE ==

1 test OK.

1 test failed:
test_x

1 re-run test:
test_x
0:00:01 load avg: 0.80
0:00:01 load avg: 0.80 Re-running failed tests in verbose mode
0:00:01 load avg: 0.80 Re-running test_x in verbose mode (matching: 
test_fail_once)
test_fail_once (test.test_x.Tests) ... ok

--
Ran 1 test in 0.000s

OK

== Tests result: FAILURE then SUCCESS ==

All 2 tests OK.

Total duration: 2.0 sec
Tests result: FAILURE then SUCCESS
---

"re-run tests" is missing in the last summary.

--
components: Tests
messages: 401151
nosy: vstinner
priority: normal
severity: normal
status: open
title: regrtest no longer lists "re-run tests" in the second summary
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



[issue45113] [subinterpreters][C API] Add a new function to create PyStructSequence from Heap.

2021-09-06 Thread hai shi


New submission from hai shi :

Copied from https://bugs.python.org/issue40512#msg399847:

Victor: PyStructSequence_InitType2() is not compatible with subinterpreters: it 
uses static types. Moreover, it allocates tp_members memory which is not 
released when the type is destroyed. But I'm not sure that the type is ever 
destroyed, since this API is designed for static types.

> PyStructSequence_InitType2() is not compatible with subinterpreters: it uses 
> static types. Moreover, it allocates tp_members memory which is not released 
> when the type is destroyed. But I'm not sure that the type is ever destroyed, 
> since this API is designed for static types.

IMO, I suggest to create a new function, 
PyStructSequence_FromModuleAndDesc(module, desc, flags) to create a heaptype 
and don't aloocates memory block for tp_members,something like 
'PyType_FromModuleAndSpec()`.

--
components: C API
messages: 401129
nosy: petr.viktorin, shihai1991, vstinner
priority: normal
severity: normal
status: open
title: [subinterpreters][C API] Add a new function to create PyStructSequence 
from Heap.
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



[issue45112] Python exception object is different after pickle.dumps and pickle.loads

2021-09-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue45112] Python exception object is different after pickle.dumps and pickle.loads

2021-09-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Pickling customized subclasses can be tricky.  The essential details are here:  
https://docs.python.org/3/library/pickle.html#object.__reduce__

Here's some code to get you started.

class ExcA(Exception):
def __init__(self, want):
msg = "missing "
msg += want
super().__init__(msg)
def __reduce__(self):
return (type(self), self.args, self.args)
def __setstate__(self, state):
self.args = stat

--
nosy: +rhettinger

___
Python tracker 

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



[issue44863] Allow TypedDict to inherit from Generics

2021-09-06 Thread Guido van Rossum

Guido van Rossum  added the comment:

Since this primarily affects static type checkers such as mypy, Pyre and 
pyright, it’s best to discuss it on typing-sig.

--

___
Python tracker 

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



[issue45094] Consider using __forceinline and __attribute__((always_inline)) on static inline functions (Py_INCREF, Py_TYPE) for debug builds

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

Sadly, Py_ALWAYS_INLINE does *not* prevent test_exceptions to crash with my PR 
28128 (convert Py_TYPE macro to a static inline function). Even if the 
Py_TYPE() static inline function is inlined, the stack memory still increases. 
MSC produces inefficient machine code. It allocates useless variables on the 
stack which requires more stack memory.

I propose a different approach: bpo-45115 "Windows: enable compiler 
optimizations when building Python in debug mode".

--

___
Python tracker 

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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Ok, that's what I was able to find.

Original BPO: https://bugs.python.org/issue35813
Original PRs (sources + tests):
- https://github.com/python/cpython/pull/11664 it was a little bit "rushed"
- https://github.com/python/cpython/pull/11816 follow up

Related: https://bugs.python.org/issue38169

1. The test fails because `sms.size != sms2.size`
2. The `sms2` object is a pickle-unpickle copy of `sms`
3. The `__reduce__` method defined in `SharedMemory` returns `(name=self.name, 
create=False, size=self.size)` tuple
4. So, when `sms2` is constructed, `size` is ignored, because `create` is 
`False`

Moreover, even when `size` is passed with `create=True` the docs say that the 
final amount of allocated memory is platform specific (no details on the exact 
platforms): it can be larger or equal. Link: 
https://github.com/python/cpython/blame/main/Doc/library/multiprocessing.shared_memory.rst#L61
 

So, this statement makes `self.assertEqual(sms.size, sms2.size)` potentially 
flaky.

After reading all this my suggestion is:
1. Remove `self.assertEqual(sms.size, sms2.size)` line, since this behavior is 
not guaranteed to work
2. Add docs about how `pickle` works with `SharedMemory` / `ShareableList`. 
Right now it is not clear. This should be just an explanation of the current 
status-quo
3. Add more tests on unpickled `Shared*` objects. Including overflowing set 
memory limits on unpickled objects and other implemetation details

I will start with `1.` right now, later I can work on `3.`.
But, I feel like someone more knowledgeable should take `2.` (or at least guide 
me, since `SharedMemory` is not something I use everyday).

--

___
Python tracker 

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



[issue45052] WithProcessesTestSharedMemory.test_shared_memory_basics fails on Windows

2021-09-06 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
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 and later on Windows

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

Raymond:
> Perhaps these critical code sections should have been left as macros. It is 
> difficult to assuring system wide inlining across modules.

These functions were not converted recently to static inline function. For 
example, Py_INCREF() was already a static inline function in Python 3.9. I 
don't think that any decision should be taken before performances have been 
analyzed in depth.

I'm not convinced that there is really a performance regression. I'm not sure 
how benchmarks are run on Windows.

neonene:
> I measured overheads of (1)~(4) on my own build whose eval-loop uses macros 
> instead of them.

I don't understand how to read the table.

Usually, I expect a comparison between a reference build and a patch build, but 
here you seem to use 3.10a7 as the reference to compare results. I'm not sure 
that geometric means can be compared this way.

--

___
Python tracker 

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



[issue44828] Using tkinter.filedialog crashes on macOS Python 3.9.6

2021-09-06 Thread Fahim Faisal


Fahim Faisal  added the comment:

Can also confirm this issue, tested on M1 and Intel Mac and both has the same 
error when using Monterey 12.0 Beta 21A5506j. 

On the same computer, using Big Sur, saves the file successfully and no error 
present. Seems like a Monterey issue, not dependent on specific hardware. 
(Intel/M1)

Tested on fresh Python 3.9.6 (tk version 8.6) Installation on Big Sur and 
Monterey Beta (Build 21A5506j) on a M1 Macbook Pro and Early 2015 13" Macbook 
Pro.

--
nosy: +i3p9

___
Python tracker 

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



[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

Using trashcan, it's possible to create a long longer than 10 000 exceptions. 
But currently, Python does crash in this case, so I stopped the benchmark at 10 
000.

--

___
Python tracker 

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



RE: on writing a while loop for rolling two dice

2021-09-06 Thread Avi Gross via Python-list
Let me add something, Stefan. Some people just want to get a job done. For
this person, he had a very specific need for a one-time project where the
rest of it was understood but one small step was confusing. Frankly, he
could have done it faster by opening a text editor on something like a CSV
file and flipped some (actual) three-sided coins while manually doing a cut
and past of lines into three new files and near the end, make sure the last
few only went into files with a missing row or two.

I have too often had people ask me for programming help and when I suggested
they learn how to do it or let me make a more careful piece of code that
checks for errors or will easily work under various changed conditions,
guess what I usually encounter? Many just want it DONE. They often
sheepishly come back some time later with some variant of the same need that
mysteriously does not work with code they asked to be designed to just work
in one case! Often they hack away at the code in odd ways first and then
come to me to have it fixed.

But there are costs to generality and creating functions with dozens of
optional arguments and that handle a wide variety of inputs and thus
constantly are checking what types they are working with and perhaps
converting to others or need to create objects with lots of dunders, can
also make it error prone.

Looking at our forever loop discussion, how often are the contents of the
loop written with multiple terminating parts within the loop body that get
complex? I mean lots of break or continue statements all over the place
with multi-part if statements. Some can be rewritten as a more standard loop
with a condition like "while (a < 5 && found_it == FALSE || ( ... )) ..."
and often in the body you need if statements that let you skip the rest if
found_it is true. It can be a mess either way. At times you need to consider
rewriting it from scratch. This especially happens as requirements keep
changing. Ages ago we had code that processed MTA headers and every time we
had a meeting of standards bodies, we kept adding ever more headers and
keywords that often required some existing code to also look at other
headers that now might be present as they might change what you did in
existing code locations. I eventually suggested a rewrite and it turned out
to be more compact now that we evaluated some things first, rather than
within many existing parts.

Has anyone mentioned the really stupid looking forever loop in languages
with the other style of for loop?

for ( ; ;)  

All that generally was,  was an initialization command before a while and so
on but here all three parts were null, so why use it?

And in the python version, has anyone made a generator that returned NULL or
the like so you can say uselessly:

for ( _ in forever() ) ...


-Original Message-
From: Python-list  On
Behalf Of Stefan Ram
Sent: Monday, September 6, 2021 12:34 PM
To: python-list@python.org
Subject: Re: on writing a while loop for rolling two dice

"Avi Gross"  writes:
>For some people the "while true" method seems reasonable but it has a 
>problem if the internal body does not have some guarantee of an exit. 
>And

  A programming error where the condition used does not
  express the intent of the programmer can happen with
  any kind of while loop.

>help explain to the reader what your intention is, if done properly. It 
>also can confuse if you put in "while 5 < 6" or other weird ways to say 
>do this indefinitely.

  If any reader cannot understand "while True:", it's not
  a problem with the source code.

  When someone writes "while True:", it is clearly his intention
  that the following indented code is repeated until it's exited
  by some means, which means is not the while condition.

>His solution was to repeat large sections of code, three times, with 
>some modification, for the cases where the remainder (modulo N) was 0, 1 or
2.

  This is typical of 

- beginners who just do not know the means of the language
  to reduce redundancy yet,

- less experience programmers, who know the language but
  still are not able to apply features to reduce redundancy
  always,

- premature publication of unfinished code where the
  redundancy has not yet been reduced, or

- programmers who do not have the personal means to climb to
  the level of abstraction needed to remove the redundancy
  in a specific case.

  And, I think you wrote that too, sometimes less smart code is
  more readable or maintainable. Maybe three very similar blocks
  are repeated literally because future modifications are expected
  that will make them less similar.


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

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


[issue44348] test_exceptions.ExceptionTests.test_recursion_in_except_handler stack overflow on Windows debug builds

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

test_recursion_in_except_handler() creates chained of exceptions. When an 
exception is deallocated, it calls the deallocator of another exception, etc.

* recurse_in_except() sub-test creates chains of 11 nested deallocator calls
* recurse_in_body_and_except() sub-test creates a chain of 8192 nested 
deallocator calls

I'm not sure how recurse_in_body_and_except() can creates a chain which is so 
long, knowing that the test sets the recursion limit to 44 frames (default 
Python limit is 1000).

--

___
Python tracker 

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



[issue44958] [sqlite3] only reset statements when needed

2021-09-06 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

In msg399939, item 2 lacks one more "reset path":

> 2. at cursor exit, if there's an active statement

Rewording this to:

2. when a statement is removed from a cursor; that is either at cursor dealloc, 
or when the current statement is replaced.

--

___
Python tracker 

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



  1   2   >