[pypy-commit] pypy default: cleanups

bdkearns noreply at buildbot.pypy.org
Wed Mar 5 03:13:22 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r69696:19c21c84e468
Date: 2014-03-04 20:57 -0500
http://bitbucket.org/pypy/pypy/changeset/19c21c84e468/

Log:	cleanups

diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -1,4 +1,3 @@
-
 """ Interpreter-level implementation of structure, exposing ll-structure
 to app-level with apropriate interface
 """
@@ -20,6 +19,7 @@
 from rpython.rlib.rarithmetic import intmask, signedtype, widen
 from rpython.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong
 
+
 def unpack_fields(space, w_fields):
     fields_w = space.unpackiterable(w_fields)
     fields = []
diff --git a/pypy/module/gc/__init__.py b/pypy/module/gc/__init__.py
--- a/pypy/module/gc/__init__.py
+++ b/pypy/module/gc/__init__.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.mixedmodule import MixedModule
-    
+
+
 class Module(MixedModule):
     interpleveldefs = {
         'collect': 'interp_gc.collect',
@@ -8,15 +9,14 @@
         'isenabled': 'interp_gc.isenabled',
         'enable_finalizers': 'interp_gc.enable_finalizers',
         'disable_finalizers': 'interp_gc.disable_finalizers',
-        'garbage' : 'space.newlist([])',
+        'garbage': 'space.newlist([])',
         #'dump_heap_stats': 'interp_gc.dump_heap_stats',
     }
-    appleveldefs = {
-    }
+    appleveldefs = {}
 
     def __init__(self, space, w_name):
         if (not space.config.translating or
-            space.config.translation.gctransformer == "framework"):
+                space.config.translation.gctransformer == "framework"):
             self.appleveldefs.update({
                 'dump_rpy_heap': 'app_referents.dump_rpy_heap',
                 })
diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -1,4 +1,3 @@
-
 """ This file makes open() and friends RPython. Note that RFile should not
 be used directly and instead it's magically appearing each time you call
 python builtin open()
@@ -17,27 +16,27 @@
 def llexternal(*args, **kwargs):
     return rffi.llexternal(*args, compilation_info=eci, **kwargs)
 
-FILE = lltype.Struct('FILE') # opaque type maybe
-
 class CConfig(object):
     _compilation_info_ = eci
 
     off_t = platform.SimpleType('off_t')
 
+config = platform.configure(CConfig)
 
-CC = platform.configure(CConfig)
-OFF_T = CC['off_t']
+OFF_T = config['off_t']
+FILE = lltype.Struct('FILE')  # opaque type maybe
+
 c_open = llexternal('fopen', [rffi.CCHARP, rffi.CCHARP], lltype.Ptr(FILE))
 c_close = llexternal('fclose', [lltype.Ptr(FILE)], rffi.INT)
 c_fwrite = llexternal('fwrite', [rffi.CCHARP, rffi.SIZE_T, rffi.SIZE_T,
-                                     lltype.Ptr(FILE)], rffi.SIZE_T)
+                                 lltype.Ptr(FILE)], rffi.SIZE_T)
 c_fread = llexternal('fread', [rffi.CCHARP, rffi.SIZE_T, rffi.SIZE_T,
-                                   lltype.Ptr(FILE)], rffi.SIZE_T)
+                               lltype.Ptr(FILE)], rffi.SIZE_T)
 c_feof = llexternal('feof', [lltype.Ptr(FILE)], rffi.INT)
 c_ferror = llexternal('ferror', [lltype.Ptr(FILE)], rffi.INT)
 c_clearerror = llexternal('clearerr', [lltype.Ptr(FILE)], lltype.Void)
 c_fseek = llexternal('fseek', [lltype.Ptr(FILE), rffi.LONG, rffi.INT],
-                          rffi.INT)
+                     rffi.INT)
 c_tmpfile = llexternal('tmpfile', [], lltype.Ptr(FILE))
 c_fileno = llexternal('fileno', [lltype.Ptr(FILE)], rffi.INT)
 c_ftell = llexternal('ftell', [lltype.Ptr(FILE)], rffi.LONG)
@@ -53,6 +52,13 @@
 BASE_BUF_SIZE = 4096
 BASE_LINE_SIZE = 100
 
+
+def _error(ll_file):
+    errno = c_ferror(ll_file)
+    c_clearerror(ll_file)
+    raise OSError(errno, os.strerror(errno))
+
+
 def create_file(filename, mode="r", buffering=-1):
     assert buffering == -1
     assert filename is not None
@@ -71,6 +77,7 @@
         lltype.free(ll_name, flavor='raw')
     return RFile(ll_f)
 
+
 def create_temp_rfile():
     res = c_tmpfile()
     if not res:
@@ -78,6 +85,7 @@
         raise OSError(errno, os.strerror(errno))
     return RFile(res)
 
+
 def create_popen_file(command, type):
     ll_command = rffi.str2charp(command)
     try:
@@ -93,6 +101,7 @@
         lltype.free(ll_command, flavor='raw')
     return RPopenFile(ll_f)
 
+
 class RFile(object):
     def __init__(self, ll_file):
         self.ll_file = ll_file
@@ -224,7 +233,7 @@
         while raw_buf[strlen] != '\0':
             strlen += 1
         if (strlen == BASE_LINE_SIZE - 1 and
-              raw_buf[BASE_LINE_SIZE - 2] != '\n'):
+                raw_buf[BASE_LINE_SIZE - 2] != '\n'):
             return -1    # overflow!
         # common case
         return strlen
@@ -255,9 +264,3 @@
 
 class RPopenFile(RFile):
     _do_close = staticmethod(c_pclose)
-
-
-def _error(ll_file):
-    errno = c_ferror(ll_file)
-    c_clearerror(ll_file)
-    raise OSError(errno, os.strerror(errno))
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -7,6 +7,7 @@
 from rpython.rlib import jit
 from rpython.translator.platform import platform
 
+
 class CConstantErrno(CConstant):
     # these accessors are used when calling get_errno() or set_errno()
     # on top of CPython
@@ -20,6 +21,7 @@
     def __setitem__(self, index, value):
         assert index == 0
         ll2ctypes.TLS.errno = value
+
 if os.name == 'nt':
     if platform.name == 'msvc':
         includes=['errno.h','stdio.h']
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -1,4 +1,3 @@
-
 from rpython.annotator import model as annmodel
 from rpython.flowspace.model import Constant
 from rpython.rlib import rarithmetic, objectmodel
diff --git a/rpython/rtyper/tool/rffi_platform.py b/rpython/rtyper/tool/rffi_platform.py
--- a/rpython/rtyper/tool/rffi_platform.py
+++ b/rpython/rtyper/tool/rffi_platform.py
@@ -198,12 +198,14 @@
     """
     for attr in ['_includes_', '_libraries_', '_sources_', '_library_dirs_',
                  '_include_dirs_', '_header_']:
-        assert not hasattr(CConfig, attr), "Found legacy attribute %s on CConfig" % (attr,)
+        assert not hasattr(CConfig, attr), \
+            "Found legacy attribute %s on CConfig" % attr
+
     entries = []
     for key in dir(CConfig):
         value = getattr(CConfig, key)
         if isinstance(value, CConfigEntry):
-            entries.append((key, value))            
+            entries.append((key, value))
 
     if entries:   # can be empty if there are only CConfigSingleEntries
         writer = _CWriter(CConfig)


More information about the pypy-commit mailing list