Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kostya committed Jun 22, 2013
1 parent c043936 commit 15c462a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib-topaz/env.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class << ENV
def to_hash
{}.tap{ |h| self.each { |k, v| h[k] = v } }
{}.tap { |h| self.each { |k, v| h[k] = v } }
end

def empty?
Expand Down
15 changes: 9 additions & 6 deletions topaz/objects/envobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def method_subscript(self, space, key):
val = os.environ[key]
except KeyError:
return space.w_nil
return space.newstr_fromstr_frozen(val)
s = space.newstr_fromstr(val)
space.send(s, "freeze")
return s

@classdef.method("store", key="str")
@classdef.method("[]=", key="str")
Expand All @@ -36,7 +38,7 @@ def method_subscript_assign(self, space, key, w_value):
if w_value is space.w_nil:
try:
del os.environ[key]
except:
except (KeyError, OSError):
pass
return space.w_nil
if "=" in key or key is "":
Expand All @@ -53,10 +55,11 @@ def method_each(self, space, block):
if block is None:
return space.send(self, "enum_for", [space.newsymbol("each")])
for k, v in os.environ.items():
space.invoke_block(block, [space.newarray([
space.newstr_fromstr_frozen(k),
space.newstr_fromstr_frozen(v)
])])
sk = space.newstr_fromstr(k)
sv = space.newstr_fromstr(v)
space.send(sk, "freeze")
space.send(sv, "freeze")
space.invoke_block(block, [space.newarray([sk, sv])])
return self

@classdef.method("length")
Expand Down

0 comments on commit 15c462a

Please sign in to comment.