File tree 2 files changed +6
-6
lines changed
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -657,7 +657,7 @@ cdef class TextReader:
657
657
658
658
if isinstance (source, str ):
659
659
encoding = sys.getfilesystemencoding() or " utf-8"
660
-
660
+ usource = source
661
661
source = source.encode(encoding)
662
662
663
663
if self .memory_map:
@@ -677,10 +677,11 @@ cdef class TextReader:
677
677
678
678
if ptr == NULL :
679
679
if not os.path.exists(source):
680
+
680
681
raise FileNotFoundError(
681
682
ENOENT,
682
- f' File {source } does not exist' ,
683
- source )
683
+ f' File {usource } does not exist' ,
684
+ usource )
684
685
raise IOError (' Initializing from file failed' )
685
686
686
687
self .parser.source = ptr
Original file line number Diff line number Diff line change 2
2
Tests that work on both the Python and C engines but do not have a
3
3
specific classification into the other test modules.
4
4
"""
5
-
6
5
import codecs
7
6
from collections import OrderedDict
8
7
import csv
@@ -978,15 +977,15 @@ def test_path_local_path(all_parsers):
978
977
def test_nonexistent_path (all_parsers ):
979
978
# gh-2428: pls no segfault
980
979
# gh-14086: raise more helpful FileNotFoundError
980
+ # GH#29233 "File foo" instead of "File b'foo'"
981
981
parser = all_parsers
982
982
path = "{}.csv" .format (tm .rands (10 ))
983
983
984
- msg = " does not exist" if parser .engine == "c" else r"\[Errno 2\]"
984
+ msg = f"File { path } does not exist" if parser .engine == "c" else r"\[Errno 2\]"
985
985
with pytest .raises (FileNotFoundError , match = msg ) as e :
986
986
parser .read_csv (path )
987
987
988
988
filename = e .value .filename
989
- filename = filename .decode () if isinstance (filename , bytes ) else filename
990
989
991
990
assert path == filename
992
991
You can’t perform that action at this time.
0 commit comments