We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import datetime import time import sys def now_nice_format(arg_utc: bool = False) -> str: """ Helper function for timestamped_line() """ dt = datetime.datetime.now(datetime.UTC) if arg_utc else datetime.datetime.now() res = time.strftime("%Y-%m-%d %H:%M:%S", datetime.datetime.timetuple(dt)) return res def timestamped_line(arg_str: str = "") -> str: return f"[{now_nice_format()}] {arg_str}" def timestamped_print(arg_str: str = "", arg_file = sys.stdout, arg_force_flush: bool = False): print(timestamped_line(arg_str), file=arg_file, flush=arg_force_flush)
In xonsh, run the following code:
import bug_xonsh bug_xonsh.timestamped_print("test") xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename> Traceback (most recent call last): File "<stdin>", line 1, in <module> File "P:\bug_xonsh.py", line 16, in timestamped_print print(timestamped_line(arg_str), file=arg_file, flush=arg_force_flush) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Users\<username>\Appdata\Local\Programs\Python\Python312\Lib\site-packages\xonsh\base_shell.py", line 182, in write self.mem.write(s) ValueError: I/O operation on closed file.
+------------------+---------------------------+ | xonsh | 0.14.4 | | Python | 3.12.1 | | PLY | 3.11 | | have readline | False | | prompt toolkit | 3.0.43 | | shell type | prompt_toolkit | | history backend | json | | pygments | 2.17.2 | | on posix | False | | on linux | False | | on darwin | False | | on windows | True | | on cygwin | False | | on msys2 | False | | is superuser | False | | default encoding | utf-8 | | xonsh encoding | utf-8 | | encoding errors | surrogateescape | | xontrib 1 | coreutils | | RC file 1 | C:\Users\<redacted>/.xonshrc | +------------------+---------------------------+
⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment
+1
The text was updated successfully, but these errors were encountered:
I can't repeat this in Python 3.11.6. I can repeat this in xonsh 0.14.4. Thanks!
Sorry, something went wrong.
No branches or pull requests
Steps to Reproduce
In xonsh, run the following code:
For community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 commentThe text was updated successfully, but these errors were encountered: