[issue40728] UnboundLocalError as a result of except statement variable re-assignment

2020-05-22 Thread Oleksandr Suvorov
Oleksandr Suvorov added the comment: Mark, I'm not sure if this is even documented, I find this a bit inconsistent when compared to the behavior of other statements, E.g.: * list expressions do have their scope and do not overwrite local variables * with statement does overwrite

[issue40728] UnboundLocalError as a result of except statement variable re-assignment

2020-05-22 Thread Oleksandr Suvorov
Oleksandr Suvorov added the comment: What I mean is why would it need to shadow function variable name if after except block it's always unbound, what is the reason and why this is expected? On Fri, May 22, 2020 at 1:19 PM Oleksandr Suvorov wrote: > > Oleksandr Suvorov added the c

[issue40728] UnboundLocalError as a result of except statement variable re-assignment

2020-05-22 Thread Oleksandr Suvorov
Oleksandr Suvorov added the comment: but if exc variable is only available in except block why then it shadows the function variable name? On Fri, May 22, 2020 at 1:15 PM Christian Heimes wrote: > > Christian Heimes added the comment: > > UnboundLocalError is a subclass of Na

[issue40728] UnboundLocalError as a result of except statement variable re-assignment

2020-05-22 Thread Oleksandr Suvorov
Oleksandr Suvorov added the comment: But then why I still can access this variable? Shouldn't it then be resulting in NameError as it's undefined variable at this point of time? I think UnboundError creates more confusing here, as it's either the variable should exist and have a value

[issue40728] UnboundLocalError as a result of except statement variable re-assignment

2020-05-22 Thread Oleksandr Suvorov
New submission from Oleksandr Suvorov : def foo(exc): try: 1/0 except Exception as exc: ... finally: return exc foo(1) Executing the following code results in UnboundLocalError, while exc has been defined and passed to a function explicitly. I think

[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Oleksandr Suvorov
Oleksandr Suvorov added the comment: This change requested just because I find it inconsistent and passing translation as key-value is much easier to read rather than two lists. When translation table gets bigger than 10 pairs it gets annoying to match in the head between from and to while

[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Oleksandr Suvorov
Oleksandr Suvorov added the comment: str.maketrans in python3 is able to accept just one argument which is a mapping of translations. While bytearray and bytes are still using only old way where you should pass two iterables from and to. static str.maketrans(x [,y [,z]]) static bytes.maketrans

[issue31594] Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str

2017-09-26 Thread Oleksandr Suvorov
Changes by Oleksandr Suvorov <susl...@gmail.com>: -- components: Interpreter Core nosy: soosleek priority: normal severity: normal status: open title: Make bytes and bytearray maketrans accept dictionaries as first argument as it's done in str type: behavior versions: Pyth