Skip to content

SystemError when passing an empty byte string in Python 3.x #1087

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

Closed
reaperhulk opened this issue Sep 29, 2015 · 1 comment
Closed

SystemError when passing an empty byte string in Python 3.x #1087

reaperhulk opened this issue Sep 29, 2015 · 1 comment
Assignees
Labels
type: bug problem that needs to be addressed
Milestone

Comments

@reaperhulk
Copy link
Contributor

Under Python 3.x with pytest 2.8.1

import pytest

@pytest.mark.parametrize("message", [b""])
def test_broken(message):
    pass

causes a SystemError during the call to codecs.escape_encode inside _escape_bytes. This was introduced in commit e106367, but is really a CPython bug as codecs.escape_encode(b'') should not cause a SystemError. That said, pytest probably needs to work around the bug for now.

Stack trace:

../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/runner.py:149: in __init__
    self.result = func()
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/main.py:437: in _memocollect
    return self._memoizedcall('_collected', lambda: list(self.collect()))
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/main.py:317: in _memoizedcall
    res = function()
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/main.py:437: in <lambda>
    return self._memoizedcall('_collected', lambda: list(self.collect()))
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:578: in collect
    return super(Module, self).collect()
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:432: in collect
    res = self.makeitem(name, obj)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:444: in makeitem
    collector=self, name=name, obj=obj)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:724: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:338: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:333: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:595: in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:249: in _wrapped_call
    wrap_controller.send(call_outcome)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:307: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:464: in _genfunctions
    self.ihook.pytest_generate_tests(metafunc=metafunc)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:724: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:338: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:333: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/vendored_packages/pluggy.py:596: in execute
    res = hook_impl.function(*args)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:217: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:994: in parametrize
    ids = idmaker(argnames, argvalues, idfn)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:1108: in idmaker
    for valindex, valset in enumerate(argvalues)]
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:1108: in <listcomp>
    for valindex, valset in enumerate(argvalues)]
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:1103: in _idvalset
    for val, argname in zip(valset, argnames)]
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:1103: in <listcomp>
    for val, argname in zip(valset, argnames)]
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:1082: in _idval
    return _escape_bytes(val)
../../.virtualenvs/crypto3/lib/python3.4/site-packages/_pytest/python.py:1058: in _escape_bytes
    encoded_bytes, _ = codecs.escape_encode(val)
E   SystemError: Objects/bytesobject.c:2828: bad argument to internal function
@The-Compiler
Copy link
Member

I reported the bug upstream as issue25271.

@nicoddemus nicoddemus added the type: bug problem that needs to be addressed label Sep 29, 2015
@nicoddemus nicoddemus added this to the 2.8.2 milestone Sep 29, 2015
@nicoddemus nicoddemus self-assigned this Sep 29, 2015
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Sep 29, 2015
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Sep 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants