-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
cli fails to write to stdout #435
Comments
@kemlath Thanks for reporting this! Since you know how to fix this, would you like to create a pull request? Does this only happen with a specific ICS file or with all of them? Can you attach file.ics? |
I'll fork the repo and create a pull request. Really the cli should fail all the time under python3 independent on what you write to sys.stdout as long as you encode it to bytes. |
I just found out that the version of icalendar I got from pypi is version '4.1.0' whereas the current master branch is version 5.0x and has a rather different cli.py which no longer has the above described problem. Sorry about the confusion |
This calls for creating a new release #429. |
The new version is released. v5.0.0 |
icalendar.version = '4.1.0'
python3.8 on ubuntu 20.04
Running "icalendar view file.ics" throws a TypeError: write() argument must be str, not bytes in
the problem is in main() in cli.py
subparser.add_argument( '-o', dest='output_handle', metavar='OUTPUT', type=argparse.FileType('w'), default=sys.stdout, help='output file (default=<stdout>)')
this, per default passes
sys.stdout
asoutput_handle
indef view(input_handle, output_handle):
which fails whenbytes
are written to it instead of astr
duringoutput_handle.write(_template.format(....).encode('utf-8')
As long as
argparse.FileType
does not properly recognize binary mode strings (e.g. 'wb') a possible fix would be to default tosys.stdout.buffer
instead ofsys.stdout
The text was updated successfully, but these errors were encountered: