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 mgorny
Recipients mgorny
Date 2018-01-06.00:38:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
While debugging PyPy test failure on backports.lzma [1], I've noticed that PySequence_Check() on a dict type raises TypeError, e.g.:

  Traceback (most recent call last):
    File "test/", line 273, in test_bad_args
      b"", format=lzma.FORMAT_RAW, filters={})
    File "/home/mgorny/git/backports.lzma/build/lib.linux-x86_64-3.6/backports/lzma/", line 463, in decompress
      decomp = LZMADecompressor(format, memlimit, filters)
  TypeError: object of type 'dict' has no len()

The relevant C code is:

  static int
  parse_filter_chain_spec(lzma_filter filters[], PyObject *filterspecs)
    Py_ssize_t i, num_filters;

    num_filters = PySequence_Length(filterspecs);

where filterspecs is the object corresponding to the {} dict in Python snippet.

According to the documentation [2], PySequence_Length() should be 'equivalent to the Python expression len(o).' The Python expression obviously does not raise TypeError:

  >>> len({})

Therefore, I think that the behavior of PySequence_Length() is a bug, and the function should successfully return the dict length instead.

Date User Action Args
2018-01-06 00:38:27mgornysetrecipients: + mgorny
2018-01-06 00:38:27mgornysetmessageid: <>
2018-01-06 00:38:27mgornylinkissue32500 messages
2018-01-06 00:38:27mgornycreate