@@ -9,7 +9,6 @@ package os
99import (
1010 "os"
1111 "os/exec"
12- "reflect"
1312 "strings"
1413
1514 "github.com/go-python/gpython/py"
@@ -167,18 +166,16 @@ func putenv(self py.Object, args py.Tuple) (py.Object, error) {
167166// Unset (delete) the environment variable named key.
168167func unsetenv (self py.Object , args py.Tuple ) (py.Object , error ) {
169168 if len (args ) == 1 && objectIsString (args [0 ]) {
170- if reflect .TypeOf (args [0 ]).String () == "py.String" {
171- _k , err := py .ReprAsString (args [0 ])
172- if err != nil {
173- return nil , py .ExceptionNewf (py .TypeError , "Unable to parse string" ) // this will never execute
174- }
175- key := strings .ReplaceAll (_k , "'" , "" ) // required
176- err = os .Unsetenv (key )
177- if err != nil {
178- return nil , py .ExceptionNewf (py .OSError , "Unable to unset enviroment variable" )
179- }
180- return py .None , nil
169+ _k , err := py .ReprAsString (args [0 ])
170+ if err != nil {
171+ return nil , py .ExceptionNewf (py .TypeError , "Unable to parse string" ) // this will never execute
181172 }
173+ key := strings .ReplaceAll (_k , "'" , "" ) // required
174+ err = os .Unsetenv (key )
175+ if err != nil {
176+ return nil , py .ExceptionNewf (py .OSError , "Unable to unset enviroment variable" )
177+ }
178+ return py .None , nil
182179 }
183180 if len (args ) == 0 {
184181 return nil , py .ExceptionNewf (py .TypeError , "missing one required argument: 'key:str'" )
0 commit comments