This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients bob.ippolito, ezio.melotti, pitrou, rhettinger, serhiy.storchaka
Date 2013-08-13.11:18:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376392694.75.0.457946059126.issue18726@psf.upfronthosting.co.za>
In-reply-to
Content
The json module functions have too many positional parameters:

dump() -- 11
dumps() -- 10
load() -- 9
loads() -- 8

In most time only small part of these options is specified so users call these functions with keyword arguments for all parameters except mandatory ones.

Even worse, the simplejson module (an ancestor and an alternative to standard json module) have a very similar interface but with difference sequences of parameters (the second parameter of loads() and the ninth parameter of dumps() in simplejson is encoding). So in any case portable application should specify all but basic arguments as keyword arguments. If json will incorporate some features from simplejson in future positions of new parameters will be different.

I propose to deprecate specifying all but mandatory parameters of json functions as positional arguments in 3.4 and then forbid it in 3.5.

I.e. dumps() should be implemented in 3.4 as:

def dumps(obj, *args, **kwargs):
    if args:
        warnings.warn("The positional arguments are deprecated.",
                     DeprecationWarning, stacklevel=2)
    return _dumps(obj, *args, **kwargs)

def _dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
        allow_nan=True, cls=None, indent=None, separators=None,
        default=None, sort_keys=False, **kwargs):
    ...

and in 3.5 as:

def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
        allow_nan=True, cls=None, indent=None, separators=None,
        default=None, sort_keys=False, **kwargs):
    ...
History
Date User Action Args
2013-08-13 11:18:14serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, bob.ippolito, pitrou, ezio.melotti
2013-08-13 11:18:14serhiy.storchakasetmessageid: <1376392694.75.0.457946059126.issue18726@psf.upfronthosting.co.za>
2013-08-13 11:18:14serhiy.storchakalinkissue18726 messages
2013-08-13 11:18:14serhiy.storchakacreate