Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent treatment of non-character path inputs #370

Open
raymondben opened this issue Feb 22, 2022 · 2 comments
Open

Inconsistent treatment of non-character path inputs #370

raymondben opened this issue Feb 22, 2022 · 2 comments
Labels
feature a feature request or enhancement

Comments

@raymondben
Copy link
Contributor

Some functions (e.g. path_tidy) call enc2utf8(as.character(path)), but others do not coerce to character first (e.g. path_expand just calls enc2utf8(path)). This leads to inconsistent treatment of non-character path inputs between different functions:

> fs::path_tidy(NA)
NA
> fs::path_expand(NA)
Error in enc2utf8(path) : argument is not a character vector

and also logically-inconsistent behaviour in some cases:

> fs::file_exists(NA_character_)
 <NA> 
FALSE 

but

> fs::file_exists(NA)
Error in enc2utf8(path) : argument is not a character vector

If this isn't intentional, would it be unreasonable to apply an as.character coercion to all calls to enc2utf8 to avoid these errors?

@gaborcsardi
Copy link
Member

I think it would make sense to try to convert to characters, would you like to submit a PR?

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Feb 23, 2022
@raymondben
Copy link
Contributor Author

OK, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants