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

fix toDict issue of Literal null #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esprima/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

del U_CATEGORIES, UNICODE_LETTER, UNICODE_COMBINING_MARK
del UNICODE_DIGIT, UNICODE_CONNECTOR_PUNCTUATION
del DECIMAL_CONV, OCTAL_CONV, HEX_CONV
# del DECIMAL_CONV, OCTAL_CONV, HEX_CONV

class Character:
@staticmethod
Expand Down
7 changes: 6 additions & 1 deletion esprima/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ def visit_dict(self, obj):
v = yield item
k = unicode(k)
items.append((self.map.get(k, k), v))
yield Visited(dict(items))
items = dict(items)
if "type" in items.keys() and "raw" in items.keys() and items["type"] == 'Literal' and items["raw"] == "null":
items["value"] = None
if "type" in items.keys() and "raw" in items.keys() and items["type"] == 'Literal' and "regex" in items.keys() and type(items["value"]) == re.Pattern:
items["value"] = None
yield Visited(items)

def visit_SRE_Pattern(self, obj):
yield Visited({})