You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Python 3.5, I can call scandir via a context manager where as under Python 2.7, I cannot.
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from os import scandir
>>> with scandir('/etc') as d:
... for entry in d:
... print(entry.name)
...
emond.d
ntp-restrict.conf
periodic
manpaths
services~previous
dnsextd.conf
(and many more files)
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from scandir import scandir
>>> with scandir('/etc') as d:
... for entry in d:
... print entry.name
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: __exit__
>>>
The text was updated successfully, but these errors were encountered:
And to clarify, here's a stack trace from a real program I'm having an issue with:
Traceback (most recent call last):
File "/Users/oogali/.../venv/bin/forwarder", line 11, in <module>
load_entry_point('forwarder', 'console_scripts', 'forwarder')()
File "/Users/oogali/.../forwarder/forwarder/__main__.py", line 12, in main
forwarder.run()
File "/Users/oogali/.../forwarder/forwarder/forwarder.py", line 46, in run
for spool_file in self.gather_files():
File "/Users/oogali/.../forwarder/forwarder/forwarder.py", line 30, in gather_files
with scandir(directory) as spool:
AttributeError: __exit__
Yes, you're right. This is a duplicate of #60 so I'll close this one -- basically none of the Python 3.6 additions have been back-ported to the scandir library. I don't have the time to incorporate these now (and it's becoming less and less important as Python 3.x takes over), but I'd welcome quality pull requests.
In Python 3.5, I can call
scandir
via a context manager where as under Python 2.7, I cannot.The text was updated successfully, but these errors were encountered: