When attempting to inspect a network-stream of underlying type SB-SYS:FD-STREAM I always get the following error:
Error: The value NIL is not of type PATHNAME.
I wrote a small patch to swank-fancy-inspector to ignore errors coming from accessing the pathname slot and not render the action link (visit file and show current position) when we do not have a pathname.
Cheers, Russ Tyndall Acceleration.net Software Developer
commit a26d435542936b2065b9d30e94df7bbed156a0e2 Author: Russ Tyndall russ@acceleration.net Date: Mon Jan 11 12:04:16 2010 -0500
Made swank-fancy-inspector NOT error when attempting to inspect network streams (due to their pathname being unbound)
diff --git a/contrib/swank-fancy-inspector.lisp b/contrib/swank-fancy-inspector.lisp index f68c6b0..f30e0c0 100644 --- a/contrib/swank-fancy-inspector.lisp +++ b/contrib/swank-fancy-inspector.lisp @@ -805,27 +805,29 @@ SPECIAL-OPERATOR groups." (defmethod emacs-inspect ((stream file-stream)) (multiple-value-bind (content) (call-next-method) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content))) + (let ((pathname (ignore-errors (pathname stream)))) + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (and (open-stream-p stream) pathname) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content))))
(defmethod emacs-inspect ((condition stream-error)) (multiple-value-bind (content) (call-next-method) - (let ((stream (stream-error-stream condition))) + (let* ((stream (stream-error-stream condition)) + (pathname (ignore-errors (pathname stream)))) (if (typep stream 'file-stream) (append `("Pathname: " - (:value ,(pathname stream)) + (:value ,pathname) (:newline) " " - ,@(when (open-stream-p stream) + ,@(when (and (open-stream-p stream) pathname) `((:action "[visit file and show current position]" ,(make-visit-file-thunk stream) :refreshp nil)
Russ Tyndall russ@acceleration.net writes:
When attempting to inspect a network-stream of underlying type SB-SYS:FD-STREAM I always get the following error:
Error: The value NIL is not of type PATHNAME.
I wrote a small patch to swank-fancy-inspector to ignore errors coming from accessing the pathname slot and not render the action link (visit file and show current position) when we do not have a pathname.
The actual issue is
https://bugs.launchpad.net/sbcl/+bug/310098
Cheers, Russ Tyndall Acceleration.net Software Developer
commit a26d435542936b2065b9d30e94df7bbed156a0e2 Author: Russ Tyndall russ@acceleration.net Date: Mon Jan 11 12:04:16 2010 -0500
Made swank-fancy-inspector NOT error when attempting to inspect network streams (due to their pathname being unbound)
diff --git a/contrib/swank-fancy-inspector.lisp b/contrib/swank-fancy-inspector.lisp index f68c6b0..f30e0c0 100644 --- a/contrib/swank-fancy-inspector.lisp +++ b/contrib/swank-fancy-inspector.lisp @@ -805,27 +805,29 @@ SPECIAL-OPERATOR groups." (defmethod emacs-inspect ((stream file-stream)) (multiple-value-bind (content) (call-next-method)
(append
`("Pathname: "
(:value ,(pathname stream))
(:newline) " "
,@(when (open-stream-p stream)
`((:action "[visit file and show current position]"
,(make-visit-file-thunk stream)
:refreshp nil)
(:newline))))
content)))
- (let ((pathname (ignore-errors (pathname stream))))
(append
`("Pathname: "
(:value ,pathname)
(:newline) " "
,@(when (and (open-stream-p stream) pathname)
`((:action "[visit file and show current position]"
,(make-visit-file-thunk stream)
:refreshp nil)
(:newline))))
content))))
(defmethod emacs-inspect ((condition stream-error)) (multiple-value-bind (content) (call-next-method)
- (let ((stream (stream-error-stream condition)))
- (let* ((stream (stream-error-stream condition))
(pathname (ignore-errors (pathname stream)))) (if (typep stream 'file-stream) (append `("Pathname: "
(:value ,(pathname stream))
(:value ,pathname) (:newline) " "
,@(when (open-stream-p stream)
,@(when (and (open-stream-p stream) pathname) `((:action "[visit file and show current position]" ,(make-visit-file-thunk stream) :refreshp nil)
(Is there something better than using IGNORE-ERRORS here?)
In case, PATHNAME signals an error, the "PATHNAME: ..." ispec should be omitted completely, I think.
-T.
Tobias C. Rittweiler wrote:
The actual issue is
https://bugs.launchpad.net/sbcl/+bug/310098
(Is there something better than using IGNORE-ERRORS here?)
In case, PATHNAME signals an error, the "PATHNAME: ..." ispec should be omitted completely, I think.
-T.
slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
Thanks for your feedback. I have incorporated it into a new (replacement) patch which handles only the specific errors I expect and entirely omits the pathname ispec. If you want/need me to make any further changes here, please let me know.
Cheers, Russ Tyndall Acceleration.net Software Developer
commit 84bb2155004ccfd601a402a464efd6fbcca44f17 Author: Russ Tyndall russ@acceleration.net Date: Mon Jan 11 12:04:16 2010 -0500
Made swank-fancy-inspector NOT error when attempting to inspect network streams (due to their pathname being unbound)
diff --git a/contrib/swank-fancy-inspector.lisp b/contrib/swank-fancy-inspector.lisp index f68c6b0..77d025a 100644 --- a/contrib/swank-fancy-inspector.lisp +++ b/contrib/swank-fancy-inspector.lisp @@ -802,35 +802,46 @@ SPECIAL-OPERATOR groups." (lambda () (ed-in-emacs `(,pathname :charpos ,position)))))
+(defun %safe-stream-pathname (stream) + (handler-case (pathname stream) + (type-error (c) + (unless (search "not of type pathname" + (string-downcase (princ-to-string c))) + (error c))))) + (defmethod emacs-inspect ((stream file-stream)) (multiple-value-bind (content) (call-next-method) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content))) + (let ((pathname (%safe-stream-pathname stream))) + (if pathname + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (open-stream-p stream) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content) + content))))
(defmethod emacs-inspect ((condition stream-error)) (multiple-value-bind (content) (call-next-method) - (let ((stream (stream-error-stream condition))) - (if (typep stream 'file-stream) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content) + (let* ((stream (stream-error-stream condition)) + (pathname (%safe-stream-pathname stream))) + (if (and (typep stream 'file-stream) pathname) + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (open-stream-p stream) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content) content))))
(defun common-seperated-spec (list &optional (callback (lambda (v)
Russ Tyndall russ@acceleration.net writes:
Tobias C. Rittweiler wrote:
The actual issue is
https://bugs.launchpad.net/sbcl/+bug/310098
(Is there something better than using IGNORE-ERRORS here?)
In case, PATHNAME signals an error, the "PATHNAME: ..." ispec should be omitted completely, I think.
-T.
slime-devel site list slime-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/slime-devel
Thanks for your feedback. I have incorporated it into a new (replacement) patch which handles only the specific errors I expect and entirely omits the pathname ispec. If you want/need me to make any further changes here, please let me know.
That's finally fixed on HEAD.
-T.
Tobias C. Rittweiler wrote:
(Is there something better than using IGNORE-ERRORS here?)
In my previous rewrite, I was checking a bit of the error text to try and limit it further than all type errors. After some more thought, I doubt that different implementations actually share error text verbiage, so I took out that check (which was probably ill-advised anyway).
Cheers and apologies for the preponderance of email, Russ Tyndall Acceleration.net Software Developer
commit f49253f2149f6f08b4202b5529f8ade299ac82b9 Author: Russ Tyndall russ@acceleration.net Date: Mon Jan 11 12:04:16 2010 -0500
Made swank-fancy-inspector NOT error when attempting to inspect network streams (due to their pathname being unbound)
diff --git a/contrib/swank-fancy-inspector.lisp b/contrib/swank-fancy-inspector.lisp index f68c6b0..77d025a 100644 --- a/contrib/swank-fancy-inspector.lisp +++ b/contrib/swank-fancy-inspector.lisp @@ -802,35 +802,46 @@ SPECIAL-OPERATOR groups." (lambda () (ed-in-emacs `(,pathname :charpos ,position)))))
+(defun %safe-stream-pathname (stream) + (handler-case (pathname stream) + (type-error (c) + (unless (search "not of type pathname" + (string-downcase (princ-to-string c))) + (error c))))) + (defmethod emacs-inspect ((stream file-stream)) (multiple-value-bind (content) (call-next-method) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content))) + (let ((pathname (%safe-stream-pathname stream))) + (if pathname + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (open-stream-p stream) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content) + content))))
(defmethod emacs-inspect ((condition stream-error)) (multiple-value-bind (content) (call-next-method) - (let ((stream (stream-error-stream condition))) - (if (typep stream 'file-stream) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content) + (let* ((stream (stream-error-stream condition)) + (pathname (%safe-stream-pathname stream))) + (if (and (typep stream 'file-stream) pathname) + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (open-stream-p stream) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content) content))))
(defun common-seperated-spec (list &optional (callback (lambda (v)
In my previous rewrite, I was checking a bit of the error text to try and limit it further than all type errors. After some more thought, I doubt that different implementations actually share error text verbiage, so I took out that check (which was probably ill-advised anyway).
I attached the wrong file. Sorry again
*face-palm*,
Russ Tyndall Acceleration.net Software Developer
commit a6758aed8083654c9e77523062f6a6ca26526856 Author: Russ Tyndall russ@acceleration.net Date: Mon Jan 11 12:04:16 2010 -0500
Made swank-fancy-inspector NOT error when attempting to inspect network streams (due to their pathname being unbound)
diff --git a/contrib/swank-fancy-inspector.lisp b/contrib/swank-fancy-inspector.lisp index f68c6b0..b38df7f 100644 --- a/contrib/swank-fancy-inspector.lisp +++ b/contrib/swank-fancy-inspector.lisp @@ -802,35 +802,44 @@ SPECIAL-OPERATOR groups." (lambda () (ed-in-emacs `(,pathname :charpos ,position)))))
+(defun %safe-stream-pathname (stream) + (handler-case (pathname stream) + (type-error (c) + (declare (ignore c))))) + (defmethod emacs-inspect ((stream file-stream)) (multiple-value-bind (content) (call-next-method) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content))) + (let ((pathname (%safe-stream-pathname stream))) + (if pathname + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (open-stream-p stream) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content) + content))))
(defmethod emacs-inspect ((condition stream-error)) (multiple-value-bind (content) (call-next-method) - (let ((stream (stream-error-stream condition))) - (if (typep stream 'file-stream) - (append - `("Pathname: " - (:value ,(pathname stream)) - (:newline) " " - ,@(when (open-stream-p stream) - `((:action "[visit file and show current position]" - ,(make-visit-file-thunk stream) - :refreshp nil) - (:newline)))) - content) + (let* ((stream (stream-error-stream condition)) + (pathname (%safe-stream-pathname stream))) + (if (and (typep stream 'file-stream) pathname) + (append + `("Pathname: " + (:value ,pathname) + (:newline) " " + ,@(when (open-stream-p stream) + `((:action "[visit file and show current position]" + ,(make-visit-file-thunk stream) + :refreshp nil) + (:newline)))) + content) content))))
(defun common-seperated-spec (list &optional (callback (lambda (v)