Re: python-cjson package in F8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2008/9/14 Todd Zullinger <tmz@xxxxxxxxx>:
> Clodoaldo Pinto Neto wrote:
>> When i install cjson from the python-cjson 1.0.5 package from Fedora
>> 8 i get this error:
>>
>>>>> cjson.encode('é', encoding='utf8')
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in <module>
>> TypeError: encode() takes no keyword arguments
>>
>> But when installed from source it works:
>>
>>>>> cjson.encode('é', encoding='utf-8')
>> '"\\u00e9"'
>
> Are you installing the same version?

No. I messed it and installed 1.0.3 from source. In 1.0.3 it accepts
the keyword argument. I guess the keyword arguments do not exist
anymore. I tested 1.0.4 and it also does not work. Very weird. I guess
it can break code. I didn't find anything about it in Google. Is
someone one using cjson? The change log says nothing about keyword
arguments:

Changes in version 1.0.5
------------------------

  * Check if module initialization failed.
  * Removed useless checks on module initialization.
  * Added __version__ attribute to the cjson module.
  * Call Py_INCREF before calling PyModule_AddObject.

Changes in version 1.0.4
------------------------

  * Added licensing information.
  * Fixed issue with decrementing a string reference too early
    (Edouard Hinard <edouard.hinard@xxxxxxxxxxxxxxxxxx>).
  * Fixed 64-bit portability problems (based on a modified version of a
    patch by David Rushby <davidrushby@xxxxxxxxx>).
  * Fixed issue with not returning NULL after setting the OverflowError
    when encoded strings would be too big.
  * Fixed 2 potential buffer overflow errors when encoding string/unicode
    (thanks to Ofer Faigon <ofer3@xxxxxxxxxxxxxxxx> for pointing them out).
  * About 10% speed improvement when encoding/decoding string/unicode.

The help(cjson) in 1.0.3:

FUNCTIONS
    decode(...)
        decode(string, all_unicode=False, extension=None, encoding=None) ->
        parse the JSON representation into python objects.
        The optional argument `all_unicode', specifies how to
        convert the strings in the JSON representation into python objects.
        If it is False (default), it will return strings everywhere possible
        and unicode objects only where necessary, else it will return unicode
        objects everywhere (this is slower). The optional argument
        `extension' defines a function to decode objects not in the original
        JSON specification. For example this can be used to convert
        new Date(...) expressions to datetime.date objects. The extension
        function must have a two arguments: json, idx. The `json' argument
        receives the original JSON string under conversion. The `idx' argument
        receives the index of the first character of the substring to be
        parsed as an extended object. The extension function must return a
        2-tuple: (obj,count) or raise DecodeError if the string cannot be
        parsed to an extended object. `obj' must be the object parsed,
        `count' must be the (positive integer) number of characters consumed
        from the JSON string (length of the object's representation).
        All unicode strings will be encoded to the specified encoding
        automatically if encoding is not None. Unicode objects are returned
        if encoding is None (this is the default). It's encouraged to set
        all_unicode=True or define an encoding to prevent mixing of str and
        unicode objects in the decoder output.

    encode(...)
        encode(object, extension=None, key2str=False, encoding='ascii') ->
        generate the JSON representation for object. The optional argument
        `extension' defines a function to encode objects not in the original
        JSON specification. For example this can be used to convert
        datetime.date objects to new Date(...) expressions. The extension
        function must have a single argument and must return the JSON
        representation of the object passed or raise EncodeError if the
        object cannot be converted to JSON format. Automatically convert
        dictionary keys to str if key2str is True, otherwise EncodeError
        is raised whenever a non-str and non-unicode dictinary key is found.
        The encoding argument must specify the encoding used to decode
        python str objects.

Regards, Clodoaldo

>Quickly testing on F9 I get the
> TypeError with both the package and source installs.
>
> What is the output of:
>
> $ python -c 'import cjson; print cjson.__file__, cjson.__version__'
>
> for the packaged and source installs?

Package:
$ python -c 'import cjson; print cjson.__file__, cjson.__version__'
cjson.so 1.0.5
$ ll /usr/lib/python2.5/site-packages/cjson.so
-rwxr-xr-x 1 root root 15892 2008-04-07 21:39
/usr/lib/python2.5/site-packages/cjson.so

>>> cjson.encode('é', encoding='utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: encode() takes no keyword arguments

I'm sure it is package 1.0.5-1.fc8. I removed and installed again.

Then removed again and installed from source:

$ ll /usr/lib/python2.5/site-packages/cjson.so
-rwxr-xr-x 1 root root 41189 2008-09-14 13:06
/usr/lib/python2.5/site-packages/cjson.so

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux