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

INTERNALERROR on Windows #13

Open
eugene-davis opened this issue Jul 22, 2019 · 3 comments
Open

INTERNALERROR on Windows #13

eugene-davis opened this issue Jul 22, 2019 · 3 comments
Labels
bug Something isn't working question Further information is requested

Comments

@eugene-davis
Copy link

When running pytest-bandit on Windows (Python 3.5, 3.6, 3.7) I get the following message.

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\_pytest\main.py", line 206, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\_pytest\main.py", line 250, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\pluggy\manager.py", line 87, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\pluggy\manager.py", line 81, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\pluggy\callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\pytest_bandit\plugin.py", line 172, in pytest_runtestloop
INTERNALERROR>     bandit_failures = BanditItem(compat_session).runtest()
INTERNALERROR>   File "C:\Users\VssAdministrator\AppData\Roaming\Python\Python35\site-packages\pytest_bandit\controller.py", line 53, in runtest
INTERNALERROR>     sys.stdout.write(os.linesep)
INTERNALERROR> ValueError: underlying buffer has been detached

==================== 3 passed, 15 skipped in 1.46 seconds =====================
Exception ignored in: <_io.TextIOWrapper mode='w' encoding='cp1252'>
ValueError: underlying buffer has been detached
##[error]Cmd.exe exited with code '3'.
##[section]Finishing: Tests
@mattwwarren
Copy link
Contributor

This is an interesting issue you've uncovered. It is almost certainly because we override sys.stdout in order to get proper bandit output on the terminal.

But from a cursory Google search, this error would only happen if some other code has detached sys.stdout, which we don't do. So without a little context from the program you're testing, I'm not sure we can get to the bottom of this.

@mattwwarren mattwwarren added bug Something isn't working question Further information is requested labels Jul 25, 2019
@eugene-davis
Copy link
Author

I can provide the extra context for sure. First off, here's the PR where I tried to enable it on a particular project: tomtom-international/ebr-board#9

This executes on Azure DevOps pipelines in the vs2017-win2016 image (defined here: https://github.com/tomtom-international/azure-pipeline-templates/blob/master/jobs/python.setup.py.yml#L31)

The actual PyTest command is executed here: https://github.com/tomtom-international/azure-pipeline-templates/blob/master/steps/python/python.build.yml#L29

Let me know how I can help.

@mattwwarren
Copy link
Contributor

Hm, interesting, it's definitely specific to Windows. I'll try to get a development environment set up so I can debug a bit further. Thanks for the links, I should be able to use that Docker container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Development

No branches or pull requests

2 participants