From a11137a2e58f9a937bb58929419fd35af651fee9 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 14 Nov 2016 12:07:51 -0600 Subject: [PATCH] COMPAT: Cast to string before raise in read_stata in `pandas.io.stata::StataReader::_read_old_hearder` we try to raise a ValueError. I'm working on making a test, but this is buried pretty deep. For now, `typlist` has type `List[int]`. We call ```python ','.join(typlist) ``` which errors on py3. --- pandas/io/stata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 985ea9c051505..14bd670862b41 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -1210,18 +1210,18 @@ def _read_old_header(self, first_char): if tp in self.OLD_TYPE_MAPPING: typlist.append(self.OLD_TYPE_MAPPING[tp]) else: - typlist.append(tp - 127) # string + typlist.append(tp - 127) # py2 string, py3 bytes try: self.typlist = [self.TYPE_MAP[typ] for typ in typlist] except: raise ValueError("cannot convert stata types [{0}]" - .format(','.join(typlist))) + .format(','.join(str(x) for x in typlist))) try: self.dtyplist = [self.DTYPE_MAP[typ] for typ in typlist] except: raise ValueError("cannot convert stata dtypes [{0}]" - .format(','.join(typlist))) + .format(','.join(str(x) for x in typlist))) if self.format_version > 108: self.varlist = [self._null_terminate(self.path_or_buf.read(33))