Skip to content

Commit

Permalink
drop optional simplejson requirement
Browse files Browse the repository at this point in the history
The json module in standard lib from python2.7 onward is good enough.
This change also removes the surprise since the setup.py will not
require simplejson if json is present, but at runtime simplejson is
preferred if it exists.
  • Loading branch information
markmcclain committed Sep 14, 2017
1 parent 58adc8e commit 6580cc2
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 32 deletions.
6 changes: 1 addition & 5 deletions pecan/jsonify.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
try:
from simplejson import JSONEncoder
except ImportError: # pragma: no cover
from json import JSONEncoder # noqa

from datetime import datetime, date
from decimal import Decimal
from json import JSONEncoder

# depending on the version WebOb might have 2 types of dicts
try:
Expand Down
7 changes: 1 addition & 6 deletions pecan/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1922,11 +1922,6 @@ def index(self, name='Jonathan'):
assert 'support for "mako3" was not found;' in str(expected)

def test_json(self):
try:
from simplejson import loads
except:
from json import loads # noqa

expected_result = dict(
name='Jonathan',
age=30, nested=dict(works=True)
Expand All @@ -1940,7 +1935,7 @@ def index(self):
app = TestApp(Pecan(RootController()))
r = app.get('/')
assert r.status_int == 200
result = dict(loads(r.body.decode()))
result = json.loads(r.body.decode())
assert result == expected_result

def test_custom_renderer(self):
Expand Down
5 changes: 1 addition & 4 deletions pecan/tests/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from json import dumps
from webtest import TestApp
try:
from simplejson import dumps
except:
from json import dumps # noqa

from six import b as b_

Expand Down
5 changes: 1 addition & 4 deletions pecan/tests/test_jsonify.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from datetime import datetime, date
from decimal import Decimal
try:
from simplejson import loads
except:
from json import loads # noqa
from json import loads
try:
from sqlalchemy import orm, schema, types
from sqlalchemy.engine import create_engine
Expand Down
6 changes: 1 addition & 5 deletions pecan/tests/test_rest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# -*- coding: utf-8 -*-

from json import dumps, loads
import unittest
import struct
import sys
import warnings

try:
from simplejson import dumps, loads
except:
from json import dumps, loads # noqa

from six import b as b_, PY3
from webtest import TestApp

Expand Down
8 changes: 0 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
if (line and not line.startswith('-'))
]

try:
import json # noqa
except:
try:
import simplejson # noqa
except:
requirements.append("simplejson >= 2.1.1")

try:
from functools import singledispatch # noqa
except:
Expand Down

0 comments on commit 6580cc2

Please sign in to comment.