Skip to content

Commit

Permalink
Make pywatchman run on Python 3
Browse files Browse the repository at this point in the history
Refs: #219
  • Loading branch information
Qwait authored and wez committed Feb 25, 2016
1 parent c95bf46 commit af477d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/pywatchman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# so fall back to a pure Python implementation.
try:
import bser
except ImportError, e:
except ImportError:
import pybser as bser

import capabilities
Expand Down
6 changes: 5 additions & 1 deletion python/pywatchman/pybser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import collections
import ctypes
import struct
import sys

BSER_ARRAY = '\x00'
BSER_OBJECT = '\x01'
Expand All @@ -49,6 +50,9 @@
# int32 for the header
EMPTY_HEADER = "\x00\x01\x05\x00\x00\x00\x00"

# Python 3 conditional for supporting Python 2's int/long types
if sys.version_info > (3,):
long = int

def _int_size(x):
"""Return the smallest size int that can store the value"""
Expand All @@ -58,7 +62,7 @@ def _int_size(x):
return 2
elif -0x80000000 <= x <= 0x7FFFFFFF:
return 4
elif -0x8000000000000000L <= x <= 0x7FFFFFFFFFFFFFFFL:
elif long(-0x8000000000000000) <= x <= long(0x7FFFFFFFFFFFFFFF):
return 8
else:
raise RuntimeError('Cannot represent value: ' + str(x))
Expand Down

0 comments on commit af477d0

Please sign in to comment.