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

Simplify code converting os.environ to strings (avoiding six) #28848

Merged
merged 1 commit into from
May 6, 2021

Conversation

foolip
Copy link
Member

@foolip foolip commented May 5, 2021

os.environ always uses str on Python 3, there's a new os.environb for a
bytes version, which isn't supported on Windows:
https://docs.python.org/3/library/os.html#os.environ
https://docs.python.org/3/library/os.html#os.environb

Simply trust os.environ to be a dict[str, str], and simplify the
openssl.py code to something more like in GeckoDriverServer and
elsewhere:

env = os.environ.copy()
env["RUST_BACKTRACE"] = "1"
WebDriverServer.__init__(self, logger, binary,
host=host,
port=port,
env=cast_env(env),
args=args)

Part of #28776.

os.environ always uses str on Python 3, there's a new os.environb for a
bytes version, which isn't supported on Windows:
https://docs.python.org/3/library/os.html#os.environ
https://docs.python.org/3/library/os.html#os.environb

Simply trust os.environ to be a dict[str, str], and simplify the
openssl.py code to something more like in GeckoDriverServer and
elsewhere:
https://github.com/web-platform-tests/wpt/blob/302039ac7c43c71bc5389104c81871b81d6cc9e0/tools/wptrunner/wptrunner/webdriver_server.py#L187-L193

Part of #28776.
@wpt-pr-bot wpt-pr-bot added infra wptrunner The automated test runner, commonly called through ./wpt run wptserve labels May 5, 2021
foolip added a commit that referenced this pull request May 5, 2021
This code would raise "TypeError: str expected, not bytes" is run using
Python 3, since setting os.environ keys implictly encodes using
sys.getfilesystemencoding():
https://docs.python.org/3/library/os.html#os.environ

This might be dead code, or simply not exercised in wpt's CI.

Spotted while preparing #28848.
@foolip foolip assigned jgraham and unassigned LukeZielinski May 6, 2021
@foolip foolip requested review from gsnedders and removed request for LukeZielinski May 6, 2021 07:22
@foolip foolip merged commit ff6a312 into master May 6, 2021
@foolip foolip deleted the foolip/six_cast_env branch May 6, 2021 20:38
foolip added a commit that referenced this pull request May 7, 2021
This code would raise "TypeError: str expected, not bytes" is run using
Python 3, since setting os.environ keys implictly encodes using
sys.getfilesystemencoding():
https://docs.python.org/3/library/os.html#os.environ

This might be dead code, or simply not exercised in wpt's CI.

Spotted while preparing #28848.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 9, 2021
…ry string, a=testonly

Automatic update from web-platform-tests
Fix setting os.environ["PATH"] to a binary string (#28849)

This code would raise "TypeError: str expected, not bytes" is run using
Python 3, since setting os.environ keys implictly encodes using
sys.getfilesystemencoding():
https://docs.python.org/3/library/os.html#os.environ

This might be dead code, or simply not exercised in wpt's CI.

Spotted while preparing web-platform-tests/wpt#28848.
--

wpt-commits: 3d2cc9904a08bf372bdc09c96628cc4c986278ee
wpt-pr: 28849
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra wptrunner The automated test runner, commonly called through ./wpt run wptserve
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants