Commit 2b20964
authored
grass.gunittest: Solve ResourceWarning in gs.parser() coming from sys.stdout (OSGeo#6196)
The note at the end of [`sys.stdout`'s docs](https://docs.python.org/3/library/sys.html#sys.stdout) mentions that writing binary data to the standard streams should use the underlying binary buffer object. However, that file might be replaced by a file-like object that doesn't support the buffer attribute.
So, inspired by [the code example for `sys.displayhook`](https://docs.python.org/3.13/library/sys.html#sys.displayhook), use the binary buffer object if available or simply write the encoded text otherwise.
This solves multiple ResourceWarnings found in tests that could be traced back to this when enabling python tracemalloc as written in the warning messages. One of the ways is to set the env var `PYTHONTRACEMALLOC` to the number of frames to keep. So, `export PYTHONTRACEMALLOC=15` is enough.1 parent edc87a4 commit 2b20964
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1095 | 1095 | | |
1096 | 1096 | | |
1097 | 1097 | | |
1098 | | - | |
1099 | | - | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1100 | 1103 | | |
1101 | 1104 | | |
1102 | 1105 | | |
| |||
0 commit comments