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

Unbuffered stdout incompatible with Python 3 #3

Open
molinav opened this issue May 2, 2020 · 2 comments
Open

Unbuffered stdout incompatible with Python 3 #3

molinav opened this issue May 2, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@molinav
Copy link
Owner

molinav commented May 2, 2020

This is the traceback if I force to run gsync with Python 3:

vic@onyx:~/github/python-gsync$ python3 bin/gsync
Traceback (most recent call last):
  File "bin/gsync", line 19, in <module>
    from libgsync.output import verbose, debug, critical
  File "/home/vic/github/python-gsync/libgsync/output.py", line 20, in <module>
    sys.stdout = WRITER(os.fdopen(sys.stdout.fileno(), "w", 0), "replace")
  File "/usr/lib/python3.8/os.py", line 1023, in fdopen
    return io.open(fd, *args, **kwargs)
ValueError: can't have unbuffered text I/O
@molinav molinav added this to the Port to Python3 milestone May 2, 2020
@molinav molinav added the bug Something isn't working label May 2, 2020
@molinav
Copy link
Owner Author

molinav commented May 2, 2020

Maybe an implementation like this one from StackOverflow might help.

@molinav
Copy link
Owner Author

molinav commented May 2, 2020

For the moment, it seems that forcing the opening mode of sys.stdout to "wb" instead of "w" does the trick for Python 3 without breaking for Python 2. Now I get another error but due to GsyncOptions:

vic@onyx:~/github/python-gsync$ python3 bin/gsync --help
Traceback (most recent call last):
  File "bin/gsync", line 97, in <module>
    sys.exit(main())
  File "bin/gsync", line 39, in main
    if GsyncOptions.verbose:
AttributeError: type object 'GsyncOptions' has no attribute 'verbose'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant