Issue1396

classification
Title: Assigning os module funcs as class attributes incompatible with CPython
Type: behaviour Severity: normal
Components: Core Versions: 2.5.0
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: arianepaola, pjenvey
Priority: Keywords:

Created on 2009-07-04.00:35:59 by arianepaola, last changed 2009-11-22.22:10:03 by pjenvey.

Messages
msg4882 (view) Author: Ariane Paola Gomes (arianepaola) Date: 2009-07-04.00:36:52
Reference failure

ariane@rainbow:/tmp$ touch foo.txt
ariane@rainbow:/tmp$ chmod 644 foo.txt 
ariane@rainbow:/tmp$ jython bug.py 
reference failure chmod() takes exactly 2 arguments (3 given)
ariane@rainbow:/tmp$ rm foo.txt 
ariane@rainbow:/tmp$ touch foo.txt
ariane@rainbow:/tmp$ chmod 644 foo.txt 
ariane@rainbow:/tmp$ ls -la foo.txt 
-rw-r--r-- 1 ariane ariane 0 2009-07-02 23:54 foo.txt
ariane@rainbow:/tmp$ python bug.py 
ariane@rainbow:/tmp$ ls -la foo.txt 
-rwxrwxrwx 1 ariane ariane 0 2009-07-02 23:54 foo.txt

import os

class foo(object):
    _os_chmod = os.chmod

    def __init__(self):
        self._os_chmod("/tmp/foo.txt", 0777)

try:
    test = foo()
except TypeError, e:
    print "reference failure", e
msg4891 (view) Author: Philip Jenvey (pjenvey) Date: 2009-07-08.01:12:08
This is a really annoying 'feature' of Python, builtin functions 
attached to classes like this are not bound, whereas normal functions 
are

os.chmod is a builtin function in CPython but a regular pure python 
function in Jython

The tempfile module has a case of this that just workarounds the 
problem, so I'd suggest SCons do the same. The kind of function these 
are is really an implementation detail IMO. Unfortunately SCons has this 
in a bunch of places.

Otherwise Jython either needs to implement chmod (and friends) in Java 
or come up with some builtin function wrapper hack to avoid this
msg5259 (view) Author: Philip Jenvey (pjenvey) Date: 2009-10-23.01:59:27
os.chmod and friends are from the posix module. We now have part of the 
posix module implemented in Java, so we can solve this by porting chmod 
etc from Python to java (in org.python.modules.posix.PosixModule)
msg5317 (view) Author: Philip Jenvey (pjenvey) Date: 2009-11-22.22:10:03
fixed in r6948
History
Date User Action Args
2009-11-22 22:10:03pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5317
title: reference failure -> Assigning os module funcs as class attributes incompatible with CPython
2009-10-23 01:59:27pjenveysetmessages: + msg5259
2009-07-08 01:12:09pjenveysetnosy: + pjenvey
messages: + msg4891
2009-07-04 00:37:54arianepaolasettype: behaviour
components: + Core
versions: + 2.5.0
2009-07-04 00:36:53arianepaolasetmessages: + msg4882
2009-07-04 00:35:59arianepaolacreate