New submission from Andre Roberge:

According to the docs, and consistent with the Python 2.x behavior,
filehandle.write() should return None.  However, under 3.0a2 (and
3.0a1), it returns the number of characters written.

Either the documentation
http://docs.python.org/dev/3.0/tutorial/inputoutput.html#reading-and-writing-files
is wrong, or it is a bug.  I would *much* prefer if the behavior would
stay the same as before.

Below is a sample session illustrating the behavior.  Note that I also
get an error message when exiting the session using exit() - this is an
unrelated problem.

Python 3.0a2 (r30a2:59382, Dec 27 2007, 15:48:14) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> handle = open('test_file.txt.', 'w')
>>> handle.write('spam')
4
>>> r = handle.write('more spam')
>>> print(r)
9
>>> exit()
/usr/local/py3k/lib/python3.0/io.py:1210: RuntimeWarning: Trying to
close unclosable fd!
  self.buffer.close()

----------
components: Interpreter Core
messages: 59592
nosy: aroberge
severity: normal
status: open
title: filehandle.write() does not return None (Python 3.0a2)
type: behavior
versions: Python 3.0

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1775>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to