Opened 9 years ago

Closed 9 years ago

#5443 closed (fixed)

Jython has no os.access (nor os.chmod)

Reported by: leo.soto@… Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: jython sprintsept14
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The Java platform has no uniform concept of permissions, so Jython don't offer functions such as os.access() or os.chmod(). So Django should avoid checking permissions when running on Jython.

Attachments (1)

jython_no_os_access.patch (838 bytes) - added by leosoto <leo.soto@…> 9 years ago.
Simple patch

Download all attachments as: .zip

Change History (9)

Changed 9 years ago by leosoto <leo.soto@…>

Attachment: jython_no_os_access.patch added

Simple patch

comment:1 Changed 9 years ago by leosoto <leo.soto@…>

Has patch: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 9 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:3 Changed 9 years ago by Jacob

Component: django-admin.pyAdmin interface

Does os.access not work on Jython, or is it just missing entirely? If it's missing, I'd much rather catch an AttributeError ("better to ask forgiveness than permission"). Please verify one way or the other and I'll check this in.

comment:4 Changed 9 years ago by Jacob

Triage Stage: Ready for checkinAccepted

comment:5 Changed 9 years ago by leosoto <leo.soto@…>

Jacob: it's missing entirely. But I don't quite like to wrap the entire catching AttributeError, as it could hide real errors.

comment:6 Changed 9 years ago by Fredrik Lundh <fredrik@…>

Triage Stage: AcceptedReady for checkin

Straight-forward patch. Possible alternative:

def _make_writeable(filename):
    "Makes sure that the file is writeable. Useful if our source is read-only."
    import stat
    if sys.platform.startswith('java'):
        return # On Jython there is no os.access() 
    if not os.access(filename, os.W_OK):
	st = os.stat(filename)
	new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
	os.chmod(filename, new_permissions)

comment:7 Changed 9 years ago by Fredrik Lundh <fredrik@…>

Keywords: sprintsept14 added

comment:8 Changed 9 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [6281]) Fixed #5443 -- Handle lack of os.access() and os.chmod() in Jython. Thanks, Leo Soto.

Note: See TracTickets for help on using tickets.
Back to Top