Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

dangling symlinks cause crash #22

Closed
wimglenn opened this issue Sep 14, 2018 · 1 comment
Closed

dangling symlinks cause crash #22

wimglenn opened this issue Sep 14, 2018 · 1 comment

Comments

@wimglenn
Copy link

When using PathSpec.match_tree, If there is a broken symlink encountered, we get unhandled exception. It's here:

https://github.com/cpburnz/python-path-specification/blob/da86e2c4d557df2d0a7cc9743268a7173d3a4828/pathspec/util.py#L68

I think you could fix it with os.lstat instead, but that's backwards incompat change.

Perhaps iter_tree could have an option to not follow symlinks? You could follow the example of os.walk, which accepts a followlinks keyword arg, and also an onerror callback which can be used to handle problems such as permission errors when stat each file.

@cpburnz
Copy link
Owner

cpburnz commented Sep 15, 2018

I've updated iter_tree to behave similar to os.walk but not identically. Dangling symlinks will now be ignored by default. I've added similar arguments:

  • on_error: behaves the same as os.walk.
  • follow_links: default is True instead of os.walk's False to maintain backwards compatibility of following links.

@cpburnz cpburnz closed this as completed Sep 15, 2018
bors bot added a commit to rehandalal/therapist that referenced this issue Oct 9, 2018
35: Update pathspec to 0.5.9 r=rehandalal a=pyup-bot


This PR updates [pathspec](https://pypi.org/project/pathspec) from **0.5.7** to **0.5.9**.



<details>
  <summary>Changelog</summary>
  
  
   ### 0.5.9
   ```
   ------------------

- Fixed file system error handling.
   ```
   
  
  
   ### 0.5.8
   ```
   ------------------

- Improved type checking.
- Created scripts to test Python 2.6 because Tox removed support for it.
- Improved byte string handling in Python 3.
- `Issue 22`_: Handle dangling symlinks.

.. _`Issue 22`: cpburnz/python-pathspec#22
   ```
   
  
</details>


 

<details>
  <summary>Links</summary>
  
  - PyPI: https://pypi.org/project/pathspec
  - Changelog: https://pyup.io/changelogs/pathspec/
  - Repo: https://github.com/cpburnz/python-path-specification
</details>



Co-authored-by: pyup-bot <github-bot@pyup.io>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants