Skip to content
New issue

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

AttributeError: 'Capture' object has no attribute 'flush' in Python 3.13 #58

Closed
jstvz opened this issue Nov 27, 2024 · 0 comments
Closed

Comments

@jstvz
Copy link

jstvz commented Nov 27, 2024

Describe the bug:
When using the sarge.Capture class with io.TextIOWrapper in Python 3.13, an AttributeError is raised because the Capture object does not have a flush method.

To Reproduce:

  1. Install Python 3.13.0.
  2. Run the following code:
Python 3.13.0 (main, Oct  7 2024, 05:02:14) [Clang 16.0.0 (clang-1600.0.26.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sarge, io, sys
>>> p = sarge.Command('echo reproduce_me', stdout=sarge.Capture(buffer_size=-1), stderr=sarge.Capture(buffer_size=-1), shell=True)
>>> p.run()
Command('echo reproduce_me')
>>> p.stdout_text = io.TextIOWrapper(p.stdout, encoding=sys.stdout.encoding)
>>> p = sarge.Command('echo reproduce_me', stdout=sarge.Capture(buffer_size=-1), stderr=sarge.Capture(buffer_size=-1), shell=True)
>>> p.run()
Exception ignored in: <_io.TextIOWrapper encoding='utf-8'>
Traceback (most recent call last):
  File "<python-input-5>", line 1, in <module>
AttributeError: 'Capture' object has no attribute 'flush'
Command('echo reproduce_me')

Expected behavior

Python 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sarge, io, sys
>>> p = sarge.Command('echo reproduce_me', stdout=sarge.Capture(buffer_size=-1), stderr=sarge.Capture(buffer_size=-1), shell=True)
>>> p.run()
Command('echo reproduce_me')
>>> p.stdout_text = io.TextIOWrapper(p.stdout, encoding=sys.stdout.encoding)
>>> p = sarge.Command('echo reproduce_me', stdout=sarge.Capture(buffer_size=-1)
... , stderr=sarge.Capture(buffer_size=-1), shell=True)
>>> p.run()
Command('echo reproduce_me')

Environment:

  • Python Version: 3.13.0
  • Sarge Version: v0.1.7.post1
  • Operating System: macOS 15.1.1

Additional context:
In Python 3.13, errors raised during the close() method of IOBase objects are now logged using sys.unraisablehook (see gh-62948). My best guess is that the issue does not occur in Python 3.12 or earlier because such errors were silently ignored unless explicitly enabled for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant