Merge pull request #3294 from davep/fix-print-console-location

Ensure that `print` reports the correct location in console
This commit is contained in:
Dave Pearson 2023-10-05 16:00:36 +01:00 committed by GitHub
commit 3aaecd3920
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1278 additions and 1370 deletions

View file

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `Pilot.click`/`Pilot.hover` can't use `Screen` as a selector https://github.com/Textualize/textual/issues/3395
- App exception when a `Tree` is initialized/mounted with `disabled=True` https://github.com/Textualize/textual/issues/3407
- Fixed `print` locations not being correctly reported in `textual console` https://github.com/Textualize/textual/issues/3237
- Fix location of IME and emoji popups https://github.com/Textualize/textual/pull/3408
- Fixed application freeze when pasting an emoji into an application on Windows https://github.com/Textualize/textual/issues/3178
- Fixed duplicate option ID handling in the `OptionList` https://github.com/Textualize/textual/issues/3455

2488
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -66,7 +66,7 @@ time-machine = "^2.6.0"
mkdocs-rss-plugin = "^1.5.0"
httpx = "^0.23.1"
types-setuptools = "^67.2.0.1"
textual-dev = "^1.1.0"
textual-dev = "^1.2.0"
pytest-asyncio = "*"
pytest-textual-snapshot = ">=0.4.0"
types-tree-sitter = "^0.20.1.4"

View file

@ -1163,7 +1163,10 @@ class App(Generic[ReturnType], DOMNode):
stderr: True if the print was to stderr, or False for stdout.
"""
if self._devtools_redirector is not None:
self._devtools_redirector.write(text)
current_frame = inspect.currentframe()
self._devtools_redirector.write(
text, current_frame.f_back if current_frame is not None else None
)
for target, (_stdout, _stderr) in self._capture_print.items():
if (_stderr and stderr) or (_stdout and not stderr):
target.post_message(events.Print(text, stderr=stderr))

File diff suppressed because one or more lines are too long