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

String enums broke in 3.12.0 #185

Closed
WeirdCarrotMonster opened this issue Nov 6, 2017 · 7 comments
Closed

String enums broke in 3.12.0 #185

WeirdCarrotMonster opened this issue Nov 6, 2017 · 7 comments

Comments

@WeirdCarrotMonster
Copy link

from enum import Enum

class A(str, Enum):
    A = "a"
    B = "b"

with simplejson 3.11.1

>>> import simplejson
>>> simplejson.dumps(A.A)
'"a"'

with simplejson 3.12.0

>>> import simplejson
>>> simplejson.dumps(A.A)
'"A.A"'
@etrepum
Copy link
Member

etrepum commented Nov 6, 2017

That’s unusual, nothing changed in that code path. What version of Python is this?

@WeirdCarrotMonster
Copy link
Author

3.6.3

@felixonmars
Copy link
Collaborator

I cannot reproduce this with Python 3.6.3 and simplejson 3.12.0 here:

2017-11-06-233657-373d85

@serhiy-storchaka
Copy link
Contributor

Python implementation calls str() on the string subclass instance (and this can invoce the custom __str__ method), C implementation uses the string content directly.

       if type(s) is not text_type:
            s = text_type(s)

The json module is not affected.

@WeirdCarrotMonster
Copy link
Author

I've created a test case: https://github.com/WeirdCarrotMonster/simplejson-enum-test.git

@felixonmars There is no problem with archlinux package indeed. Maybe something wrong with PyPI version?

@WeirdCarrotMonster
Copy link
Author

Updated tests to check git version: everything works fine. Something is wrong with PyPI package.

@serhiy-storchaka
Copy link
Contributor

Seems there are two bugs here:

  1. There is a difference between Python and C implementations.
  2. C implementation isn't used in PyPI package.

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

4 participants