Clojure

pr-str and read-string don't handle @ symbols inside keywords properly

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Ubuntu 12.04 LTS; Java 1.7.0_05 Java HotSpot(TM) Client VM

Description

user=> (read-string (pr-str {(keyword "key@other") :stuff}))
RuntimeException Map literal must contain an even number of forms  clojure.lang.Util.runtimeException (Util.java:170)

pr-str emits "{:key@other :stuff}", which read-string fails to interpret correctly. Either pr-str needs to escape the @ symbol, or read-string needs to handle the symbol inside a keyword.

Background: I'm passing a map with email addresses as keys through Storm bolts, which require a thrift-serializable form. Using the pr-str/read-string combo fails on these keys, so I've fallen back to JSON serialization.

Activity

Stuart Halloway made changes -
Field Original Value New Value
Approval Vetted [ 10003 ]
Priority Major [ 3 ] Minor [ 4 ]
Issue Type Defect [ 1 ] Enhancement [ 4 ]
Rich Hickey made changes -
Approval Vetted [ 10003 ]
Alex Miller made changes -
Labels reader print reader

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: