Bug: Cannot open .dbf files read only

149 views
Skip to first unread message

Sandro Tosi

unread,
Feb 19, 2017, 11:47:14 PM2/19/17
to Python dBase
Hello,
as reported in Debian as http://bugs.debian.org/855131

$ chmod 0400 /tmp/test.dbf
$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbf
>>> t = dbf.Table("/tmp/test.dbf")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/dbf/ver_33.py", line 4761, in __init__
    raise DbfError(str(e)) from None
dbf.ver_33.DbfError: [Errno 13] Permission denied: '/tmp/test.dbf'


It seems that the code uses "r+b" for opening files "read only", and "w+b" to
open them read-write, forgetting that the "+" stands for "update".

the reporter kindly tested that replacing the opening mode from r+b to rb makes it possible to open read-only files, and provided the attached patch to do so.

this applies to 0.96.8 too

PS: it would be much better to be able to report issues on bitbucket than here
0001-Fixed-readonly-file-opening-modes.patch
Reply all
Reply to author
Forward
0 new messages