/usr/lib/python3/dist-packages/astroML/py3k_compat.py is in python3-astroml 0.3-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """
Compatibility utilities for Python 2 & 3
"""
import sys
py3k = (sys.version_info[0] == 3)
#----------------------------------------------------------------------
# urllib stuff
if py3k:
from urllib.request import urlopen
from urllib.error import HTTPError
from urllib.parse import urlencode
else:
from urllib2 import urlopen
from urllib2 import HTTPError
from urllib import urlencode
def url_content_length(fhandle):
if py3k:
length = dict(fhandle.info())['Content-Length']
else:
length = fhandle.info().getheader('Content-Length')
return int(length.strip())
#----------------------------------------------------------------------
# pickle stuff
if py3k:
from pickle import load, dump
else:
from cPickle import load, dump
#----------------------------------------------------------------------
# StringIO
if py3k:
from io import StringIO, BytesIO
else:
from cStringIO import StringIO
from cStringIO import StringIO as BytesIO
|