Skip to content

Commit b0aa224

Browse files
glaukiol1sbinet
andauthored
Update os/os.module.go
Co-authored-by: Sebastien Binet <[email protected]>
1 parent c1be034 commit b0aa224

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

os/os.module.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,11 @@ func chdir(self py.Object, args py.Tuple) (py.Object, error) {
7878
if len(args) == 0 {
7979
return nil, py.ExceptionNewf(py.TypeError, "Missing required argument 'path' (pos 1)")
8080
}
81-
if !objectIsString(args[0]) {
81+
dir, ok := args[0].(py.String)
82+
if !ok {
8283
return nil, py.ExceptionNewf(py.TypeError, "str expected, not "+args[0].Type().Name)
8384
}
84-
dir, err := py.ReprAsString(args[0])
85-
if err != nil {
86-
return nil, py.ExceptionNewf(py.TypeError, "Failed to parse string") // never going to run
87-
}
88-
dir = strings.ReplaceAll(dir, "'", "")
85+
err = os.Chdir(string(dir))
8986
err = os.Chdir(dir)
9087
if err != nil {
9188
return nil, py.ExceptionNewf(py.NotADirectoryError, "Couldn't change cwd; "+err.Error())

0 commit comments

Comments
 (0)