question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please support Python 3.9

See original GitHub issue

When I run pytest . --workers auto with Python 3.9, this error occur.

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/_pytest/main.py", line 255, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pytest_parallel/__init__.py", line 219, in pytest_sessionstart
INTERNALERROR>     os.environ = ThreadLocalEnviron(os.environ)
INTERNALERROR>   File "/.../venv/lib/python3.9/site-packages/pytest_parallel/__init__.py", line 122, in __init__
INTERNALERROR>     env.putenv,
INTERNALERROR> AttributeError: '_Environ' object has no attribute 'putenv'

So I check the code, it uses os.environ.putenv but Python doesn’t have the API. Then only have os.putenv.

On Python 3.8 they are exists.

Python 3.8.6 (default, Dec 11 2020, 14:45:03)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> e = os.environ
>>> e.putenv
<built-in function putenv>
>>> os.putenv == e.putenv
True

But 3.9 does not

Python 3.9.0 (default, Oct  7 2020, 23:09:01)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> e = os.environ
>>> e.putenv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: '_Environ' object has no attribute 'putenv'

and definition of _Environ is also changed.

class _Environ(MutableMapping):
    def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue):
        self.encodekey = encodekey
        self.decodekey = decodekey
        self.encodevalue = encodevalue
        self.decodevalue = decodevalue
        self._data = data

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:44
  • Comments:9

github_iconTop GitHub Comments

8reactions
amal-khailtashcommented, Mar 12, 2021

Making these changes works for Python 3.9+, but not sure if it breaks older releases 3.8-:

# pytest_parallel/__init__.py

114: class ThreadLocalEnviron(os._Environ):
115:     def __init__(self, env):
116:         super().__init__(
117:             env._data,
118:             env.encodekey,
119:             env.decodekey,
120:             env.encodevalue,
121:             env.decodevalue,
122:             # env.putenv,    # <---- Commented
123:             # env.unsetenv   # <---- Commented
124:         )

139:     def __setitem__(self, key, value):
140:         if key == 'PYTEST_CURRENT_TEST':
141:             value = self.encodevalue(value)
142:             os.putenv(self.encodekey(key), value)   # <------  Changed self to os

147:     def __delitem__(self, key):
148:         if key == 'PYTEST_CURRENT_TEST':
149:             os.unsetenv(self.encodekey(key))   # <------  Changed self to os
0reactions
Sumedh-Kadoocommented, Sep 8, 2021

e solved. It is preventing me from moving from 3.8. Is this closed as it is a pytest-parall

Its happening with 3.9.7 so I read some of the issues here and it looks like this project is not maintained anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Release Python 3.9.0
Python 3.9 is incompatible with this unsupported version of Windows. Major new features of the 3.9 series, compared to 3.8. Some of the...
Read more >
Python 3.9 support table for most popular Python packages
This site shows Python 3.9 support for the 360 most downloaded packages on PyPI: 274 green packages (76.1%) support Python 3.9;; 86 white...
Read more >
Python 3.9: please confirm support in pants #11818 - GitHub
hi, the pants script only seems to support up to Python 3.8: https://pantsbuild.github.io/setup/pants function set_supported_python_versions ...
Read more >
How to PIP Install Requests Python Package - ActiveState
Try a faster and easier way to manage your Python dependencies. Use Python 3.9 by ActiveState and build your own runtime with the...
Read more >
How can I run Python 3.9.1 natively on M1 Mac?
Please help a newbie figure out how to take advantage of his recent impulse-buy. python-3.9 · apple-silicon · Share.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found