Skip to content
Browse files

Merge pull request #521 from michelboaventura/env_delete

Implements ENV#delete
  • Loading branch information
alex committed Mar 18, 2013
2 parents 9b39c7d + b85adea commit 1378fb318d8a1330a4a396c355858c11c34b60a2
Showing with 13 additions and 3 deletions.
  1. +0 −3 spec/tags/core/env/delete_tags.txt
  2. +13 −0 topaz/objects/

This file was deleted.

@@ -33,3 +33,16 @@ def method_subscript_assign(self, space, key, value):
raise space.error(space.w_ArgumentError, "bad environment variable value")
os.environ[key] = value
return space.newstr_fromstr(value)

@classdef.method("delete", key="str")
def method_delete(self, space, key, block=None):
if "\0" in key:
raise space.error(space.w_ArgumentError, "bad environment variable name")
val = os.environ[key]
except KeyError:
if block is not None:
space.invoke_block(block, [space.newstr_fromstr(key)])
return space.w_nil
del os.environ[key]
return space.newstr_fromstr(val)

0 comments on commit 1378fb3

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