@@ -27,6 +27,15 @@ impl From<PyErr> for io::Error {
2727 } else if err. is_instance_of :: < exceptions:: PyTimeoutError > ( py) {
2828 io:: ErrorKind :: TimedOut
2929 } else {
30+ #[ cfg( io_error_more) ]
31+ if err. is_instance_of :: < exceptions:: PyIsADirectoryError > ( py) {
32+ io:: ErrorKind :: IsADirectory
33+ } else if err. is_instance_of :: < exceptions:: PyNotADirectoryError > ( py) {
34+ io:: ErrorKind :: NotADirectory
35+ } else {
36+ io:: ErrorKind :: Other
37+ }
38+ #[ cfg( not( io_error_more) ) ]
3039 io:: ErrorKind :: Other
3140 }
3241 } ) ;
@@ -54,6 +63,10 @@ impl From<io::Error> for PyErr {
5463 io:: ErrorKind :: AlreadyExists => exceptions:: PyFileExistsError :: new_err ( err) ,
5564 io:: ErrorKind :: WouldBlock => exceptions:: PyBlockingIOError :: new_err ( err) ,
5665 io:: ErrorKind :: TimedOut => exceptions:: PyTimeoutError :: new_err ( err) ,
66+ #[ cfg( io_error_more) ]
67+ io:: ErrorKind :: IsADirectory => exceptions:: PyIsADirectoryError :: new_err ( err) ,
68+ #[ cfg( io_error_more) ]
69+ io:: ErrorKind :: NotADirectory => exceptions:: PyNotADirectoryError :: new_err ( err) ,
5770 _ => exceptions:: PyOSError :: new_err ( err) ,
5871 }
5972 }
@@ -167,5 +180,9 @@ mod tests {
167180 check_err ( io:: ErrorKind :: AlreadyExists , "FileExistsError" ) ;
168181 check_err ( io:: ErrorKind :: WouldBlock , "BlockingIOError" ) ;
169182 check_err ( io:: ErrorKind :: TimedOut , "TimeoutError" ) ;
183+ #[ cfg( io_error_more) ]
184+ check_err ( io:: ErrorKind :: IsADirectory , "IsADirectoryError" ) ;
185+ #[ cfg( io_error_more) ]
186+ check_err ( io:: ErrorKind :: NotADirectory , "NotADirectoryError" ) ;
170187 }
171188}
0 commit comments