python 2.6
>>> import os
>>> buf = 'a'
>>> f = open('test', 'wb')
>>> f.write(buf)
>>> f.close()
>>> os.stat('test').st_size
1
>>> buf = 'ф'
>>> f = open('test2', 'wb')
>>> f.write(buf)
>>> f.close()
>>> os.stat('test2').st_size
2
>>> buf = u'a'
>>> f = open('test', 'wb')
>>> f.write(buf)
>>> f.close()
>>> os.stat('test').st_size
1
>>> buf = u'ф'
>>> f = open('test2', 'wb')
>>> f.write(buf)
Traceback (most recent call last):
File "<input>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0444' in position 0
: ordinal not in range(128)
>>> buf
u'\u0444'