[New-bugs-announce] [issue45867] kwarg default value expression incorrectly evaluated

Muhamed Itani report at bugs.python.org
Mon Nov 22 07:32:27 EST 2021


New submission from Muhamed Itani <moefear85 at gmail.com>:

I have an MPYFrame class that inherits from tkinter.Frame. It's init looks like this:

from os.path import normcase,normpath
def __init__(self,master=None,port=None,baudrate=115200,timeout=1,localFolder=normcase(normpath(os.getcwd()))):

The problem is, when I check/access the value of localFolder later in the code (even directly as a first statement within __init__), it is obvious that os.getcwd() is executing, but normcase and/or normpath are not. The resulting path contains capital letters (tested on Windows 11), even though it should not. If I run:
localFolder=normcase(normpath(localFolder))

as a first statement after init, then check the value of localFolder (for example at a debugging breakpoint), it correctly then contains a normalized path in which all letters have been converted to lowercase (but only after the statement itself has executed).

----------
components: Parser
files: mpyFrame.pyw
messages: 406765
nosy: lys.nikolaou, moefear85, pablogsal
priority: normal
severity: normal
status: open
title: kwarg default value expression incorrectly evaluated
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50456/mpyFrame.pyw

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45867>
_______________________________________


More information about the New-bugs-announce mailing list