Message 72757 - Python tracker

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.

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