[issue46153] function fails in exec when locals is given

2021-12-23 Thread Quentin Peter
Quentin Peter added the comment: Maybe a note could be added to https://docs.python.org/3/library/functions.html#exec Something along the lines of: Note: If exec gets two separate objects as `globals` and `locals`, the code will not be executed as if it were embedded in a function

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Quentin Peter
Quentin Peter added the comment: Thank you for your explaination. Just to be sure, it is expected that: exec("a = 1\ndef f(): return a\nprint(f())", {}) Runs successfully but exec("a = 1\ndef f(): return a\nprint(f())&quo

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Quentin Peter
Quentin Peter added the comment: The reason I am asking is that I am working on a debugger. The debugger stops on a frame which is inside a function. Let's say the locals is: locals() == {"a": 1} I now want to define a closure with exec. I might want to do something li

[issue46153] closure fails in exec when locals is given

2021-12-22 Thread Quentin Peter
Quentin Peter added the comment: This might be related to https://bugs.python.org/issue41918 -- ___ Python tracker <https://bugs.python.org/issue46153> ___ ___

[issue46153] closure fails in exec when locals is given

2021-12-22 Thread Quentin Peter
New submission from Quentin Peter : When both namespace arguments are given to exec, function definitions fail to capture closure. See below: ``` Python 3.8.6 (default, Oct 8 2020, 14:06:32) [Clang 12.0.0 (clang-1200.0.32.2)] on darwin Type "help", "copyright", "

[issue42170] splitdrive fails for UNC path with the "\\?\UNC\" prefix.

2020-10-27 Thread Quentin Peter
Change by Quentin Peter : -- keywords: +patch pull_requests: +21916 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23001 ___ Python tracker <https://bugs.python.org/issu

[issue42170] splitdrive fails for UNC path with the "\\?\UNC\" prefix.

2020-10-27 Thread Quentin Peter
New submission from Quentin Peter : Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. IPython 7.18.1 -- An enhanced Interactive Python. In [1]: import os.path In [2]:

[issue42170] splitdrive fails for UNC path with the "\\?\UNC\" prefix.

2020-10-27 Thread Quentin Peter
Change by Quentin Peter : -- components: Library (Lib) nosy: qpeter priority: normal severity: normal status: open title: splitdrive fails for UNC path with the "\\?\UNC\" prefix. type: behavior versions: Python 3.7 ___ Python track

[issue41918] exec fails to take locals into account when running list comprehensions or functions

2020-10-14 Thread Quentin Peter
Quentin Peter added the comment: Fails for functions as well: ``` In [4]: exec(compile('print(my_var)\ndef a():\n print(my_var)\na()', '', 'exec'), globals(), {"my_var": 0}) 0 Traceback (most recent call last): File "", line 1, in exec(c

[issue41918] exec fails to take locals into account when running list comprehensions

2020-10-03 Thread Quentin Peter
New submission from Quentin Peter : The exec function fails to take locals into account when executing a list comprehension: ``` Python 3.7.7 (default, Mar 10 2020, 15:43:33) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin Type "help", "copyright", "credits" or

[issue31466] No easy way to change float formatting when subclassing encoder.JSONEncoder

2017-09-14 Thread Quentin Peter
Changes by Quentin Peter : -- keywords: +patch pull_requests: +3561 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue31466> ___ ___ Py

[issue31466] No easy way to change float formatting when subclassing encoder.JSONEncoder

2017-09-14 Thread Quentin Peter
New submission from Quentin Peter: I want to output floats in ENG format. Working with distance in micrometers, it is a bit annoying to see: 2.5e-5 .0003 instead of 25e-6 300e-6 The solution I found was to redefine `iterencode` but that doesn't feel right. I would like to see some