fiuba08 / robotframework

Automatically exported from code.google.com/p/robotframework
Apache License 2.0
0 stars 0 forks source link

"Create File" (OperatingSystem Library) cannot write binary data which should not be encoded #1707

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi everybody!

There is a problem with "Create File" keyword from OperatingSystem library. It 
seems it can't always handle binary data such as PDF. 

I use this keyword following way:

Create File    blablabla.pdf    ${payload}

The result with debugging on is following:

20140228 17:05:02.298 - INFO - +----- START KW: OperatingSystem.Create File [ 
blablabla.pdf | ${payload} ]
20140228 17:05:02.317 - FAIL - UnicodeDecodeError: 'ascii' codec can't decode 
byte 0x83 in position 11: ordinal not in range(128)
20140228 17:05:02.318 - DEBUG - Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\robot\libraries\OperatingSystem.py", line 611, in create_file
    path = self._write_to_file(path, content, encoding, 'w')
  File "C:\Python27\lib\site-packages\robot\libraries\OperatingSystem.py", line 630, in _write_to_file
    f.write(content.encode(encoding))
20140228 17:05:02.318 - INFO - +----- END KW: OperatingSystem.Create File (20)

My PDF content comes from the ImapLibrary and the guys that support ImapLibrary 
already debugged this issue and they suspect that there is a problem with the 
"Create File" keyword, see here:

https://github.com/lovelysystems/robotframework-imaplibrary/issues/17

Regards,
mr

Robot Framework version: 2.8.4
used interpreter: Python, version 2.7.5
operating system: Windows 7
output of `pybot --version` command: Robot Framework 2.8.4 (Python 2.7.5 on 
win32)

Original issue reported on code.google.com by m...@protel.net on 12 May 2014 at 11:00

GoogleCodeExporter commented 9 years ago
We've already implemented Create Binary File and it will be part of 2.8.5 
release.

Original comment by pekka.klarck on 12 May 2014 at 9:54