Skip to content

Commit

Permalink
Fix&extend comments
Browse files Browse the repository at this point in the history
  • Loading branch information
petamas committed May 13, 2023
1 parent f2465a6 commit 63cf347
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions oslex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def is_posix() -> bool:
"""
Returns whether the system running Python is POSIX compatible.
This is the condition for oslex.underyling being shlex.
This is the condition for oslex.underlying being shlex.
This is also the condition for os.path being posixpath.
"""
return 'posix' in sys.builtin_module_names
Expand All @@ -13,7 +13,7 @@ def is_posix() -> bool:
def is_windows() -> bool:
"""
Returns whether the system running Python is Windows based.
This is the condition for oslex.underyling being mslex.
This is the condition for oslex.underlying being mslex.
This is also the condition for os.path being ntpath.
"""

Expand All @@ -31,7 +31,7 @@ def is_windows() -> bool:
import shlex as underlying
elif is_windows():
# mslex has no type annotations -> we have to ignore the "import" error
# also, mypy does not understand conditioanl importing, so it thinks we are redefining the name -> we have to ignore the "no-redef" error
# also, mypy does not understand conditional importing, so it thinks we are redefining the name "underlying" -> we have to ignore the "no-redef" error
import mslex as underlying # type: ignore[import, no-redef]
else:
raise ImportError('no os specific module found')
Expand Down Expand Up @@ -61,7 +61,8 @@ def join(split_command: list[str]) -> str:
The returned value is shell-escaped to protect against injection vulnerabilities (see quote()).
This function is safe to use both for POSIX-compatible shells and for Windows's cmd.
"""
# shlex only has join() since python 3.8
# shlex only has join() since Python 3.8
# mslex doesn't have it at all
# it's easier to just implement it without trying to import the functionality
# It's easier to just implement it without trying to import the functionality
# Implementation is the same as shlex.join(), see https://github.com/python/cpython/blob/3.8/Lib/shlex.py
return ' '.join(quote(arg) for arg in split_command)

0 comments on commit 63cf347

Please sign in to comment.