Commits

Philip Jenvey committed 2a5c9b3

cleanup

Comments (0)

Files changed (5)

rpython/memory/gc/inspector.py

 """
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rlib.objectmodel import free_non_gc_object
-from rpython.rtyper.module.ll_os import underscore_on_windows
+from rpython.rtyper.module.ll_os import UNDERSCORE_ON_WIN32
 from rpython.rlib import rposix, rgc
 
 from rpython.memory.support import AddressDict, get_address_stack
 
 # ----------
 
-raw_os_write = rffi.llexternal(underscore_on_windows+'write',
+raw_os_write = rffi.llexternal(UNDERSCORE_ON_WIN32 + 'write',
                                [rffi.INT, llmemory.Address, rffi.SIZE_T],
                                rffi.SIZE_T,
                                sandboxsafe=True, _nowrapper=True)

rpython/rtyper/lltypesystem/module/ll_math.py

 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.platform import platform
 from rpython.rlib.rfloat import isfinite, isinf, isnan, INFINITY, NAN
+from rpython.rtyper.module.support import UNDERSCORE_ON_WIN32
 
 use_library_isinf_isnan = False
 if sys.platform == "win32":
                            compilation_info=math_eci,
                            sandboxsafe=True)
 
-if sys.platform == 'win32':
-    underscore = '_'
-else:
-    underscore = ''
-
 math_fabs = llexternal('fabs', [rffi.DOUBLE], rffi.DOUBLE)
 math_log = llexternal('log', [rffi.DOUBLE], rffi.DOUBLE)
 math_log10 = llexternal('log10', [rffi.DOUBLE], rffi.DOUBLE)
 math_log1p = math_llexternal('log1p', [rffi.DOUBLE], rffi.DOUBLE)
-math_copysign = llexternal(underscore + 'copysign',
+math_copysign = llexternal(UNDERSCORE_ON_WIN32 + 'copysign',
                            [rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE,
                            elidable_function=True)
 math_atan2 = llexternal('atan2', [rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE)
 math_ldexp = llexternal('ldexp', [rffi.DOUBLE, rffi.INT], rffi.DOUBLE)
 math_pow   = llexternal('pow', [rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE)
 math_fmod  = llexternal('fmod',  [rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE)
-math_hypot = llexternal(underscore + 'hypot',
+math_hypot = llexternal(UNDERSCORE_ON_WIN32 + 'hypot',
                         [rffi.DOUBLE, rffi.DOUBLE], rffi.DOUBLE)
 math_floor = llexternal('floor', [rffi.DOUBLE], rffi.DOUBLE, elidable_function=True)
 math_sqrt = llexternal('sqrt', [rffi.DOUBLE], rffi.DOUBLE)

rpython/rtyper/lltypesystem/test/test_ll2ctypes.py

 from rpython.tool.udir import udir
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.annotator.annrpython import RPythonAnnotator
+from rpython.rtyper.module.support import UNDERSCORE_ON_WIN32
 from rpython.rtyper.rtyper import RPythonTyper
 from rpython.rlib.rarithmetic import r_uint, get_long_pattern, is_emulated_long
 from rpython.rlib.rarithmetic import is_valid_int
     def test_get_errno(self):
         eci = ExternalCompilationInfo(includes=['string.h'])
         if sys.platform.startswith('win'):
-            underscore_on_windows = '_'
             # Note that cpython before 2.7 installs an _invalid_parameter_handler,
             # which is why the test passes there, but this is no longer
             # accepted practice.
             old_err_mode = ctypes.windll.kernel32.GetErrorMode()
             new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX
             ctypes.windll.kernel32.SetErrorMode(new_err_mode)
-        else:
-            underscore_on_windows = ''
         strlen = rffi.llexternal('strlen', [rffi.CCHARP], rffi.SIZE_T,
                                  compilation_info=eci)
-        os_write = rffi.llexternal(underscore_on_windows+'write',
+        os_write = rffi.llexternal(UNDERSCORE_ON_WIN32 + 'write',
                                    [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
                                    rffi.SIZE_T)
         buffer = lltype.malloc(rffi.CCHARP.TO, 5, flavor='raw')

rpython/rtyper/module/ll_os.py

 import os, sys, errno
 import py
 from rpython.rtyper.module.support import (
-    _WIN32, StringTraits, UnicodeTraits, underscore_on_windows)
+    UNDERSCORE_ON_WIN32, _WIN32, StringTraits, UnicodeTraits)
 from rpython.tool.sourcetools import func_renamer
 from rpython.rlib.rarithmetic import r_longlong
 from rpython.rtyper.extfunc import (
     SEEK_CUR = platform.DefinedConstantInteger('SEEK_CUR')
     SEEK_END = platform.DefinedConstantInteger('SEEK_END')
 
-    UTIMBUF     = platform.Struct('struct '+underscore_on_windows+'utimbuf',
-                                  [('actime', rffi.INT),
-                                   ('modtime', rffi.INT)])
+    UTIMBUF = platform.Struct('struct %sutimbuf' % UNDERSCORE_ON_WIN32,
+                              [('actime', rffi.INT),
+                               ('modtime', rffi.INT)])
 
 
 class RegisterOs(BaseLazyRegistering):
 
     @registering(os.dup)
     def register_os_dup(self):
-        os_dup = self.llexternal(underscore_on_windows+'dup', [rffi.INT], rffi.INT)
+        os_dup = self.llexternal(UNDERSCORE_ON_WIN32 + 'dup',
+                                 [rffi.INT], rffi.INT)
 
         def dup_llimpl(fd):
             rposix.validate_fd(fd)
 
     @registering(os.dup2)
     def register_os_dup2(self):
-        os_dup2 = self.llexternal(underscore_on_windows+'dup2',
+        os_dup2 = self.llexternal(UNDERSCORE_ON_WIN32 + 'dup2',
                                   [rffi.INT, rffi.INT], rffi.INT)
 
         def dup2_llimpl(fd, newfd):
 
     @registering(os.read)
     def register_os_read(self):
-        os_read = self.llexternal(underscore_on_windows+'read',
+        os_read = self.llexternal(UNDERSCORE_ON_WIN32 + 'read',
                                   [rffi.INT, rffi.VOIDP, rffi.SIZE_T],
                                   rffi.SIZE_T)
 
 
     @registering(os.write)
     def register_os_write(self):
-        os_write = self.llexternal(underscore_on_windows+'write',
+        os_write = self.llexternal(UNDERSCORE_ON_WIN32 + 'write',
                                    [rffi.INT, rffi.VOIDP, rffi.SIZE_T],
                                    rffi.SIZE_T)
 
 
     @registering(os.close)
     def register_os_close(self):
-        os_close = self.llexternal(underscore_on_windows+'close', [rffi.INT],
+        os_close = self.llexternal(UNDERSCORE_ON_WIN32 + 'close', [rffi.INT],
                                    rffi.INT, releasegil=False)
 
         def close_llimpl(fd):
 
     @registering(os.getcwd)
     def register_os_getcwd(self):
-        os_getcwd = self.llexternal(underscore_on_windows + 'getcwd',
+        os_getcwd = self.llexternal(UNDERSCORE_ON_WIN32 + 'getcwd',
                                     [rffi.CCHARP, rffi.SIZE_T],
                                     rffi.CCHARP)
 
 
     @registering(os.getcwdu, condition=sys.platform=='win32')
     def register_os_getcwdu(self):
-        os_wgetcwd = self.llexternal(underscore_on_windows + 'wgetcwd',
+        os_wgetcwd = self.llexternal(UNDERSCORE_ON_WIN32 + 'wgetcwd',
                                      [rffi.CWCHARP, rffi.SIZE_T],
                                      rffi.CWCHARP)
 
 
     @registering(os.isatty)
     def register_os_isatty(self):
-        os_isatty = self.llexternal(underscore_on_windows+'isatty', [rffi.INT], rffi.INT)
+        os_isatty = self.llexternal(UNDERSCORE_ON_WIN32 + 'isatty',
+                                    [rffi.INT], rffi.INT)
 
         def isatty_llimpl(fd):
             if not rposix.is_valid_fd(fd):
 
     @registering(os.umask)
     def register_os_umask(self):
-        os_umask = self.llexternal(underscore_on_windows+'umask', [rffi.MODE_T], rffi.MODE_T)
+        os_umask = self.llexternal(UNDERSCORE_ON_WIN32 + 'umask',
+                                   [rffi.MODE_T], rffi.MODE_T)
 
         def umask_llimpl(newmask):
             res = os_umask(rffi.cast(rffi.MODE_T, newmask))

rpython/rtyper/module/support.py

 from rpython.rtyper.lltypesystem import lltype, rffi
 
 _WIN32 = sys.platform.startswith('win')
-underscore_on_windows = '_' if _WIN32 else ''
+UNDERSCORE_ON_WIN32 = '_' if _WIN32 else ''
 
 # utility conversion functions
 class LLSupport:
 
     @staticmethod
     def posix_function_name(name):
-        return underscore_on_windows + name
+        return UNDERSCORE_ON_WIN32 + name
 
     @staticmethod
     def ll_os_name(name):
 
     @staticmethod
     def posix_function_name(name):
-        return underscore_on_windows + 'w' + name
+        return UNDERSCORE_ON_WIN32 + 'w' + name
 
     @staticmethod
     def ll_os_name(name):