jupyter/jupyter.github.io

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

einyboycode opened this issue · 3 comments

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.

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!

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.

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.