Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frozenset bug. #12

Open
jonathanslenders opened this issue Sep 10, 2014 · 7 comments
Open

Frozenset bug. #12

jonathanslenders opened this issue Sep 10, 2014 · 7 comments

Comments

@jonathanslenders
Copy link

pprintpp.pprint({6,frozenset({78, 32, 342}),8})

fails with

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 94, in pprint
    printer.pprint(object)
  File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 236, in pprint
    self._format(object, state)
  File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 349, in _format
    self._format_nested_objects(object, state, typeish=typeish)
  File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 280, in _format_nested_objects
    oneline=True)
  File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 310, in _write_nested_real
    object = _sorted(object)
  File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 117, in _sorted
    return sorted(iterable)
TypeError: can only compare to a set

(I didn't had time to look further into this issue.)

@wolever
Copy link
Owner

wolever commented Sep 10, 2014

Weird. I can't recreate that on any of the supported Pythons (2.7, 3.3, PyPy). What's in the set?

@wolever
Copy link
Owner

wolever commented Sep 10, 2014

Disregard that, I'm an idiot. The issue is that sets can't be compared to non-set things. Testing for this also uncovered a related issue: python 3 gets fussy when trying to sort heterogeneous sets. Fix incoming!

@wolever
Copy link
Owner

wolever commented Sep 10, 2014

Okay! I've put https://github.com/wolever/safesort out there for comments, and I'll use it for sorting here too once I've got some confirmation that it's not a totally insane thing to do.

@jonathanslenders
Copy link
Author

ok, nice. :)
btw, is it impossible to establish without the exec in safesort?

@wolever
Copy link
Owner

wolever commented Sep 10, 2014

On 2014-09-10, at 1:56 PM, Jonathan Slenders notifications@github.com wrote:

ok, nice. :)
btw, is it impossible to establish without the exec in safesort?

Ya, safesort would definitely be possible to implement without exec; there would just be a lot of code duplication, or a pile of less performant function calls. What's the concern about it?=

@jonathanslenders
Copy link
Author

No real concern, it could be a valid use case. Only it feels like going back in time and have code preprocessors and macros like in C. :)

@wolever
Copy link
Owner

wolever commented Sep 10, 2014

On 2014-09-10, at 3:23 PM, Jonathan Slenders notifications@github.com wrote:

No real concern, it could be a valid use case. Only it feels like going back in time and have code preprocessors and macros like in C. :)

That is precisely what it is ;)

Python is wonderful for many things, but it does fall a bit short in preprocessing department :(=

wolever pushed a commit that referenced this issue Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants