The problem on Windows is still there, but I have found workaround. The workaround is to print to file:
printer.print_entry(entry,file=open('output.txt','a')) On Monday, April 8, 2019 at 9:34:17 AM UTC+2, Chary Chary wrote: > > > > On Monday, April 8, 2019 at 7:22:32 AM UTC+2, Martin Blais wrote: >> >> There's a related discussion here: >> >> https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3 >> >> I could potentially change this code to wrap the output encoder >> differently, or encode explicitly and write bytes. >> Problem is, I don't have access to a Windows box, so I can't really test >> the differences there. >> If someone's up for it, test a few of the options in the thread and let >> me know which works on Windows and I'll make the adjustment. >> > > Martin, > > if you are able to describe what needs to be done so that an armature > self-taught Python user can do it - then I am definitely willing to try > > > >> >> >> On Sun, Apr 7, 2019 at 5:23 PM Chary Chary <char...@gmail.com> wrote: >> >>> Martin, >>> >>> thanks. >>> >>> OK, I tested the same under Unbuntu the error indeed does not come up. >>> >>> >>> >>> On Sunday, April 7, 2019 at 4:32:41 PM UTC+2, Martin Blais wrote: >>>> >>>> I don't know - I don't have access to Windows - but I'm probably not >>>> wrapping up stdout in an utf-8 encoder the right way. >>>> This could be improved. >>>> >>>> >>>> On Sat, Apr 6, 2019 at 6:34 PM Chary Chary <char...@gmail.com> wrote: >>>> >>>>> Hello everybody. >>>>> >>>>> I was experimenting with scripting and when I run example from your >>>>> document Beancount Scripting & Plugins, >>>>> <https://docs.google.com/document/d/1QftxNvQPdH-MikMBHupftU6F4IsNZP5FlFh1LCbVgk8/edit> >>>>> >>>>> I get the following error >>>>> >>>>> Example: >>>>> >>>>> from beancount import loader >>>>> from beancount.parser import printer >>>>> >>>>> >>>>> # example file, generated by beancount >>>>> filename='example.beancount' >>>>> >>>>> entries, errors, options = loader.load_file(filename) >>>>> >>>>> for entry in entries: >>>>> printer.print_entry(entry) >>>>> >>>>> >>>>> >>>>> Error >>>>> >>>>> Traceback (most recent call last): >>>>> File "C:\_code\fava&BC testing\test.py", line 14, in <module> >>>>> printer.print_entry(entry) >>>>> File >>>>> "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\beancount\parser\printer.py", >>>>> >>>>> line 351, in print_entry >>>>> output = file or codecs.getwriter("utf-8")(sys.stdout.buffer) >>>>> AttributeError: 'PseudoOutputFile' object has no attribute 'buffer' >>>>> >>>>> >>>>> Any idea what that might me? >>>>> >>>>> I am using python 3.7 on windows 10 >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Beancount" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to bean...@googlegroups.com. >>>>> To post to this group, send email to bean...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/beancount/c47d8b86-2da8-4900-b94c-9fa27877c379%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/beancount/c47d8b86-2da8-4900-b94c-9fa27877c379%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Beancount" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to bean...@googlegroups.com. >>> To post to this group, send email to bean...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/beancount/7ae93ead-2718-413f-b6a9-558ef79b10af%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/beancount/7ae93ead-2718-413f-b6a9-558ef79b10af%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to beancount+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/62065072-31f6-4aec-b159-b31c5b3b6d36%40googlegroups.com.