Skip to content

merge json library with latest simplejson 2.0.x #48386

Closed

Description

@etrepum
mannequin
BPO 4136
Nosy @loewis, @birkenfeld, @rhettinger, @etrepum, @amauryfa, @pitrou, @tiran, @devdanzin, @benjaminp, @djc
Files
  • json_issue4136_r66961.diff: backport of simplejson 2.0.3 to json library
  • json_issue4136_r67009.diff: backport of simplejson 2.0.4 to json library
  • json_issue4136_r69662.diff: backport of simplejson-2.0.9 (r169, from trunk) to json library
  • json_issue4136_r69885.diff: backport of simplejson-2.0.9 to json library
  • json_py3k.patch
  • json_py3k-2.patch
  • json_py3k-3.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/etrepum'
    closed_at = <Date 2009-05-02.12:37:10.550>
    created_at = <Date 2008-10-16.22:08:48.956>
    labels = ['type-bug', 'library', 'release-blocker']
    title = 'merge json library with latest simplejson 2.0.x'
    updated_at = <Date 2009-05-02.12:37:10.131>
    user = 'https://github.com/etrepum'

    bugs.python.org fields:

    activity = <Date 2009-05-02.12:37:10.131>
    actor = 'benjamin.peterson'
    assignee = 'bob.ippolito'
    closed = True
    closed_date = <Date 2009-05-02.12:37:10.550>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2008-10-16.22:08:48.956>
    creator = 'bob.ippolito'
    dependencies = []
    files = ['11822', '11870', '13106', '13152', '13647', '13648', '13653']
    hgrepos = []
    issue_num = 4136
    keywords = ['patch']
    message_count = 51.0
    messages = ['74872', '74874', '74875', '74877', '74929', '74931', '74932', '74933', '74941', '74946', '74947', '75171', '78697', '79054', '79100', '82053', '82218', '82233', '82234', '82252', '82613', '82873', '82874', '82875', '82877', '82887', '82892', '82900', '82937', '83172', '83662', '83703', '83704', '83705', '83706', '83713', '83715', '83721', '85118', '85752', '85753', '85757', '85759', '85775', '85776', '85777', '85778', '85779', '85781', '85814', '86942']
    nosy_count = 10.0
    nosy_names = ['loewis', 'georg.brandl', 'rhettinger', 'bob.ippolito', 'amaury.forgeotdarc', 'pitrou', 'christian.heimes', 'ajaksu2', 'benjamin.peterson', 'djc']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'accepted'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4136'
    versions = ['Python 3.1']

    Activity

    1. etrepum commented on Oct 16, 2008

      etrepummannequin
      MannequinAuthor

      simplejson 2.0.3 includes major performance enhancements (both in Python
      and C) and removes usage of the private sre functionality.

      I will need some help with 3.0 since I am not well versed in the changes
      to the C API or Python code for that, but merging for 2.6.1 should be no
      big deal.

      How should I go about this?

    2. self-assigned this
      on Oct 16, 2008
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Oct 16, 2008
    4. vstinner commented on Oct 16, 2008

      @vstinner
      Member

      Can you write a patch against python trunk ? :-)

    5. etrepum commented on Oct 16, 2008

      etrepummannequin
      MannequinAuthor

      Sure, but that doesn't port it to Python 3.0 :)

    6. loewis commented on Oct 16, 2008

      loewismannequin
      Mannequin

      Sure, but that doesn't port it to Python 3.0 :)

      Still, as Victor suggests, the first step for porting it to 3.0
      definitely is to produce a patch for the trunk. What the next steps will
      be can be discussed when this step has been completed.

    7. etrepum commented on Oct 17, 2008

      etrepummannequin
      MannequinAuthor

      patch to r66961 of trunk is attached.

    8. amauryfa commented on Oct 17, 2008

      @amauryfa
      Contributor

      About the patch: are those lines really needed?

      + PyScannerType.tp_getattro = PyObject_GenericGetAttr;
      + PyScannerType.tp_setattro = PyObject_GenericSetAttr;
      + PyScannerType.tp_alloc = PyType_GenericAlloc;
      + PyScannerType.tp_new = PyType_GenericNew;
      + PyScannerType.tp_free = _PyObject_Del;

      I've never used them. What happens if the slots are left empty, and let PyType_Ready() do the rest?

    9. etrepum commented on Oct 17, 2008

      etrepummannequin
      MannequinAuthor

      You're probably right, I don't remember what code I was using as a
      template for that.

    10. etrepum commented on Oct 17, 2008

      etrepummannequin
      MannequinAuthor

      Actually, if I remove those lines from the equivalent module in simplejson
      it no longer works properly with Python 2.5.2.

      File "/Users/bob/src/simplejson/simplejson/decoder.py", line 307, in
      __init__
      self.scan_once = make_scanner(self)
      TypeError: cannot create 'make_scanner' instances

    11. loewis commented on Oct 17, 2008

      loewismannequin
      Mannequin

      Actually, if I remove those lines from the equivalent module in simplejson
      it no longer works properly with Python 2.5.2.

      Why aren't the functions pointers in the structs itself?

      As a procedural note, it seems like this patch is a complete rewrite of
      the module. Do you anticipate further complete rewrites within the next
      year? If yes, we should close the issue, and wait for the module to
      evolve. If no, I'll try to find some time to review the entire module -
      can you then please post the code to Rietveld?

    12. etrepum commented on Oct 17, 2008

      etrepummannequin
      MannequinAuthor

      I don't recall exactly why they aren't in the struct itself, it may not
      have worked with some compiler on some platform.

      It's not really a complete rewrite, the encoding path is largely the
      same and the tests haven't changed.

      Anyway, there is no further work planned for simplejson. It's done
      except for the potential for bug fixes. The only enhancements were
      performance related and this is about as fast as it's going to get. The
      majority of this work was ready before Python 2.6 was released but it
      was frozen so I couldn't get this in.

    13. etrepum commented on Oct 17, 2008

      etrepummannequin
      MannequinAuthor
    14. etrepum commented on Oct 24, 2008

      etrepummannequin
      MannequinAuthor

      Attached is a new diff, one byte fix to the float parser when parsing JSON
      documents that are just a float (also a test and a version bump).

    15. changed the title [-]merge json library with simplejson 2.0.3[/-] [+]merge json library with simplejson 2.0.4[/+] on Oct 24, 2008
    16. 34 remaining items

    17. benjaminp commented on Apr 7, 2009

      @benjaminp
      Contributor

      Here's a half-baked patch against py3k. It resolves all the conflicts
      but still has 15 failing tests. Perhaps someone would like to finish it up.

      For example, json.dumps(b"hi") works, but not json.dumps([b"hi", "hi"])

    18. pitrou commented on Apr 7, 2009

      @pitrou
      Member

      There is the problem in the current py3k version of json. b"hi" can be
      serialized, but not [b"hi"].

      >>> json.dumps(b"hi")
      '"hi"'
      >>> json.dumps([b"hi"])
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/home/antoine/py3k/__svn__/Lib/json/__init__.py", line 230, in dumps
          return _default_encoder.encode(obj)
        File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 367, in encode
          chunks = list(self.iterencode(o))
        File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 306, in
      _iterencode
          for chunk in self._iterencode_list(o, markers):
        File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 204, in
      _iterencode_list
          for chunk in self._iterencode(value, markers):
        File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 317, in
      _iterencode
          for chunk in self._iterencode_default(o, markers):
        File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 323, in
      _iterencode_default
          newobj = self.default(o)
        File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 344, in
      default
          raise TypeError(repr(o) + " is not JSON serializable")
      TypeError: b'hi' is not JSON serializable
    19. pitrou commented on Apr 7, 2009

      @pitrou
      Member

      Christian:

      1. in py3k, loads and dumps always seem to operate on/produce str
        objects, but encode_basestring_ascii returns a bytes object. Why is that?

      2. what is the use of the encoding argument in py3k? it looks completely
        ignored (bytes objects are not allowed as input and never produced as
        output)

    20. pitrou commented on Apr 8, 2009

      @pitrou
      Member

      Updated patch:

      • fixes all failures
      • removes bytes input and output "support" (which didn't work but still
        involved a lot of code)

      To be done:

      • remove all traces of the encoding argument, and associated machinery
    21. pitrou commented on Apr 8, 2009

      @pitrou
      Member

      Here is an updated patch, completely removing the encoding parameter
      and fixing docs.

    22. pitrou commented on Apr 8, 2009

      @pitrou
      Member

      (by the way, all tests pass)

    23. rhettinger commented on Apr 8, 2009

      @rhettinger
      Contributor

      It would be better to have a patch that diff's from the current 2.7
      version than to start with the 3.0 version; otherwise, the two will
      never be fully synchronized and some of the choices made in 2.6-to-3.0
      will live on forever. The 2.7 version reflects more patch review and
      real world usage (from simplejson) than the relatively unexercised 3.0
      version.

    24. pitrou commented on Apr 8, 2009

      @pitrou
      Member

      It would be better to have a patch that diff's from the current 2.7
      version than to start with the 3.0 version; otherwise, the two will
      never be fully synchronized and some of the choices made in 2.6-to-3.0
      will live on forever.

      How am I supposed to produce this patch?

    25. rhettinger commented on Apr 8, 2009

      @rhettinger
      Contributor

      The idea is to ignore the current 3.0 version and just redo the 2-to-3
      conversion from 2.7 and do it well this time. Compute the 3.1 patch as
      if the current 3.0 version was blown away (reverted).

    26. tiran commented on Apr 8, 2009

      @tiran
      Member

      +1 for Raymond's suggestion

      The 3.0 version of json was more like a last minute patch work than
      thorough work. You might wanna svn rm the 3.0 code, svn cp the 2.7 code
      to the py3k branch and start all over.

    27. djc commented on Apr 9, 2009

      @djc
      Contributor

      I'll take a stab at doing it Raymond's way this weekend.

    28. benjaminp commented on May 2, 2009

      @benjaminp
      Contributor

      Since no other patches were proposed, I applied Antoine's patch in r72194.

    29. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    release-blockerstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions