[issue44892] Configparser fails when the .cfg file contains comments

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Make PR branch from main, which I used for testing. I verified issue on 3.10 
and 3.9, so we will backport.

--
stage: needs patch -> test needed
title: Configparser fails when the file contains $ inside a comment -> 
Configparser fails when the .cfg file contains comments
versions: +Python 3.10, Python 3.9

___
Python tracker 

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



[issue20115] NUL bytes in commented lines

2021-09-06 Thread Guido van Rossum

Guido van Rossum  added the comment:

Serhiy’s comment from 2014-01-04 gives the answer. It’s different reading from 
a file than from a string. And only “python x.py” still reads from a file.

--

___
Python tracker 

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



[issue44892] Configparser fails when the file contains $ inside a comment

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Diego, I repaired the defacement, which included removing you as nosy.

Relevant doc: 
https://docs.python.org/3/library/configparser.html#configparser.BasicInterpolation

To me, the following line implies that % may be used freely in comments.
  gain: 80%%  # use a %% to escape the % sign (% is the only character ...
However, IDLE uses .cfg files and configparser, and when I added #% to my 
C:/Users/Terry/.idlerc/config-main.cfg, IDLE startup fails with the following, 
confirming the behavior.

Traceback (most recent call last):
  File "f:\dev\3x\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
   ^^^
  File "f:\dev\3x\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
^^^
  File "f:\dev\3x\lib\idlelib\__main__.py", line 7, in 
idlelib.pyshell.main()
^^
  File "f:\dev\3x\lib\idlelib\pyshell.py", line 1648, in main
shell = flist.open_shell()
^^
  File "f:\dev\3x\lib\idlelib\pyshell.py", line 335, in open_shell
self.pyshell = PyShell(self)
   ^
  File "f:\dev\3x\lib\idlelib\pyshell.py", line 898, in __init__
OutputWindow.__init__(self, flist, None, None)
^^
  File "f:\dev\3x\lib\idlelib\outwin.py", line 79, in __init__
EditorWindow.__init__(self, *args)
^^
  File "f:\dev\3x\lib\idlelib\editor.py", line 215, in __init__
text['font'] = idleConf.GetFont(self.root, 'main', 'EditorWindow')
   ^^^
  File "f:\dev\3x\lib\idlelib\config.py", line 742, in GetFont
bold = self.GetOption(configType, section, 'font-bold', default=0,
   ^^^
  File "f:\dev\3x\lib\idlelib\config.py", line 229, in GetOption
return self.userCfg[configType].Get(section, option,
   ^
  File "f:\dev\3x\lib\idlelib\config.py", line 61, in Get
return self.getboolean(section, option)
   
  File "f:\dev\3x\lib\configparser.py", line 829, in getboolean
return self._get_conv(section, option, self._convert_to_boolean,
   ^
  File "f:\dev\3x\lib\configparser.py", line 809, in _get_conv
return self._get(section, conv, option, raw=raw, vars=vars,
   
  File "f:\dev\3x\lib\configparser.py", line 804, in _get
return conv(self.get(section, option, **kwargs))
^^^
  File "f:\dev\3x\lib\configparser.py", line 800, in get
return self._interpolation.before_get(self, section, option, value,
   
  File "f:\dev\3x\lib\configparser.py", line 395, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
^^
  File "f:\dev\3x\lib\configparser.py", line 442, in _interpolate_some
raise InterpolationSyntaxError(
^^^
configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', 
found: '%'

When changed one of the lines in my file see what a valid interpolation would 
do,
   font-size = 12  # for %(font)s
I got

"Warning: config.py - IdleConf.GetOption -
 invalid 'int' value for configuration option 'font-size'
 from section 'EditorWindow': '12  # for source code pro'"

configparser interpreted the comment as part of the value, and started IDLE 
with the default size 10.
The same happened when I used %%: the bad value was '12  # for %'
And again with just '#'.  Values read as string are also disabled by '#'.
"name = Custom Dark # %(parenstyle)s" resulted in the default light theme.
Conclusion: 1. Comments are currently worse than useless. 2. Test suite is 
deficient.

Diego, good PRs are welcome.  Please sign CLA first.  For this, the problem is 
comments not being recognized and stripped.  Fix that and % in comments will 
not be an issue.

--
nosy: +DiddiLeija, terry.reedy, uranusjr, zach.ware
stage:  -> needs patch
title: [configparser] Module configparser fails when the config file contains a 
"%" inside a commentary -> Configparser fails when the file contains $ inside a 
comment
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



[issue44892] [configparser] Module configparser fails when the config file contains a "%" inside a commentary

2021-09-06 Thread Kubilay Kocak


Change by Kubilay Kocak :


--
assignee: terry.reedy -> 
components: +Library (Lib) -Extension Modules, FreeBSD, IDLE, IO, Installation, 
Interpreter Core, SSL, Subinterpreters, Tests, Tkinter, Windows, XML, macOS
nosy: +lukasz.langa -koobs, ned.deily, paul.moore, ronaldoussoren, steve.dower, 
terry.reedy, tim.golden, zach.ware
title: [configparser] Module configparser fails when the config file contains 
a0918076336 "100%" inside a commentary -> [configparser] Module configparser 
fails when the config file contains a "%" inside a commentary
type: enhancement -> behavior
versions:  -Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, 
Python 3.9

___
Python tracker 

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



[issue45123] PyAiter_Check & PyObject_GetAiter issues

2021-09-06 Thread Yury Selivanov


Change by Yury Selivanov :


--
keywords: +patch
pull_requests: +26618
pull_request: https://github.com/python/cpython/pull/28194

___
Python tracker 

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



[issue45123] PyAiter_Check & PyObject_GetAiter issues

2021-09-06 Thread Yury Selivanov


New submission from Yury Selivanov :

Per discussion on python-dev (also see the linked email), PyAiter_Check should 
only check for `__anext__` existence (and not for `__aiter__`) to be consistent 
with `Py_IterCheck`.

While there, I'd like to rename PyAiter_Check to PyAIter_Check and 
PyObject_GetAiter to PyObject_GetAIter (i -> I).  First, we should apply 
CamelCase convention correctly, here "async" and "iter" are separate words; 
second, "Aiter" is marked as invalid spelling by spell checkers in IDEs which 
is annoying.

See 
https://mail.python.org/archives/list/python-...@python.org/message/BRHMOFPEKGQCCKEKEEKGSYDR6NOPMRCC/
 for more details.

--
components: Interpreter Core
messages: 401206
nosy: pablogsal, yselivanov
priority: release blocker
severity: normal
stage: patch review
status: open
title: PyAiter_Check & PyObject_GetAiter issues
type: behavior
versions: Python 3.10, Python 3.11

___
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 Dennis Sweeney


Dennis Sweeney  added the comment:

Hi Stefan,

`from __future__ import annotations` only affects annotations -- just the 
things after the colon. It makes it so that annotations are never evaluated, so 
things like this work:

>>> from __future__ import annotations
>>> x: nonsense()()()()[other_nonsense](1<2>3)

The __future__ import is not a wholesale opt-in-to-all-new-typing-features, 
it's just an opt-in-to-not-evaluate-annotations.

dict.__class_getitem__ (which is what gets called when you type dict[str, Any]) 
was not added at all until Python 3.9 (GH-18239), so if you want to *evaluate* 
such expressions, you have to upgrade to 3.9+. In 3.8, use typing.Dict instead 
-- 3.8 is no longer accepting new features.

Thanks for the report, but I'm closing this for now.

--
nosy: +Dennis Sweeney
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



RE: on writing a while loop for rolling two dice

2021-09-06 Thread Avi Gross via Python-list
It has been nearly three decades since I have had to write in C, Stefan, but
what I suggested jokingly is quite mild compared to what the winners of the
obfuscated C Contest do:

https://www.ioccc.org/

Time for me to drop out of this thread. Personally I fully agree uses of
"while' as described are perfectly understandable. Features that
sophisticated programmers love tend to confuse novices. I recall my exposure
to PERL where weird things seemed to just happen with no rhyme or reason or
connections. Turned out just about everything puts things into or takes them
out of hidden variables so much of the time, a string of commands just does
what might be expected. Another variant on the elusive concept of a
pipeline. But all the nice gimmicks and tricks make novices a bit puzzled.
On the other hand, you can still write most programs the old fashioned way
and sort of start normal then head off into hyperspace at warp speed.

Python too has a way to write fairly unsophisticated programs as well as
idioms and methods that rapidly become hard to comprehend.

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

"Avi Gross"  writes:
> In languages like C/C++ there are people who make up macros like:
>#define INDEFINITELY_LOOP while (true)
>Or something like that and then allow the preprocessor to replace 
>INDEFINITELY_LOOP with valid C code.

  Those usually are beginners.

>So, how to do something like that in python, is a challenge left to the 
>user

  Such a use of macros is frowned upon by most C programmers,
  because it renders the code unreadable.

  "while(1)" in C or "while True:" in Python is perfectly clear.
  Don't fix it if it ain't broke!


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

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


Non sequitur: on writing a while loop for rolling two dice

2021-09-06 Thread Dennis Lee Bieber


RESEND with clarification!

On Mon, 6 Sep 2021 20:11:41 -0400, Avi Gross via Python-list
 declaimed the following:

>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

Why did my mind immediately flash on "The Man Who Never Returned"?
(AKA: "M.T.A.", Kingston Trio song)

(Especially as you describe just the opposite -- many returns )


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

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


Non sequitur: on writing a while loop for rolling two dice

2021-09-06 Thread Dennis Lee Bieber
On Mon, 6 Sep 2021 20:11:41 -0400, Avi Gross via Python-list
 declaimed the following:

>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

Why did my mind immediately flash on "The Man Who Never Returned"?

(Especially as you describe just the opposite -- many returns )


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

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


[issue44892] [configparser] Module configparser fails when the config file contains a0918076336 "100%" inside a commentary

2021-09-06 Thread Nirawat Puechpian


Change by Nirawat Puechpian :


--
assignee:  -> terry.reedy
components: +Extension Modules, FreeBSD, IDLE, IO, Installation, Interpreter 
Core, SSL, Subinterpreters, Tests, Tkinter, Windows, XML, macOS -Library (Lib)
nosy: +koobs, ned.deily, paul.moore, ronaldoussoren, steve.dower, terry.reedy, 
tim.golden, zach.ware -DiddiLeija, lukasz.langa, uranusjr
title: [configparser] Module configparser fails when the config file contains a 
"%" inside a commentary -> [configparser] Module configparser fails when the 
config file contains a0918076336 "100%" inside a commentary
type: behavior -> enhancement
versions: +Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue20115] NUL bytes in commented lines

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

What I missed before is that duplicating the effect of the first two 
interactive entries (no exception) requires escaping the backslash so that the 
source argument for the explicit compile does not have a null. 

compile("'\\0'", '', 'exec')
 at 0x0214431CAA20, file "", line 1>
compile("#\\0", '', 'exec')
 at 0x0214431CAC30, file "", line 1>

So I did not actually see an exception to the rule.
---

*On Win 10*, I experimented with a version of Armin and Irit's example, without 
and with b'...' and 'wb'.

s = '#\x00\na\nb\n' 
print(len(s))  # 7
with open("f:/Python/a/nulltest.py", 'w') as f:
  f.write(s)
import nulltest

When I ran a local repository build of 3.9, 3.10, or 3.11 with
  f:\dev\3x>python f:/Python/a/nulltest.py
I got Irit's strange NameError instead of the proper ValueError.

When I ran with installed 3.9 or 3.10 with
  py -3.10 -m a.nulltest
I got the null-byte ValueError.

When I ran from IDLE's editor running on either installed or repository python, 
the import gave the null-byte ValueError.

--

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread Dong-hee Na


Dong-hee Na  added the comment:

I sent the patch for this issue: https://github.com/python/mypy/pull/11067

--

___
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 Dong-hee Na


Change by Dong-hee Na :


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

___
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 Dong-hee Na


Dong-hee Na  added the comment:

I sent the patch for this issue: https://github.com/python/mypy/pull/11067

--
nosy: +corona10

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread Dong-hee Na


Dong-hee Na  added the comment:

FYI, mypyc is using PyCode_New.
mypyc should be fixed not to use PyCode_New :)

--

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


Shantanu  added the comment:

Sorry if my message was confusing. Hopefully the following makes things clear:

3.9.6: snippet runs without error

3.9.7, with bpo-44806: (a probably reasonable) TypeError, but a breaking change

main, with bpo-45081: RecursionError

--

___
Python tracker 

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



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


Shantanu  added the comment:

As I mentioned in the post, bpo-45081 actually makes this issue worse, since we 
get a RecursionError.

I think `TypeError: Protocols cannot be instantiated` is probably okay 
behaviour (as opposed to RecursionError), more just unfortunate that it seems 
to be an unanticipated breaking change.

--

___
Python tracker 

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



[issue45104] Error in __new__ docs

2021-09-06 Thread Vedran Čačić

Vedran Čačić  added the comment:

The first variant seems best to me.

--
nosy: +veky

___
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
I hate to quibble but as almost anything in Python can evaluate to being
truthy, a command like

while "never"

evaluates to true as the string is not empty.

I meant a generator like

>>> def boring():
while True: yield()


>>> for _ in boring():
print("repeating ...")

The above gives me a nice infinite loop, with the second one looking like a
normal loop but actually doing nothing much.

-Original Message-
From: Python-list  On
Behalf Of 2qdxy4rzwzuui...@potatochowder.com
Sent: Monday, September 6, 2021 8:28 PM
To: python-list@python.org
Subject: Re: on writing a while loop for rolling two dice

On 2021-09-06 at 20:11:41 -0400,
Avi Gross via Python-list  wrote:

> And in the python version, has anyone made a generator that returned 
> NULL or the like so you can say uselessly:
> 
> for ( _ in forever() ) ...

while "forever":
...
--
https://mail.python.org/mailman/listinfo/python-list

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


[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

Possibly related to issue 45081, which ended up not having anything to do with 
dataclasses (despite the title).

Can you check if that fix solves your problem?

--
nosy: +eric.smith

___
Python tracker 

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



Re: on writing a while loop for rolling two dice

2021-09-06 Thread 2QdxY4RzWzUUiLuE
On 2021-09-06 at 20:11:41 -0400,
Avi Gross via Python-list  wrote:

> And in the python version, has anyone made a generator that returned
> NULL or the like so you can say uselessly:
> 
> for ( _ in forever() ) ...

while "forever":
...
-- 
https://mail.python.org/mailman/listinfo/python-list


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


RE: on writing a while loop for rolling two dice

2021-09-06 Thread Avi Gross via Python-list
I actually like it if a language lets you spell out your intention, although 
adding many keywords is not a plus.

So, yes something like:

loop
...
end loop;

Is appealing as it makes clear the decision on when to exit the loop must be 
within the loop (or till something kills ...)

 In languages like C/C++ there are people who make up macros like:

#define INDEFINITELY_LOOP while (true)

Or something like that and then allow the preprocessor to replace 
INDEFINITELY_LOOP with valid C code.

So, how to do something like that in python, is a challenge left to the user 

Bottom line I find is it is a great idea to write comments as even if you are 
the one reviewing the code much later, you may struggle to figure out what you 
did and why.

-Original Message-
From: Python-list  On 
Behalf Of Dennis Lee Bieber
Sent: Sunday, September 5, 2021 12:50 PM
To: python-list@python.org
Subject: Re: on writing a while loop for rolling two dice

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

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


[issue20115] NUL bytes in commented lines

2021-09-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Which part puzzles you?

I see that you tried

>>> #\0

This does not contain a null byte, just three characters: a hash, a backslash, 
and a digit zero.

--

___
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



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

bench.py: pyperf benchmarks on BaseException_dealloc().

Benchmarks results on PR 28190 on Fedora 34 with LTO (I didn't use PGO nor CPU 
pinning). It says "faster" but it's likely noise in the build or in the 
benchmark (again, I didn't use CPU pinning, and I used my laptop while the 
benchmark was running. IMO it means that the trashcan overhead is not 
significant on this benchmark.

$ python3 -m pyperf compare_to ref.json trashcan.json --table
++-+---+
| Benchmark  | ref | trashcan  |
++=+===+
| list 10_000| 1.27 ms | 1.18 ms: 1.08x faster |
++-+---+
| chain 10_000   | 3.94 ms | 3.89 ms: 1.01x faster |
++-+---+
| Geometric mean | (ref)   | 1.01x faster  |
++-+---+

Benchmark hidden because not significant (6): list 10, list 100, list 1000, 
chain 10, chain 100, chain 1000

--
Added file: https://bugs.python.org/file50266/bench.py

___
Python tracker 

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



[issue20115] NUL bytes in commented lines

2021-09-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The compile() doc currently says ""This function raises SyntaxError if the 
compiled source is invalid, and ValueError if the source contains null bytes."  
And indeed, in repository 3.9, 3.10, 3.11,

>>> compile('\0','','exec')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: source code string cannot contain null bytes

Ditto when run same in a file from IDLE or command line.  The exception 
sometimes when the null is in a comment or string within the code.

>>> '\0'
'\x00'
>>> #\0
>>> compile('#\0','','single', 0x200)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: source code string cannot contain null bytes
>>> compile('"\0"','','single', 0x200)
ValueError: source code string cannot contain null bytes

I am puzzled because "\0" and #\0 in the IDLE shell are sent as strings 
containing the string or comment to compiled with the call above in codeop.  
There must be some difference in when \0 is interpreted.

--

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

That sounds like a good plan (note that alpha 1 will go out around Oct 4).

I left an issue for Cython: https://github.com/cython/cython/issues/4365

--

___
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 Hope Rouselle
Chris Angelico  writes:

> On Sun, Sep 5, 2021 at 1:04 PM Hope Rouselle  wrote:
>> The same question in other words --- what's a trivial way for the REPL
>> to show me such cycles occur?
>>
>> >> 7.23.as_integer_ratio()
>> >>> (2035064081618043, 281474976710656)
>>
>> Here's what I did on this case.  The REPL is telling me that
>>
>>   7.23 = 2035064081618043/281474976710656
>>
>> If that were true, then 7.23 * 281474976710656 would have to equal
>> 2035064081618043.  So I typed:
>>
>> >>> 7.23 * 281474976710656
>> 2035064081618043.0
>>
>> That agrees with the falsehood.  I'm getting no evidence of the problem.
>>
>> When take control of my life out of the hands of misleading computers, I
>> calculate the sum:
>>
>>844424930131968
>>  +5629499534213120
>> 197032483697459200
>> ==
>> 203506408161804288
>> =/= 203506408161804300
>>
>> How I can save the energy spent on manual verification?
>
> What you've stumbled upon here is actually a neat elegance of
> floating-point, and an often-forgotten fundamental of it: rounding
> occurs exactly the same regardless of the scale. The number 7.23 is
> represented with a certain mantissa, and multiplying it by some power
> of two doesn't change the mantissa, only the exponent. So the rounding
> happens exactly the same, and it comes out looking equal!

That's insightful.  Thanks!

> The easiest way, in Python, to probe this sort of thing is to use
> either fractions.Fraction or decimal.Decimal. I prefer Fraction, since
> a float is fundamentally a rational number, and you can easily see
> what's happening. You can construct a Fraction from a string, and
> it'll do what you would expect; or you can construct one from a float,
> and it'll show you what that float truly represents.
>
> It's often cleanest to print fractions out rather than just dumping
> them to the console, since the str() of a fraction looks like a
> fraction, but the repr() looks like a constructor call.
>
 Fraction(0.25)
> Fraction(1, 4)
 Fraction(0.1)
> Fraction(3602879701896397, 36028797018963968)
>
> If it looks like the number you put in, it was perfectly
> representable. If it looks like something of roughly that many digits,
> it's probably not the number you started with.

That's pretty, pretty nice.  It was really what I was looking for.

-- 
You're the best ``little lord of local nonsense'' I've ever met! :-D
(Lol.  The guy is kinda stressed out!  Plonk, plonk, plonk.  EOD.)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

I understood that these function calls shoud be replaced with:

* PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
* code.replace() method: 
https://docs.python.org/dev/library/types.html#types.CodeType.replace

--

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

If possible, I suggest to do in in this order:

* Fix Cython
* Publish a Cython release including the fix
* (Maybe wait a bit)
* Remove the two functions

Previously, we tried to first modified Python, and then update Cython: it went 
bad.

Otherwise, the following 136 popular PyPI packages will fail to build on Python 
3.11:
https://mail.python.org/archives/list/python-...@python.org/message/6RO2WFU5Q7UQDVL72IRMT4T6L4GEAKB6/

In Fedora, we start to integrate Python 3.11 since alpha 1. In the past, the 
broken Cython was really annoying: many important packages failed to build, and 
so everything was broken. Hopefully, we can now patch Cython, and we modified 
most recipes building Python packages to always regenerate Cython source, to 
avoid such problem.

--
nosy: +vstinner

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

PS. It would be nice to also update Cython, which is the only thing that uses 
these C APIs.

--

___
Python tracker 

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



[issue45122] Remove PyCode_New and PyCode_NewWithPosOnlyArgs

2021-09-06 Thread Guido van Rossum


New submission from Guido van Rossum :

This is up for grabs.

For reference, the Steering Council approved getting rid of these two C APIs 
without honoring the customary two-release deprecation period required by PEP 
387.

For reference see https://github.com/python/steering-council/issues/75. This 
also has references to python-dev and python-committers discussions.

--
messages: 401188
nosy: gvanrossum
priority: normal
severity: normal
stage: needs patch
status: open
title: Remove PyCode_New and PyCode_NewWithPosOnlyArgs
type: behavior
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



[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



[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



[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



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

2021-09-06 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +26617
pull_request: https://github.com/python/cpython/pull/28190

___
Python tracker 

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



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


Change by Shantanu :


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue45121] Regression in 3.9.7 with typing.Protocol

2021-09-06 Thread Shantanu


New submission from Shantanu :

Consider:
```
from typing import Protocol

class P(Protocol):
...

class C(P):
def __init__(self):
super().__init__()

C()
```
This code passes without error on 3.9.6.

With 3.9.7, we get:
```
Traceback (most recent call last):
  File "/Users/shantanu/dev/test.py", line 10, in 
C()
  File "/Users/shantanu/dev/test.py", line 8, in __init__
super().__init__()
  File "/Users/shantanu/.pyenv/versions/3.9.7/lib/python3.9/typing.py", line 
1083, in _no_init
raise TypeError('Protocols cannot be instantiated')
TypeError: Protocols cannot be instantiated
```

I bisected this to:

bpo-44806: Fix __init__ in subclasses of protocols (GH-27545) (GH-27559)

Note there is also an interaction with the later commit:

bpo-45081: Fix __init__ method generation when inheriting from Protocol 
(GH-28121) (GH-28132)

This later commit actually causes a RecursionError:
```
  File "/Users/shantanu/dev/cpython/Lib/typing.py", line 1103, in 
_no_init_or_replace_init
cls.__init__(self, *args, **kwargs)
  File "/Users/shantanu/dev/test.py", line 8, in __init__
super().__init__()
  File "/Users/shantanu/dev/cpython/Lib/typing.py", line 1103, in 
_no_init_or_replace_init
cls.__init__(self, *args, **kwargs)
  File "/Users/shantanu/dev/test.py", line 8, in __init__
super().__init__()
```

Originally reported by @tyralla on Gitter.

--
components: Library (Lib)
messages: 401184
nosy: hauntsaninja
priority: normal
severity: normal
status: open
title: Regression in 3.9.7 with typing.Protocol
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



[issue45116] Performance regression 3.10b1 and later on Windows

2021-09-06 Thread STINNER Victor


STINNER Victor  added the comment:

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

I'm not sure if PGO builds are reproducible, since there is a training step 
which requires to run a non-deterministic workload (the Python test suite which 
is somehow randomized by I/O timings and other stuffs).

The compiler is free to inline or not depending on the pressure on registers 
and stack memory. I'm not sure that inlining always make the code faster, since 
inlining have many side effects.

I don't know well MSC compiler.

--

___
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



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


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


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


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


[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



[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



[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



[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



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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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


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



[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

[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



[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



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



[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



[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



[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



  1   2   >