Backport #8436
closed__dir__ not working in eval with binding
Description
Hello,
I think I might have found a bug concerning the new dir method.
Given binding (e.g. current top level binding) I would expect dir to return the directory I'm in, similarly to how FILE with binding does. Instead it returns nil.
I think I have found the solution, but since this is my first modification of Ruby code it might be inaccurate and not work in some cases. I hope it points to the right location though.
Please see attached patch along with a testcase showing the problem.
I also had to modify another testcase to use realpath when checking dir functionality, please check if it's correct.
Files
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r41306.
Dawid, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
vm_eval.c: dir in eval
- vm_eval.c (eval_string_with_cref): propagate absolute path from the
binding if it is given explicitly. patch by Gat (Dawid Janczak) at
[ruby-core:55123]. [Bug #8436]
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport200
- Status changed from Closed to Assigned
- Assignee set to nagachika (Tomoyuki Chikanaga)
r41305 and 41306.
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
r40759 and r40966 are also required.
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
- Status changed from Assigned to Closed
This issue was solved with changeset r41317.
Dawid, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) 40759,40966,41305,41306: [Backport #8436]
vm_eval.c: suppress warning
* vm_eval.c (eval_string_with_cref): narrow a variable scope into the
EXEC_TAG block to suppress -Wclobberd warning.
* vm_eval.c (eval_string_with_cref): propagate absolute path from the
binding if it is given explicitly. patch by Gat (Dawid Janczak) at
[ruby-core:55123]. [Bug #8436]
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
- Status changed from Closed to Assigned
add r41315.
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
- Status changed from Assigned to Closed
This issue was solved with changeset r41318.
Dawid, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) 41315: [Backport #8436]
vm_eval.c: suppress warning
* vm_eval.c (eval_string_with_cref): move absolute_path inside
non-exception block, since it is used only there. [Bug #8436]