Changes between Initial Version and Version 1 of Ticket #35187, comment 4


Ignore:
Timestamp:
Feb 13, 2024, 2:06:20 PM (9 months ago)
Author:
William Schwartz

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35187, comment 4

    initial v1  
    22    To persist the sensitive variables list for async functions, we can use a global dict with the hash of the filename and line number of the function as the key (more formally: `hash(f"{file_path}:{line_number}")` and the value is the tuple or sensitive variables (or `__ALL__`). Then, during traceback cleanup we can read this dict by reconstructing the same key with `f_code.co_filename` and `f_code.co_firstlineno` to lookup the relevant value in the dict.
    33
    4 I don't have the bandwidth these days to offer an alternative solution. All I can say is that the implementation assumes the existence of a file path that Python does not guarantee exists. To be clear on this: **Python does not guarantee that there is a source file or cache file associated with any object.** Modules without source files exist in *all* CPython instances because of the `sys` module, and in most CPython instances because of the frozen `importlib` submodules. They occur frequently in embedded instance of Python, e.g., when running code directly from pyc cache files (which I have always [back to 2010] understood was a fully supported solution) or using a compiler such as PyOxidizer, which I use. So a correct solution to whatever https://github.com/django/django/pull/16831 was trying to fix for async functions cannot rely on source files. I think what went wrong was essentially what comment:10:ticket:30950 warned of:
     4I don't have the bandwidth these days to offer an alternative solution. All I can say is that the implementation assumes the existence of a file path that Python does not guarantee exists. To be clear on this: **Python does not guarantee that there is a source file or cache file associated with any object.** (See discussion at #30950 and other linked tickets.) Modules without source files exist in *all* CPython instances because of the `sys` module, and in most CPython instances because of the frozen `importlib` submodules. They occur frequently in embedded instance of Python, e.g., when running code directly from pyc cache files (which I have always [back to 2010] understood was a fully supported solution) or using a compiler such as PyOxidizer, which I use. So a correct solution to whatever https://github.com/django/django/pull/16831 was trying to fix for async functions cannot rely on source files. I think what went wrong was essentially what comment:10:ticket:30950 warned of:
    55     I could be wrong but I believe that whatever we do to tackle this ticket, it's important ensure that __file__ isn't added back by new contributions in the future. Ideally this shouldn't be a burden on reviewers, there should be a linting rule, or a test or something that ensures that any contributions following the resolution of this ticket isn't adding this back.
    66
Back to Top