@@ -9,7 +9,6 @@ package os
9
9
import (
10
10
"os"
11
11
"os/exec"
12
- "reflect"
13
12
"strings"
14
13
15
14
"github.com/go-python/gpython/py"
@@ -167,18 +166,16 @@ func putenv(self py.Object, args py.Tuple) (py.Object, error) {
167
166
// Unset (delete) the environment variable named key.
168
167
func unsetenv (self py.Object , args py.Tuple ) (py.Object , error ) {
169
168
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
181
172
}
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
182
179
}
183
180
if len (args ) == 0 {
184
181
return nil , py .ExceptionNewf (py .TypeError , "missing one required argument: 'key:str'" )
0 commit comments