-
Notifications
You must be signed in to change notification settings - Fork 76
Commit 9668980
Fix memory leak issue (#258)
* Test for memory leaks as described in #198
* Possible fix for #198: memory leak
* Optimization: avoid holding frame reference when locals == globals
* Get caller frame at decoration-time
Here we are more careful about which caller's locals we use to
resolve forward type references. We want the callers locals
at decoration-time — not at decorator-construction time.
Consider:
```py
frozen_dataclass = marshmallow_dataclass.dataclass(frozen=True)
def f():
@custom_dataclass
class A:
b: "B"
@custom_dataclass
class B:
x: int
```
The locals we want in this case are the one from where the
custom_dataclass decorator is called, not from where
marshmallow_dataclass.dataclass is called.
* Add ability to pass explicit localns (and globalns) to class_schema
When class_schema is called, it doesn't need the caller's whole stack
frame. What it really wants is a `localns` to pass to
`typing.get_type_hints` to be used to resolve type references.
Here we add the ability to pass an explicit `localns` parameter to
`class_schema`. We also add the ability to pass an explicit
`globalns`, because ... might as well — it might come in useful.
(Since we need these only to pass to `get_type_hints`, we might
as well match `get_type_hints` API as closely as possible.)
* test: check for frame leakage when decorators throw exceptions
* Fix mypy by setting python to the minimum supported version, 3.8
---------
Co-authored-by: Jeff Dairiki <dairiki@dairiki.org>1 parent d6396c1 commit 9668980Copy full SHA for 9668980
File tree
Expand file treeCollapse file tree
4 files changed
+346
-69
lines changedFilter options
- marshmallow_dataclass
- tests
Expand file treeCollapse file tree
4 files changed
+346
-69
lines changed
0 commit comments