Skip to content
Permalink
Browse files

random small cleanups

  • Loading branch information
Alex Gaynor
Alex Gaynor committed Mar 23, 2013
1 parent e4ddaf7 commit b20db28f7e158bd0291a1f32ec7b965f3369921e
Showing with 12 additions and 8 deletions.
  1. +1 −1 topaz/interpreter.py
  2. +1 −0 topaz/mapdict.py
  3. +3 −3 topaz/objects/fileobject.py
  4. +1 −1 topaz/objects/regexpobject.py
  5. +6 −3 topaz/objspace.py
@@ -376,7 +376,7 @@ def BUILD_CLASS(self, space, bytecode, frame, pc):
"wrong argument type %s (expected Class)" % cls_name
)
assert isinstance(superclass, W_ClassObject)
w_cls = space.newclass(name, superclass, is_singleton=False, w_scope=w_scope)
w_cls = space.newclass(name, superclass, w_scope=w_scope)
space.set_const(w_scope, name, w_cls)
elif not space.is_kind_of(w_cls, space.w_class):
raise space.error(space.w_TypeError, "%s is not a class" % name)
@@ -8,6 +8,7 @@
# note: we use "x * NUM_DIGITS_POW2" instead of "x << NUM_DIGITS" because
# we want to propagate knowledge that the result cannot be negative


class MapTransitionCache(object):
def __init__(self, space):
# Mappings of classes -> their terminator nodes.
@@ -395,11 +395,11 @@ def method_nlink(self, space):

@classdef.method("setgid?")
def method_setgidp(self, space):
return space.newbool(stat.S_IMODE(self.get_stat(space).st_mode) & stat.S_ISGID)
return space.newbool(bool(stat.S_IMODE(self.get_stat(space).st_mode) & stat.S_ISGID))

@classdef.method("setuid?")
def method_setuidp(self, space):
return space.newbool(stat.S_IMODE(self.get_stat(space).st_mode) & stat.S_ISUID)
return space.newbool(bool(stat.S_IMODE(self.get_stat(space).st_mode) & stat.S_ISUID))

@classdef.method("size")
def method_size(self, space):
@@ -411,7 +411,7 @@ def method_socketp(self, space):

@classdef.method("sticky?")
def method_stickyp(self, space):
return space.newbool(stat.S_IMODE(self.get_stat(space).st_mode) & stat.S_ISVTX)
return space.newbool(bool(stat.S_IMODE(self.get_stat(space).st_mode) & stat.S_ISVTX))

@classdef.method("symlink?")
def method_symlinkp(self, space):
@@ -223,7 +223,7 @@ def method_eqeqeq(self, space, s):

@classdef.method("casefold?")
def method_casefoldp(self, space):
return space.newbool(self.flags & regexp.IGNORE_CASE)
return space.newbool(bool(self.flags & regexp.IGNORE_CASE))

@classdef.singleton_method("escape", string="str")
def method_escape(self, space, string):
@@ -3,9 +3,10 @@
import os
import sys

from rpython.rlib import jit, rpath
from rpython.rlib import jit, rpath, types
from rpython.rlib.cache import Cache
from rpython.rlib.objectmodel import specialize
from rpython.rlib.signature import signature
from rpython.rlib.rarithmetic import intmask
from rpython.rlib.rbigint import rbigint

@@ -56,7 +57,7 @@
from topaz.objects.moduleobject import W_ModuleObject
from topaz.objects.nilobject import W_NilObject
from topaz.objects.numericobject import W_NumericObject
from topaz.objects.objectobject import W_Object, W_BaseObject
from topaz.objects.objectobject import W_Object, W_BaseObject, W_Root
from topaz.objects.procobject import W_ProcObject
from topaz.objects.randomobject import W_RandomObject
from topaz.objects.rangeobject import W_RangeObject
@@ -317,12 +318,14 @@ def execute_frame(self, frame, bc):

# Methods for allocating new objects.

@signature(types.any(), types.bool(), returns=types.instance(W_Root))
def newbool(self, boolvalue):
if boolvalue:
return self.w_true
else:
return self.w_false

@signature(types.any(), types.int(), returns=types.instance(W_FixnumObject))
def newint(self, intvalue):
return W_FixnumObject(self, intvalue)

@@ -422,7 +425,7 @@ def buildname(self, name, w_scope):
complete_name = name
if w_scope is not None:
assert isinstance(w_scope, W_ModuleObject)
if w_scope.name != "Object":
if w_scope is not self.w_object:
complete_name = "%s::%s" % (w_scope.name, name)
return complete_name

0 comments on commit b20db28

Please sign in to comment.
You can’t perform that action at this time.