Skip to content

Commit 327e6f0

Browse files
authored
Merge pull request #238 from jasongrout/hiddenwarning
Trigger warning when trying to check hidden file status on PyPy
2 parents 0983649 + c79b7e0 commit 327e6f0

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ See the `jupyter_core
1414
4.8 <https://github.com/jupyter/jupyter_core/milestone/20?closed=1>`__
1515
milestone on GitHub for the full list of pull requests and issues closed.
1616

17+
jupyter-core now has experimental support for PyPy (Python 3.7). Some features are known not to work due to limitations in PyPy, such as hidden file detection on Windows.
18+
1719
- Print an error message instead of an exception when a command is not found (:ghpull:`218`)
1820
- Return canonical path when using ``%APPDATA%`` on Windows (:ghpull:`222`)
1921
- Print full usage on missing or invalid commands (:ghpull:`225`)
2022
- Remove dependency on ``pywin32`` package on PyPy (:ghpull:`230`)
2123
- Update packages listed in ``jupyter --version`` (:ghpull:`232`)
2224
- Inherit base aliases/flags from traitlets Application, including ``--show-config`` from traitlets 5 (:ghpull:`233`)
25+
- Trigger warning when trying to check hidden file status on PyPy (:ghpull:`238`)
2326

2427
4.7
2528
---

jupyter_core/paths.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def is_file_hidden_win(abs_path, stat_res=None):
275275
# allow AttributeError on PyPy for Windows
276276
# 'stat_result' object has no attribute 'st_file_attributes'
277277
# https://foss.heptapod.net/pypy/pypy/-/issues/3469
278+
warnings.warn("hidden files are not detectable on this system, so no file will be marked as hidden.")
278279
pass
279280

280281
return False

jupyter_core/tests/test_paths.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313
import subprocess
1414
import sys
15+
import warnings
1516

1617
from jupyter_core import paths
1718
from jupyter_core.paths import (
@@ -260,10 +261,10 @@ def test_is_hidden():
260261

261262

262263
@pytest.mark.skipif(
263-
sys.platform != "win32" or "__pypy__" in sys.modules,
264-
reason="only run on windows/cpython: https://foss.heptapod.net/pypy/pypy/-/issues/3469"
264+
not (sys.platform == "win32" and (("__pypy__" not in sys.modules) or (sys.implementation.version >= (7, 3, 6)))),
265+
reason="only run on windows/cpython or pypy >= 7.3.6: https://foss.heptapod.net/pypy/pypy/-/issues/3469"
265266
)
266-
def test_is_hidden_win32():
267+
def test_is_hidden_win32_cpython():
267268
import ctypes
268269
with tempfile.TemporaryDirectory() as root:
269270
subdir1 = os.path.join(root, 'subdir')
@@ -273,6 +274,39 @@ def test_is_hidden_win32():
273274
assert is_hidden(subdir1, root)
274275
assert is_file_hidden(subdir1)
275276

277+
@pytest.mark.skipif(
278+
not (sys.platform == "win32" and "__pypy__" in sys.modules and sys.implementation.version < (7, 3, 6)),
279+
reason="only run on windows/pypy < 7.3.6: https://foss.heptapod.net/pypy/pypy/-/issues/3469"
280+
)
281+
def test_is_hidden_win32_pypy():
282+
import ctypes
283+
with tempfile.TemporaryDirectory() as root:
284+
subdir1 = os.path.join(root, 'subdir')
285+
os.makedirs(subdir1)
286+
assert not is_hidden(subdir1, root)
287+
subprocess.check_call(["attrib", "+h", subdir1])
288+
289+
with warnings.catch_warnings(record=True) as w:
290+
# Cause all warnings to always be triggered.
291+
warnings.simplefilter("always")
292+
# Trigger a warning.
293+
assert not is_hidden(subdir1, root)
294+
# Verify the warning was triggered
295+
assert len(w) == 1
296+
assert issubclass(w[-1].category, UserWarning)
297+
assert "hidden files are not detectable on this system" in str(w[-1].message)
298+
299+
with warnings.catch_warnings(record=True) as w:
300+
# Cause all warnings to always be triggered.
301+
warnings.simplefilter("always")
302+
# Trigger a warning.
303+
assert not is_file_hidden(subdir1)
304+
# Verify the warning was triggered
305+
assert len(w) == 1
306+
assert issubclass(w[-1].category, UserWarning)
307+
assert "hidden files are not detectable on this system" in str(w[-1].message)
308+
309+
276310

277311
@pytest.mark.skipif(sys.platform != "win32", reason="only runs on windows")
278312
def test_secure_write_win32():

0 commit comments

Comments
 (0)