drop python 2.6 support
MODIFY
.travis.yml
.travis.yml
language: python
sudo: false
python:
- - 2.6
- 2.7
- 3.4
- 3.5

MODIFY
ChangeLog
ChangeLog
+2017-10-31 version 0.15.0
+* Remove Python 2.6 support (@scottbelden in PR #110)
+
2017-10-31 version 0.14.11
* Added fixed decimal type (@glgnohk in PR #106)
* Fix validation failure when writing nullable datetime.date (@theianrobertson in PR #109)

MODIFY
README.md
README.md
@@ -20,7 +20,6 @@ If the optional C extension (generated by [Cython][cython]) is available, then
`fastavro` supports the following Python versions:
-* Python 2.6
* Python 2.7
* Python 3.4
* Python 3.5

MODIFY
fastavro/__init__.py
fastavro/__init__.py
@@ -43,7 +43,7 @@ The only onterface function is iter_avro, example usage::
writer(out, schema, records)
'''
-__version_info__ = (0, 14, 11)
+__version_info__ = (0, 15, 0)
__version__ = '%s.%s.%s' % __version_info__

MODIFY
fastavro/reader.py
fastavro/reader.py
@@ -14,22 +14,26 @@ from decimal import localcontext, Decimal
from uuid import UUID
try:
- from fastavro._six import MemoryIO, xrange, btou, utob, iteritems,\
- is_str, str2ints, fstint
- from fastavro._schema import (
+ from ._six import (
+ MemoryIO, xrange, btou, utob, iteritems, is_str, str2ints, fstint
+ )
+ from ._schema import (
extract_record_type, acquaint_schema, populate_schema_defs,
extract_logical_type
)
except ImportError:
- from fastavro.six import MemoryIO, xrange, btou, utob, iteritems, \
- is_str, str2ints, fstint
- from fastavro.schema import (
+ from .six import (
+ MemoryIO, xrange, btou, utob, iteritems, is_str, str2ints, fstint
+ )
+ from .schema import (
extract_record_type, acquaint_schema, populate_schema_defs,
extract_logical_type
)
-from fastavro.const import MCS_PER_HOUR, MCS_PER_MINUTE, MCS_PER_SECOND, \
- MLS_PER_HOUR, MLS_PER_MINUTE, MLS_PER_SECOND, DAYS_SHIFT
+from .const import (
+ MCS_PER_HOUR, MCS_PER_MINUTE, MCS_PER_SECOND, MLS_PER_HOUR, MLS_PER_MINUTE,
+ MLS_PER_SECOND, DAYS_SHIFT
+)
VERSION = 1
MAGIC = b'Obj' + utob(chr(VERSION))
@@ -409,8 +413,7 @@ def read_record(fo, writer_schema, reader_schema=None):
for field in writer_schema['fields']:
record[field['name']] = read_data(fo, field['type'])
else:
- readers_field_dict = \
- dict((f['name'], f) for f in reader_schema['fields'])
+ readers_field_dict = {f['name']: f for f in reader_schema['fields']}
for field in writer_schema['fields']:
readers_field = readers_field_dict.get(field['name'])
if readers_field:
@@ -574,8 +577,9 @@ class iter_avro:
raise ValueError('cannot read header - is it an avro file?')
# `meta` values are bytes. So, the actual decoding has to be external.
- self.metadata = \
- dict((k, btou(v)) for k, v in iteritems(self._header['meta']))
+ self.metadata = {
+ k: btou(v) for k, v in iteritems(self._header['meta'])
+ }
self.schema = self.writer_schema = \
json.loads(self.metadata['avro.schema'])

MODIFY
fastavro/writer.py
fastavro/writer.py
# Apache 2.0 license (http://www.apache.org/licenses/LICENSE-2.0)
try:
- from fastavro._six import utob, MemoryIO, long, is_str, iteritems, mk_bits
- from fastavro._reader import HEADER_SCHEMA, SYNC_SIZE, MAGIC
- from fastavro._schema import extract_named_schemas_into_repo,\
- extract_record_type, extract_logical_type
+ from ._six import utob, MemoryIO, long, is_str, iteritems, mk_bits
+ from ._reader import HEADER_SCHEMA, SYNC_SIZE, MAGIC
+ from ._schema import (
+ extract_named_schemas_into_repo, extract_record_type,
+ extract_logical_type
+ )
except ImportError:
- from fastavro.six import utob, MemoryIO, long, is_str, iteritems, mk_bits
- from fastavro.reader import HEADER_SCHEMA, SYNC_SIZE, MAGIC
- from fastavro.schema import extract_named_schemas_into_repo,\
- extract_record_type, extract_logical_type
+ from .six import utob, MemoryIO, long, is_str, iteritems, mk_bits
+ from .reader import HEADER_SCHEMA, SYNC_SIZE, MAGIC
+ from .schema import (
+ extract_named_schemas_into_repo, extract_record_type,
+ extract_logical_type
+ )
-from fastavro.const import MCS_PER_HOUR, MCS_PER_MINUTE, MCS_PER_SECOND,\
- MLS_PER_HOUR, MLS_PER_MINUTE, MLS_PER_SECOND, DAYS_SHIFT
+from fastavro.const import (
+ MCS_PER_HOUR, MCS_PER_MINUTE, MCS_PER_SECOND, MLS_PER_HOUR, MLS_PER_MINUTE,
+ MLS_PER_SECOND, DAYS_SHIFT
+)
try:
@@ -115,10 +121,6 @@ def prepare_bytes_decimal(data, schema):
for digit in digits:
unscaled_datum = (unscaled_datum * 10) + digit
- # 2.6 support
- if not hasattr(unscaled_datum, 'bit_length'):
- bits_req = len(bin(abs(unscaled_datum))) - 2
- else:
bits_req = unscaled_datum.bit_length() + 1
if sign:
@@ -160,10 +162,6 @@ def prepare_fixed_decimal(data, schema):
for digit in digits:
unscaled_datum = (unscaled_datum * 10) + digit
- # 2.6 support
- if not hasattr(unscaled_datum, 'bit_length'):
- bits_req = len(bin(abs(unscaled_datum))) - 2
- else:
bits_req = unscaled_datum.bit_length() + 1
size_in_bits = size * 8
@@ -471,7 +469,7 @@ _base_types = [
'string',
]
-SCHEMA_DEFS = dict((typ, typ) for typ in _base_types)
+SCHEMA_DEFS = {typ: typ for typ in _base_types}
def write_data(fo, datum, schema):
@@ -502,8 +500,7 @@ def write_data(fo, datum, schema):
def write_header(fo, metadata, sync_marker):
header = {
'magic': MAGIC,
- 'meta': dict([(key, utob(value)) for key, value in
- iteritems(metadata)]),
+ 'meta': {key: utob(value) for key, value in iteritems(metadata)},
'sync': sync_marker
}
write_data(fo, header, HEADER_SCHEMA)

MODIFY
run-tests.sh
run-tests.sh
@@ -9,11 +9,8 @@ echo
find . -name '*.pyc' -exec rm {} \;
-pyver=$(python -c 'import sys; print("%s.%s" % sys.version_info[:2])')
-if [ "${pyver}" != "2.6" ]; then
echo "running flake8"
flake8 fastavro tests
-fi
check-manifest --ignore 'fastavro/_*.c'

MODIFY
tests/test_complex.py
tests/test_complex.py
@@ -83,7 +83,7 @@ def test_complex_schema():
'multi_union_time': datetime.datetime.now(),
'array_bytes_decimal': [Decimal("123.456")],
'array_fixed_decimal': [Decimal("123.456")],
- 'array_record': [dict(f1="1", f2=Decimal("123.456"))]
+ 'array_record': [{'f1': '1', 'f2': Decimal("123.456")}]
}
binary = serialize(schema, data1)
data2 = deserialize(schema, binary)
@@ -93,7 +93,7 @@ def test_complex_schema():
def test_complex_schema_nulls():
data1 = {
'array_string': ['a', "b", "c"],
- 'array_record': [dict(f1="1", f2=Decimal("123.456"))]
+ 'array_record': [{'f1': '1', 'f2': Decimal("123.456")}]
}
binary = serialize(schema, data1)
data2 = deserialize(schema, binary)

MODIFY
tests/test_str_py3.py
tests/test_str_py3.py
@@ -17,7 +17,7 @@ def test_str_py3():
keys = ['first', 'second', 'third', 'fourth']
- testdata = [dict((key, gen_id()) for key in keys) for _ in range(50)]
+ testdata = [{key: gen_id() for key in keys} for _ in range(50)]
schema = {
"fields": [{'name': key, 'type': 'string'} for key in keys],

MODIFY
tox.ini
tox.ini
[tox]
-envlist = py26,py27,py34,py35,pypy,pypy3,packaging
+envlist = py27,py34,py35,py36,pypy,pypy3,packaging
[testenv]
deps =

drop python 2.6 support