Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ pandas 0.13
called using the top level matplotlib API (:issue:`4408`)
- Fixed a bug where calling ``Series.astype(str)`` would truncate the string
(:issue:`4405`, :issue:`4437`)
- Fixed a py3 compat issue where bytes were being repr'd as tuples
(:issue:`4455`)

pandas 0.12
===========
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,8 @@ def _is_sequence(x):
try:
iter(x)
len(x) # it has a length
return not isinstance(x, compat.string_types) and True
return not isinstance(x, compat.string_types +
(compat.binary_type,)) and True
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback is this True here for a reason? It will have no effect on the return value of _is_sequence...

except Exception:
return False

Expand Down Expand Up @@ -2053,8 +2054,7 @@ def as_escaped_unicode(thing,escape_chars=escape_chars):

return compat.text_type(result)

if (compat.PY3 and hasattr(thing, '__next__')) or \
hasattr(thing, 'next'):
if (compat.PY3 and hasattr(thing, '__next__')) or hasattr(thing, 'next'):
return compat.text_type(thing)
elif (isinstance(thing, dict) and
_nest_lvl < get_option("display.pprint_nest_depth")):
Expand Down
19 changes: 17 additions & 2 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime
import sys
import re

import nose
from nose.tools import assert_equal
import unittest

from pandas import Series, DataFrame, date_range, DatetimeIndex, Timestamp
from pandas.compat import range, long, lrange, lmap, u, map
from pandas.compat import range, long, lrange, lmap, u
from pandas.core.common import notnull, isnull
import pandas.core.common as com
import pandas.util.testing as tm
Expand Down Expand Up @@ -147,6 +147,21 @@ def test_all_not_none():
assert(not com._all_not_none(None, None, None, None))


def test_repr_binary_type():
import string
letters = string.ascii_letters
btype = compat.binary_type
try:
raw = btype(letters, encoding=cf.get_option('display.encoding'))
except TypeError:
raw = btype(letters)
b = compat.text_type(compat.bytes_to_str(raw))
res = com.pprint_thing(b, quote_strings=True)
assert_equal(res, repr(b))
res = com.pprint_thing(b, quote_strings=False)
assert_equal(res, b)


def test_rands():
r = com.rands(10)
assert(len(r) == 10)
Expand Down