Message8096

Author dcoles
Recipients dcoles
Date 2013-08-29.21:17:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1377811079.82.0.46643822235.issue2081@psf.upfronthosting.co.za>
In-reply-to
Content
Jython can't open files with write-only permission (write-bit is set, but read-bit is not set).

This appears to be due to org.python.core.io.FileIO using java.io.RandomAccessFile which only supports "r" or "rw" modes. The same file can be opened from Jython by using Java's java.io.FileOutputStream.


How to reproduce:

  $ touch /tmp/write-only-file
  $ chmod 200 /tmp/write-only-file
  $ jython2.7 --version
  Jython 2.7b1+
  $ jython2.7 -c 'f = open("/tmp/write-only-file", "w"); print(f)'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  IOError: [Errno 13] Permission denied: '/tmp/write-only-file'


Expected behavior:

  $ python -c 'f = open("/tmp/write-only-file", "w"); print(f)'
  <_io.TextIOWrapper name='/tmp/write-only-file' mode='w' encoding='ANSI_X3.4-1968'>


It seems like os.open also has the same problem:

  $ jython2.7 -c 'import os; fd = os.open("/tmp/write-only-file", os.O_WRONLY); print(fd)'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  IOError: [Errno 13] Permission denied: '/tmp/write-only-file'
History
Date User Action Args
2013-08-29 21:17:59dcolessetrecipients: + dcoles
2013-08-29 21:17:59dcolessetmessageid: <1377811079.82.0.46643822235.issue2081@psf.upfronthosting.co.za>
2013-08-29 21:17:59dcoleslinkissue2081 messages
2013-08-29 21:17:58dcolescreate