Opened 8 years ago

Closed 8 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@…> 8 years ago.
Simple patch

Download all attachments as: .zip

Change History (9)

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

Simple patch

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

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

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

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 8 years ago by jacob

  • Component changed from django-admin.py to Admin 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 8 years ago by jacob

  • Triage Stage changed from Ready for checkin to Accepted

comment:5 Changed 8 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 8 years ago by Fredrik Lundh <fredrik@…>

  • Triage Stage changed from Accepted to Ready 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 8 years ago by Fredrik Lundh <fredrik@…>

  • Keywords sprintsept14 added

comment:8 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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