andrewferrier / email2pdf

Script to convert emails to PDF from the command-line, as well as detach recognized attachments. Helps to process incoming emails and assist automatically with a non-paper paperwork workflow. Designed to work in tandem with getmail to convert forwarded emails to PDF automatically.
MIT License
68 stars 35 forks source link

test_plaincontent_poundsign_utf8_8bit failing in Linux because of unexpected System preferred encoding #77

Closed andrewferrier closed 9 years ago

andrewferrier commented 9 years ago

Based on experiences with issue #76

andrewferrier commented 9 years ago

Discovered this is no longer just a procmail issue, can be recreated using test_plaincontent_poundsign_utf8_8bit inside Docker image.

andrewferrier commented 9 years ago

Some potential explanation here: http://stackoverflow.com/a/21968640/27641.

andrewferrier commented 9 years ago

Current output inside Linux Docker:

Checking if online... Yes.
Output examination directory: /tmp/tmp_qnzrqp6

INFO: Options used are: Namespace(add_prefix_date=False, attachments=True, body=True, enforce_syslog=False, headers=False, help=False, ignore_floating_attachments=False, inputFile='/tmp/tmpe7bnbj15', outputDirectory='/tmp/tmp1hl67e1x', outputFile='/tmp/tmp_qnzrqp6/plaincontent_poundsign_utf8_8bit.pdf', verbose=2)
INFO: Output file name is: /tmp/tmp_qnzrqp6/plaincontent_poundsign_utf8_8bit.pdf
DEBUG: System preferred encoding is: ANSI_X3.4-1968
Traceback (most recent call last):
  File "/tmp/email2pdf/email2pdf", line 575, in call_main
    main(argv, syslog_handler, syserr_handler)
  File "/tmp/email2pdf/email2pdf", line 86, in main
    input_data = get_input_data(args)
  File "/tmp/email2pdf/email2pdf", line 205, in get_input_data
    data = input_handle.read()
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 214: ordinal not in range(128)

F
======================================================================
FAIL: test_plaincontent_poundsign_utf8_8bit (tests.Subprocess.test_Subprocess_MIME.TestMIME)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/email2pdf/tests/Subprocess/test_Subprocess_MIME.py", line 33, in test_plaincontent_poundsign_utf8_8bit
    self.assertEqual(0, rc)
AssertionError: 0 != 3
andrewferrier commented 9 years ago

This is the same issue as #76 after all; needs to be resolved by providing an --input-encoding switch (along with some docs). Closing this a duplicate.