Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

jupyter notebook 6.4.12 verson found a rename file bug, Please check utils.py code #707

Closed
einyboycode opened this issue Nov 23, 2022 · 3 comments

Comments

@einyboycode
Copy link

My jupyter version info:
!jupyter --version

IPython : 8.5.0
ipykernel : 6.15.1
ipywidgets : 7.7.1
jupyter_client : 7.3.4
jupyter_core : 4.11.1
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.6.6
nbconvert : 6.5.3
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : 5.3.1
traitlets : 5.4.0

my file name is: /home/nlp/bert/class_text/未命名.ipynb
It'will rename fail when try rename it.
Has bug code is is_hidden function in /home/nlp/anaconda3/envs/pydnlp/lib/python3.8/site-packages/notebook/utils.py
The key bug code is:

def is_hidden(abs_path, abs_root=''):
"""Is a file hidden or contained in a hidden directory?

This will start with the rightmost path element and work backwards to the
given root to see if a path is hidden or in a hidden directory. Hidden is
determined by either name starting with '.' or the UF_HIDDEN flag as
reported by stat.

If abs_path is the same directory as abs_root, it will be visible even if
that is a hidden folder. This only checks the visibility of files
and directories *within* abs_root.

Parameters
----------
abs_path : unicode
    The absolute path to check for hidden directories.
abs_root : unicode
    The absolute path of the root directory in which hidden directories
    should be checked for.
"""
if os.path.normpath(abs_path) == os.path.normpath(abs_root):
    return False

if is_file_hidden(abs_path):
    return True

########### bug code start
if not abs_root:
    abs_root = abs_path.split(os.sep, 1)[0] + os.sep
inside_root = abs_path[len(abs_root):]
if any(part.startswith('.') for part in inside_root.split(os.sep)):  
    return True

########### bug code end
.......

in my case:
abs_root is: /home/nlp/bert/
inside_root is: ".ipynb"
part is: .ipynb
part.startswith('.') will true, bug is trigger.

@RRosio
Copy link

RRosio commented Dec 2, 2022

Hi @einyboycode, I happened upon your issue by chance but I noticed it is an issue that is better suited for the Jupyter/Notebook repository rather than the here as this is the Jupyter Website repository. I also thought I could share that this issue has been brought up in the Notebook Repo and there is a PR in the works. Please feel free to contribute to the conversation there!

@JolisNzamb21st
Copy link

I had the same kind of bug when renaming the file in jupyter notebook and I got rid of it by simply finding all files with the same name as the one causing the error and deleting them and creating a new file in Jupyter notebook.

@JasonWeill
Copy link
Contributor

Thank you for your contributions! As @RRosio noted earlier, future issues about Jupyter Notebook should be filed in the Jupyter Noteboook repo: https://github.com/jupyter/notebook/issues/

This repo is for the Jupyter web site, not for a software product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants