Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r416:44b7cd5560d8
Date: 2013-05-24 13:58 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/44b7cd5560d8/

Log:    fixed the bugs in FileOpen:
        - removed truncate flag
        - the flag-combination create & rdwr automatically mean that the file
        is zeroed out, therefore use this combination only when the file is
        actually missing

diff --git a/spyvm/plugins/fileplugin.py b/spyvm/plugins/fileplugin.py
--- a/spyvm/plugins/fileplugin.py
+++ b/spyvm/plugins/fileplugin.py
@@ -38,11 +38,15 @@
 @FilePlugin.expose_primitive(unwrap_spec=[object, str, object])
 def primitiveFileOpen(interp, s_frame, w_rcvr, file_path, w_writeable_flag):
     space = interp.space
+    file_missing = not os.path.exists(file_path)
     if w_writeable_flag is space.w_true:
-        mode = os.O_RDWR | os.O_CREAT | os.O_TRUNC
+        if file_missing:
+            mode = os.O_RDWR | os.O_CREAT
+        else:
+            mode = os.O_RDWR
     else:
         mode = os.O_RDONLY
-        if not os.path.exists(file_path):
+        if file_missing:
             return space.w_nil
     try:
         file_descriptor = os.open(file_path, mode, 0666)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to