Commit 262a47d2 authored by Ezio Melotti's avatar Ezio Melotti

Merged revisions 75407,75409-75413,75415,75419-75421 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75407 | antoine.pitrou | 2009-10-14 20:30:52 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix py3k warnings in the aifc module
........
  r75409 | antoine.pitrou | 2009-10-14 21:01:33 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix py3k warnings in bsddb
........
  r75410 | antoine.pitrou | 2009-10-14 21:09:45 +0300 (Wed, 14 Oct 2009) | 3 lines

  Silence a py3k warning claiming to affect Lib/calendar.py
........
  r75411 | antoine.pitrou | 2009-10-14 21:12:54 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix a py3k warning in the StringIO module (exhibited in test_codecencodings_cn)
........
  r75412 | antoine.pitrou | 2009-10-14 21:27:32 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix py3k warnings in the socket module
........
  r75413 | antoine.pitrou | 2009-10-14 21:31:05 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix a py3k warning in the sndhdr module (found with test_email)
........
  r75415 | antoine.pitrou | 2009-10-14 21:39:46 +0300 (Wed, 14 Oct 2009) | 3 lines

  Silence some py3k warnings claiming to affect _pyio
........
  r75419 | antoine.pitrou | 2009-10-14 21:56:11 +0300 (Wed, 14 Oct 2009) | 3 lines

  Silence py3k warning claiming to affect the random module
........
  r75420 | antoine.pitrou | 2009-10-14 22:04:48 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix py3k warnings in httplib
........
  r75421 | antoine.pitrou | 2009-10-14 22:09:48 +0300 (Wed, 14 Oct 2009) | 3 lines

  Fix py3k warnings in the uuid module
........
parent efcdd849
......@@ -128,7 +128,7 @@ class StringIO:
if self.buflist:
self.buf += ''.join(self.buflist)
self.buflist = []
if n < 0:
if n is None or n < 0:
newpos = self.len
else:
newpos = min(self.pos+n, self.len)
......
......@@ -409,7 +409,7 @@ class Aifc_read:
data = self._ssnd_chunk.read(nframes * self._framesize)
if self._convert and data:
data = self._convert(data)
self._soundpos = self._soundpos + len(data) / (self._nchannels * self._sampwidth)
self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth)
return data
#
......@@ -420,7 +420,7 @@ class Aifc_read:
import cl
dummy = self._decomp.SetParam(cl.FRAME_BUFFER_SIZE,
len(data) * 2)
return self._decomp.Decompress(len(data) / self._nchannels,
return self._decomp.Decompress(len(data) // self._nchannels,
data)
def _ulaw2lin(self, data):
......@@ -439,7 +439,7 @@ class Aifc_read:
def _read_comm_chunk(self, chunk):
self._nchannels = _read_short(chunk)
self._nframes = _read_long(chunk)
self._sampwidth = (_read_short(chunk) + 7) / 8
self._sampwidth = (_read_short(chunk) + 7) // 8
self._framerate = int(_read_float(chunk))
self._framesize = self._nchannels * self._sampwidth
if self._aifc:
......@@ -468,7 +468,7 @@ class Aifc_read:
pass
else:
self._convert = self._adpcm2lin
self._framesize = self._framesize / 4
self._framesize = self._framesize // 4
return
# for ULAW and ALAW try Compression Library
try:
......@@ -478,17 +478,17 @@ class Aifc_read:
try:
import audioop
self._convert = self._ulaw2lin
self._framesize = self._framesize / 2
self._framesize = self._framesize // 2
return
except ImportError:
pass
raise Error, 'cannot read compressed AIFF-C files'
if self._comptype == 'ULAW':
scheme = cl.G711_ULAW
self._framesize = self._framesize / 2
self._framesize = self._framesize // 2
elif self._comptype == 'ALAW':
scheme = cl.G711_ALAW
self._framesize = self._framesize / 2
self._framesize = self._framesize // 2
else:
raise Error, 'unsupported compression type'
self._decomp = cl.OpenDecompressor(scheme)
......@@ -706,7 +706,7 @@ class Aifc_write:
def writeframesraw(self, data):
self._ensure_header_written(len(data))
nframes = len(data) / (self._sampwidth * self._nchannels)
nframes = len(data) // (self._sampwidth * self._nchannels)
if self._convert:
data = self._convert(data)
self._file.write(data)
......@@ -820,17 +820,17 @@ class Aifc_write:
self._init_compression()
self._file.write('FORM')
if not self._nframes:
self._nframes = initlength / (self._nchannels * self._sampwidth)
self._nframes = initlength // (self._nchannels * self._sampwidth)
self._datalength = self._nframes * self._nchannels * self._sampwidth
if self._datalength & 1:
self._datalength = self._datalength + 1
if self._aifc:
if self._comptype in ('ULAW', 'ALAW'):
self._datalength = self._datalength / 2
self._datalength = self._datalength // 2
if self._datalength & 1:
self._datalength = self._datalength + 1
elif self._comptype == 'G722':
self._datalength = (self._datalength + 3) / 4
self._datalength = (self._datalength + 3) // 4
if self._datalength & 1:
self._datalength = self._datalength + 1
self._form_length_pos = self._file.tell()
......
This diff is collapsed.
......@@ -225,7 +225,7 @@ class DBShelf(DictMixin):
# given nothing is passed to the extension module. That way
# an exception can be raised if set_get_returns_none is turned
# off.
data = apply(self.db.get, args, kw)
data = self.db.get(*args, **kw)
try:
return cPickle.loads(data)
except (EOFError, TypeError, cPickle.UnpicklingError):
......@@ -294,7 +294,7 @@ class DBShelfCursor:
def get(self, *args):
count = len(args) # a method overloading hack
method = getattr(self, 'get_%d' % count)
apply(method, args)
method(*args)
def get_1(self, flags):
rec = self.dbc.get(flags)
......
......@@ -398,7 +398,7 @@ class bsdTableDB :
# column names
newcolumnlist = copy.copy(oldcolumnlist)
for c in columns:
if not oldcolumnhash.has_key(c):
if c not in oldcolumnhash:
newcolumnlist.append(c)
# store the table's new extended column list
......@@ -472,7 +472,7 @@ class bsdTableDB :
raise TableDBError, "unknown table"
# check the validity of each column name
if not self.__tablecolumns.has_key(table):
if not table in self.__tablecolumns:
self.__load_column_info(table)
for column in rowdict.keys() :
if not self.__tablecolumns[table].count(column):
......@@ -615,7 +615,7 @@ class bsdTableDB :
argument and returning a boolean.
"""
try:
if not self.__tablecolumns.has_key(table):
if table not in self.__tablecolumns:
self.__load_column_info(table)
if columns is None:
columns = self.__tablecolumns[table]
......@@ -639,7 +639,7 @@ class bsdTableDB :
argument and returning a boolean.
"""
# check the validity of each column name
if not self.__tablecolumns.has_key(table):
if not table in self.__tablecolumns:
self.__load_column_info(table)
if columns is None:
columns = self.tablecolumns[table]
......@@ -709,28 +709,24 @@ class bsdTableDB :
# extract the rowid from the key
rowid = key[-_rowid_str_len:]
if not rejected_rowids.has_key(rowid):
if not rowid in rejected_rowids:
# if no condition was specified or the condition
# succeeds, add row to our match list.
if not condition or condition(data):
if not matching_rowids.has_key(rowid):
if not rowid in matching_rowids:
matching_rowids[rowid] = {}
if savethiscolumndata:
matching_rowids[rowid][column] = data
else:
if matching_rowids.has_key(rowid):
if rowid in matching_rowids:
del matching_rowids[rowid]
rejected_rowids[rowid] = rowid
key, data = cur.next()
except db.DBError, dberror:
if sys.version_info[0] < 3 :
if dberror[0] != db.DB_NOTFOUND:
raise
else :
if dberror.args[0] != db.DB_NOTFOUND:
raise
if dberror.args[0] != db.DB_NOTFOUND:
raise
continue
cur.close()
......@@ -743,7 +739,7 @@ class bsdTableDB :
if len(columns) > 0:
for rowid, rowdata in matching_rowids.items():
for column in columns:
if rowdata.has_key(column):
if column in rowdata:
continue
try:
rowdata[column] = self.db.get(
......@@ -815,13 +811,10 @@ class bsdTableDB :
txn.commit()
txn = None
if self.__tablecolumns.has_key(table):
if table in self.__tablecolumns:
del self.__tablecolumns[table]
except db.DBError, dberror:
if txn:
txn.abort()
if sys.version_info[0] < 3 :
raise TableDBError, dberror[1]
else :
raise TableDBError, dberror.args[1]
raise TableDBError(dberror.args[1])
......@@ -61,7 +61,7 @@ def DeadlockWrap(function, *_args, **_kwargs):
"""
sleeptime = _deadlock_MinSleepTime
max_retries = _kwargs.get('max_retries', -1)
if _kwargs.has_key('max_retries'):
if 'max_retries' in _kwargs:
del _kwargs['max_retries']
while True:
try:
......
......@@ -707,8 +707,8 @@ class HTTPConnection:
if code != 200:
self.close()
raise socket.error, "Tunnel connection failed: %d %s" % (code,
message.strip())
raise socket.error("Tunnel connection failed: %d %s" % (code,
message.strip()))
while True:
line = response.fp.readline()
if line == '\r\n': break
......@@ -758,7 +758,7 @@ class HTTPConnection:
else:
self.sock.sendall(str)
except socket.error, v:
if v[0] == 32: # Broken pipe
if v.args[0] == 32: # Broken pipe
self.close()
raise
......@@ -914,7 +914,7 @@ class HTTPConnection:
self._send_request(method, url, body, headers)
except socket.error, v:
# trap 'Broken pipe' if we're allowed to automatically reconnect
if v[0] != 32 or not self.auto_open:
if v.args[0] != 32 or not self.auto_open:
raise
# try one more time
self._send_request(method, url, body, headers)
......
......@@ -100,7 +100,7 @@ def test_au(h, f):
else:
sample_bits = '?'
frame_size = sample_size * nchannels
return type, rate, nchannels, data_size/frame_size, sample_bits
return type, rate, nchannels, data_size//frame_size, sample_bits
tests.append(test_au)
......@@ -109,7 +109,7 @@ def test_hcom(h, f):
if h[65:69] != 'FSSD' or h[128:132] != 'HCOM':
return None
divisor = get_long_be(h[128+16:128+20])
return 'hcom', 22050/divisor, 1, -1, 8
return 'hcom', 22050//divisor, 1, -1, 8
tests.append(test_hcom)
......
......@@ -290,12 +290,16 @@ class _fileobject(object):
write_offset = 0
try:
while write_offset < data_size:
self._sock.sendall(buffer(data, write_offset, buffer_size))
with warnings.catch_warnings():
if sys.py3kwarning:
warnings.filterwarnings("ignore", ".*buffer",
DeprecationWarning)
self._sock.sendall(buffer(data, write_offset, buffer_size))
write_offset += buffer_size
finally:
if write_offset < data_size:
remainder = data[write_offset:]
del data # explicit free
del view, data # explicit free
self._wbuf.append(remainder)
self._wbuf_len = len(remainder)
......@@ -343,7 +347,7 @@ class _fileobject(object):
try:
data = self._sock.recv(rbufsize)
except error, e:
if e[0] == EINTR:
if e.args[0] == EINTR:
continue
raise
if not data:
......@@ -372,7 +376,7 @@ class _fileobject(object):
try:
data = self._sock.recv(left)
except error, e:
if e[0] == EINTR:
if e.args[0] == EINTR:
continue
raise
if not data:
......@@ -427,7 +431,7 @@ class _fileobject(object):
except error, e:
# The try..except to catch EINTR was moved outside the
# recv loop to avoid the per byte overhead.
if e[0] == EINTR:
if e.args[0] == EINTR:
continue
raise
break
......@@ -439,7 +443,7 @@ class _fileobject(object):
try:
data = self._sock.recv(self._rbufsize)
except error, e:
if e[0] == EINTR:
if e.args[0] == EINTR:
continue
raise
if not data:
......@@ -468,7 +472,7 @@ class _fileobject(object):
try:
data = self._sock.recv(self._rbufsize)
except error, e:
if e[0] == EINTR:
if e.args[0] == EINTR:
continue
raise
if not data:
......
......@@ -502,8 +502,8 @@ def uuid1(node=None, clock_seq=None):
nanoseconds = int(time.time() * 1e9)
# 0x01b21dd213814000 is the number of 100-ns intervals between the
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
timestamp = int(nanoseconds/100) + 0x01b21dd213814000L
if timestamp <= _last_timestamp:
timestamp = int(nanoseconds//100) + 0x01b21dd213814000L
if _last_timestamp is not None and timestamp <= _last_timestamp:
timestamp = _last_timestamp + 1
_last_timestamp = timestamp
if clock_seq is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment