You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run the above code with -bb, it crashes with BytesWarning:
% python -bb repro.py
Traceback (most recent call last):
File "repro.py", line 6, in <module>
pandas.read_fwf(input)
File "/Users/fsouza/.venvs/pandas-debug/lib/python3.7/site-packages/pandas/io/parsers.py", line 791, in read_fwf
return _read(filepath_or_buffer, kwds)
File "/Users/fsouza/.venvs/pandas-debug/lib/python3.7/site-packages/pandas/io/parsers.py", line 457, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "/Users/fsouza/.venvs/pandas-debug/lib/python3.7/site-packages/pandas/io/parsers.py", line 895, in __init__
self._make_engine(self.engine)
File "/Users/fsouza/.venvs/pandas-debug/lib/python3.7/site-packages/pandas/io/parsers.py", line 1147, in _make_engine
self._engine = klass(self.f, **self.options)
File "/Users/fsouza/.venvs/pandas-debug/lib/python3.7/site-packages/pandas/io/parsers.py", line 3709, in __init__
PythonParser.__init__(self, f, **kwds)
File "/Users/fsouza/.venvs/pandas-debug/lib/python3.7/site-packages/pandas/io/parsers.py", line 2348, in __init__
r"[^-^0-9^{decimal}]+".format(decimal=self.decimal)
BytesWarning: str() on a bytes instance
It doesn't crash without that flag, but we do end-up with the incorrect regexp:
Maybe I’m missing something but shouldn’t you receive a warning or error when using -bb option (see below from DOCS )
``
1.1.3. Miscellaneous options
-b
Issue a warning when comparing bytes or bytearray with str or bytes with int. Issue an error when the option is given twice (-bb).
Changed in version 3.5: Affects comparisons of bytes with int.
``
@lwgray -b is warning, -bb is error. But the reason it warms/errors is because the code doesn't do what's intended when running on python 3. I can send a PR that coalesces decimal to str before using it in format, if that's ok/acceptable.
Code Sample, a copy-pastable example if possible
Problem description
If you run the above code with
-bb
, it crashes withBytesWarning
:It doesn't crash without that flag, but we do end-up with the incorrect regexp:
Notice how you end-up with an unexpected regexp.
Expected Output
No crash.
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: