This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skip.montanaro
Recipients gvanrossum, skip.montanaro
Date 2008-09-08.00:26:13
SpamBayes Score 4.462391e-09
Marked as misclassified No
Message-id <1220833576.66.0.821569313311.issue3799@psf.upfronthosting.co.za>
In-reply-to
Content
I'm not sure.  I've never done anything with the io module.  Simply
eliminating the bytes checks and letting it try to write the string
yields:

  File "/Users/skip/local/lib/python3.0/dbm/dumb.py", line 170, in 
__setitem__
    self._addkey(key, self._addval(val))
  File "/Users/skip/local/lib/python3.0/dbm/dumb.py", line 138, in 
_addval
    f.write(val)
  File "/Users/skip/local/lib/python3.0/io.py", line 1224, in write
    return BufferedWriter.write(self, b)
  File "/Users/skip/local/lib/python3.0/io.py", line 1034, in write
    raise TypeError("can't write str to binary stream")

I suppose you'd have to check if val is an instance of str and if so,
encode it as utf-8.  I notice in the existing code that it's doing
some key decoding assuming latin-1.  That would be an incompatibility,
but I think assuming latin-1 is wrong.

That said, I've attached a patch which passes all current unit tests.

Skip
History
Date User Action Args
2008-09-08 00:26:16skip.montanarosetrecipients: + skip.montanaro, gvanrossum
2008-09-08 00:26:16skip.montanarosetmessageid: <1220833576.66.0.821569313311.issue3799@psf.upfronthosting.co.za>
2008-09-08 00:26:15skip.montanarolinkissue3799 messages
2008-09-08 00:26:14skip.montanarocreate