Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Commit

Permalink
get_sheet python 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiofsilva committed May 29, 2015
1 parent 1a8542c commit 004c5e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions tests/test_by_name_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def test_get_by_index(self):

def test_invalid_sheet_parameter(self):
'Raises exception when sheet is not string or integer'
with self.assertRaises(Exception) as context:
try:
self.wb.get_sheet(1.1)
#print context.exception
self.assertTrue('sheet must be integer or string' in context.exception)
except Exception, e:
self.assertTrue('sheet must be integer or string', e)
else:
self.fail('exception not raised')

if __name__=='__main__':
unittest.main()
4 changes: 2 additions & 2 deletions xlwt/Workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from . import BIFFRecords
from . import Style
from .compat import unicode_type
from .compat import unicode_type, int_types, basestring

class Workbook(object):
"""
Expand Down Expand Up @@ -374,7 +374,7 @@ def add_sheet(self, sheetname, cell_overwrite_ok=False):
return self.__worksheets[-1]

def get_sheet(self, sheet):
if isinstance(sheet, int):
if isinstance(sheet, int_types):
return self.__worksheets[sheet]
elif isinstance(sheet, basestring):
sheetnum = self.sheet_index(sheet)
Expand Down

0 comments on commit 004c5e7

Please sign in to comment.