Skip to content

Commit 7e64a28

Browse files
committed
replaced deprecated f'romstring' by 'frombuffer', this fixes issue #64
1 parent a47696a commit 7e64a28

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
because of 'async' becoming a keyword in Python 3.7
88
- replaced DataFrame.as_matrix() method (deprecated since Pandas 0.23.0) by
99
DataFrame.values
10+
- replaced numpy.fromstring method (deprecated since NumPy 1.14) by
11+
numpy.frombuffer
1012

1113
------------------------------------------------------------------------------
1214
qPython 1.3.0 [2017.03.xx]

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __getattr__(cls, name):
2929

3030
# workaround for building docs without numpy
3131
import numpy
32-
numpy.fromstring = lambda x, dtype: [None]
32+
numpy.frombuffer = lambda x, dtype: [None]
3333
numpy.ndarray = Mock
3434
# end-of-workaround
3535

doc/source/type-conversion.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ Please note that q ``null`` values are defined as::
370370
_QNULL2 = numpy.int16(-2**15)
371371
_QNULL4 = numpy.int32(-2**31)
372372
_QNULL8 = numpy.int64(-2**63)
373-
_QNAN32 = numpy.fromstring('\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
374-
_QNAN64 = numpy.fromstring('\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
373+
_QNAN32 = numpy.frombuffer('\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
374+
_QNAN64 = numpy.frombuffer('\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
375375
_QNULL_BOOL = numpy.bool_(False)
376376
_QNULL_SYM = numpy.string_('')
377377
_QNULL_GUID = uuid.UUID('00000000-0000-0000-0000-000000000000')

qpython/qreader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def read_data(self, message_size, is_compressed = False, **options):
200200
uncompressed_size = -8 + self._buffer.get_int()
201201
compressed_data = self._read_bytes(message_size - 12) if self._stream else self._buffer.raw(message_size - 12)
202202

203-
raw_data = numpy.fromstring(compressed_data, dtype = numpy.uint8)
203+
raw_data = numpy.frombuffer(compressed_data, dtype = numpy.uint8)
204204
if uncompressed_size <= 0:
205205
raise QReaderException('Error while data decompression.')
206206

@@ -296,7 +296,7 @@ def _read_list(self, qtype):
296296
return qlist(data, qtype = qtype, adjust_dtype = False)
297297
elif conversion:
298298
raw = self._buffer.raw(length * ATOM_SIZE[qtype])
299-
data = numpy.fromstring(raw, dtype = conversion)
299+
data = numpy.frombuffer(raw, dtype = conversion)
300300
if not self._is_native:
301301
data.byteswap(True)
302302

qpython/qtype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@
259259
_QNULL2 = numpy.int16(-2**15)
260260
_QNULL4 = numpy.int32(-2**31)
261261
_QNULL8 = numpy.int64(-2**63)
262-
_QNAN32 = numpy.fromstring(b'\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
263-
_QNAN64 = numpy.fromstring(b'\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
262+
_QNAN32 = numpy.frombuffer(b'\x00\x00\xc0\x7f', dtype=numpy.float32)[0]
263+
_QNAN64 = numpy.frombuffer(b'\x00\x00\x00\x00\x00\x00\xf8\x7f', dtype=numpy.float64)[0]
264264
_QNULL_BOOL = numpy.bool_(False)
265265
_QNULL_SYM = numpy.string_('')
266266
_QNULL_GUID = uuid.UUID('00000000-0000-0000-0000-000000000000')

0 commit comments

Comments
 (0)