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 jgoerzen
Recipients jgoerzen
Date 2019-11-20.15:07:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This simple recipe fails:

>>> import dbm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/dbm/", line 78, in open
    result = whichdb(file) if 'n' not in flag else None
  File "/usr/lib/python3.7/dbm/", line 112, in whichdb
    f = + ".pag", "rb")
TypeError: can't concat str to bytes

Why does this matter?  On POSIX, a filename is any string of bytes that does not contain 0x00 or '/'.  A database with a filename containing, for instance, German characters in ISO-8859-1, can't be opened by dbm, EVEN WITH decoding.

For instance:

file = b"test\xf7"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf7 in position 4: invalid start byte
db ='iso-8859-1'), 'c')


ls *.db | hd
00000000  74 65 73 74 c3 b7 2e 64  62 0a                    |test...db.|

Note that it didn't insert the 0xf7 here; rather, it inserted the Unicode sequence corresponding to the division character (which is what 0xf7 in iso-8859-1 is).  It is not possible to open a filename named "test\xf7.db" with the dbm module.
Date User Action Args
2019-11-20 15:07:49jgoerzensetrecipients: + jgoerzen
2019-11-20 15:07:49jgoerzensetmessageid: <>
2019-11-20 15:07:49jgoerzenlinkissue38864 messages
2019-11-20 15:07:48jgoerzencreate