Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

data_readers.clj should contain a legal Clojure map, not an ad hoc da…

…ta structure
  • Loading branch information...
commit 28618bbfa870fcbd68cce36b531ca56b02df4a36 1 parent 4036c77
Stuart Halloway stuarthalloway authored

Showing 1 changed file with 23 additions and 20 deletions. Show diff stats Hide diff stats

  1. +23 20 src/clj/clojure/core.clj
43 src/clj/clojure/core.clj
@@ -6613,13 +6613,6 @@
6613 6613 (.. Thread currentThread getContextClassLoader
6614 6614 (getResources "data_readers.clj"))))
6615 6615
6616   -(defn- assert-symbol [^clojure.lang.LineNumberingPushbackReader reader x]
6617   - (when-not (symbol? x)
6618   - (throw (ex-info "non-symbol in data-reader file"
6619   - {:file *file*
6620   - :line (.getLineNumber reader)
6621   - :value x}))))
6622   -
6623 6616 (defn- data-reader-var [sym]
6624 6617 (intern (create-ns (symbol (namespace sym)))
6625 6618 (symbol (name sym))))
@@ -6629,18 +6622,24 @@
6629 6622 (java.io.InputStreamReader.
6630 6623 (.openStream url) "UTF-8"))]
6631 6624 (binding [*file* (.getFile url)]
6632   - (loop [mappings mappings]
6633   - (if-let [tag (read rdr false nil)]
6634   - (do (assert-symbol rdr tag)
6635   - (when (contains? mappings tag)
6636   - (throw (ex-info "Conflicting data-reader mapping"
6637   - {:file *file*
6638   - :line (.getLineNumber rdr)
6639   - :symbol tag})))
6640   - (let [target (read rdr true nil)]
6641   - (assert-symbol rdr target)
6642   - (recur (assoc mappings tag (data-reader-var target)))))
6643   - mappings)))))
  6625 + (let [new-mappings (read rdr false nil)]
  6626 + (when (not (map? new-mappings))
  6627 + (throw (ex-info (str "Not a valid data-reader map")
  6628 + {:url url})))
  6629 + (reduce
  6630 + (fn [m [k v]]
  6631 + (when (not (symbol? k))
  6632 + (throw (ex-info (str "Invalid form in data-reader file")
  6633 + {:url url
  6634 + :form k})))
  6635 + (when (contains? mappings k)
  6636 + (throw (ex-info "Conflicting data-reader mapping"
  6637 + {:url url
  6638 + :conflict k
  6639 + :mappings m})))
  6640 + (assoc m k (data-reader-var v)))
  6641 + mappings
  6642 + new-mappings)))))
6644 6643
6645 6644 (defn- load-data-readers []
6646 6645 (alter-var-root #'*data-readers*
@@ -6648,4 +6647,8 @@
6648 6647 (reduce load-data-reader-file
6649 6648 mappings (data-reader-urls)))))
6650 6649
6651   -(load-data-readers)
  6650 +(try
  6651 + (load-data-readers)
  6652 + (catch Throwable t
  6653 + (.printStackTrace t)
  6654 + (throw t)))

0 comments on commit 28618bb

Please sign in to comment.
Something went wrong with that request. Please try again.