Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c4edb0ec
Kaydet (Commit)
c4edb0ec
authored
May 02, 2006
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF #1479181: split open() and file() from being aliases for each other.
üst
4bbf66e8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
17 deletions
+23
-17
libfuncs.tex
Doc/lib/libfuncs.tex
+5
-7
test_subprocess.py
Lib/test/test_subprocess.py
+2
-2
NEWS
Misc/NEWS
+2
-0
fileobject.c
Objects/fileobject.c
+0
-4
bltinmodule.c
Python/bltinmodule.c
+14
-4
No files found.
Doc/lib/libfuncs.tex
Dosyayı görüntüle @
c4edb0ec
...
@@ -455,12 +455,7 @@ class C:
...
@@ -455,12 +455,7 @@ class C:
after any I/O has been performed, and there's no reliable way to
after any I/O has been performed, and there's no reliable way to
determine whether this is the case.
}
determine whether this is the case.
}
The
\function
{
file()
}
constructor is new in Python 2.2 and is an
\versionadded
{
2.2
}
alias for
\function
{
open()
}
. Both spellings are equivalent. The
intent is for
\function
{
open()
}
to continue to be preferred for use
as a factory function which returns a new
\class
{
file
}
object. The
spelling,
\class
{
file
}
is more suited to type testing (for example,
writing
\samp
{
isinstance(f, file)
}
).
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
filter
}{
function, list
}
\begin{funcdesc}
{
filter
}{
function, list
}
...
@@ -725,7 +720,10 @@ class C:
...
@@ -725,7 +720,10 @@ class C:
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
open
}{
filename
\optional
{
, mode
\optional
{
, bufsize
}}}
\begin{funcdesc}
{
open
}{
filename
\optional
{
, mode
\optional
{
, bufsize
}}}
An alias for the
\function
{
file()
}
function above.
A wrapper for the
\function
{
file()
}
function above. The intent is
for
\function
{
open()
}
to be preferred for use as a factory function
returning a new
\class
{
file
}
object.
\class
{
file
}
is more suited to
type testing (for example, writing
\samp
{
isinstance(f, file)
}
).
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
ord
}{
c
}
\begin{funcdesc}
{
ord
}{
c
}
...
...
Lib/test/test_subprocess.py
Dosyayı görüntüle @
c4edb0ec
...
@@ -347,7 +347,7 @@ class ProcessTestCase(unittest.TestCase):
...
@@ -347,7 +347,7 @@ class ProcessTestCase(unittest.TestCase):
stdout
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
universal_newlines
=
1
)
universal_newlines
=
1
)
stdout
=
p
.
stdout
.
read
()
stdout
=
p
.
stdout
.
read
()
if
hasattr
(
open
,
'newlines'
):
if
hasattr
(
p
.
stdout
,
'newlines'
):
# Interpreter with universal newline support
# Interpreter with universal newline support
self
.
assertEqual
(
stdout
,
self
.
assertEqual
(
stdout
,
"line1
\n
line2
\n
line3
\n
line4
\n
line5
\n
line6"
)
"line1
\n
line2
\n
line3
\n
line4
\n
line5
\n
line6"
)
...
@@ -374,7 +374,7 @@ class ProcessTestCase(unittest.TestCase):
...
@@ -374,7 +374,7 @@ class ProcessTestCase(unittest.TestCase):
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
universal_newlines
=
1
)
universal_newlines
=
1
)
(
stdout
,
stderr
)
=
p
.
communicate
()
(
stdout
,
stderr
)
=
p
.
communicate
()
if
hasattr
(
open
,
'newlines'
):
if
hasattr
(
stdout
,
'newlines'
):
# Interpreter with universal newline support
# Interpreter with universal newline support
self
.
assertEqual
(
stdout
,
self
.
assertEqual
(
stdout
,
"line1
\n
line2
\n
line3
\n
line4
\n
line5
\n
line6"
)
"line1
\n
line2
\n
line3
\n
line4
\n
line5
\n
line6"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
c4edb0ec
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 2?
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 2?
Core and builtins
Core and builtins
-----------------
-----------------
- Patch #1479181: split open() and file() from being aliases for each other.
- Bug #1465834: '
bdist_wininst
preinstall
script
support
' was fixed
- Bug #1465834: '
bdist_wininst
preinstall
script
support
' was fixed
by converting these apis from macros into exported functions again:
by converting these apis from macros into exported functions again:
...
...
Objects/fileobject.c
Dosyayı görüntüle @
c4edb0ec
...
@@ -2025,10 +2025,6 @@ PyDoc_STR(
...
@@ -2025,10 +2025,6 @@ PyDoc_STR(
"'
\\
r', '
\\
n', '
\\
r
\\
n' or a tuple containing all the newline types seen.
\n
"
"'
\\
r', '
\\
n', '
\\
r
\\
n' or a tuple containing all the newline types seen.
\n
"
"
\n
"
"
\n
"
"'U' cannot be combined with 'w' or '+' mode.
\n
"
"'U' cannot be combined with 'w' or '+' mode.
\n
"
)
PyDoc_STR
(
"
\n
"
"Note: open() is an alias for file()."
);
);
PyTypeObject
PyFile_Type
=
{
PyTypeObject
PyFile_Type
=
{
...
...
Python/bltinmodule.c
Dosyayı görüntüle @
c4edb0ec
...
@@ -1341,6 +1341,18 @@ PyDoc_STRVAR(oct_doc,
...
@@ -1341,6 +1341,18 @@ PyDoc_STRVAR(oct_doc,
Return the octal representation of an integer or long integer."
);
Return the octal representation of an integer or long integer."
);
static
PyObject
*
builtin_open
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
return
PyObject_Call
((
PyObject
*
)
&
PyFile_Type
,
args
,
kwds
);
}
PyDoc_STRVAR
(
open_doc
,
"open(name[, mode[, buffering]]) -> file object
\n
\
\n
\
Open a file using the file() type, returns a file object."
);
static
PyObject
*
static
PyObject
*
builtin_ord
(
PyObject
*
self
,
PyObject
*
obj
)
builtin_ord
(
PyObject
*
self
,
PyObject
*
obj
)
{
{
...
@@ -2247,6 +2259,7 @@ static PyMethodDef builtin_methods[] = {
...
@@ -2247,6 +2259,7 @@ static PyMethodDef builtin_methods[] = {
{
"max"
,
(
PyCFunction
)
builtin_max
,
METH_VARARGS
|
METH_KEYWORDS
,
max_doc
},
{
"max"
,
(
PyCFunction
)
builtin_max
,
METH_VARARGS
|
METH_KEYWORDS
,
max_doc
},
{
"min"
,
(
PyCFunction
)
builtin_min
,
METH_VARARGS
|
METH_KEYWORDS
,
min_doc
},
{
"min"
,
(
PyCFunction
)
builtin_min
,
METH_VARARGS
|
METH_KEYWORDS
,
min_doc
},
{
"oct"
,
builtin_oct
,
METH_O
,
oct_doc
},
{
"oct"
,
builtin_oct
,
METH_O
,
oct_doc
},
{
"open"
,
(
PyCFunction
)
builtin_open
,
METH_VARARGS
|
METH_KEYWORDS
,
open_doc
},
{
"ord"
,
builtin_ord
,
METH_O
,
ord_doc
},
{
"ord"
,
builtin_ord
,
METH_O
,
ord_doc
},
{
"pow"
,
builtin_pow
,
METH_VARARGS
,
pow_doc
},
{
"pow"
,
builtin_pow
,
METH_VARARGS
,
pow_doc
},
{
"range"
,
builtin_range
,
METH_VARARGS
,
range_doc
},
{
"range"
,
builtin_range
,
METH_VARARGS
,
range_doc
},
...
@@ -2313,6 +2326,7 @@ _PyBuiltin_Init(void)
...
@@ -2313,6 +2326,7 @@ _PyBuiltin_Init(void)
#endif
#endif
SETBUILTIN
(
"dict"
,
&
PyDict_Type
);
SETBUILTIN
(
"dict"
,
&
PyDict_Type
);
SETBUILTIN
(
"enumerate"
,
&
PyEnum_Type
);
SETBUILTIN
(
"enumerate"
,
&
PyEnum_Type
);
SETBUILTIN
(
"file"
,
&
PyFile_Type
);
SETBUILTIN
(
"float"
,
&
PyFloat_Type
);
SETBUILTIN
(
"float"
,
&
PyFloat_Type
);
SETBUILTIN
(
"frozenset"
,
&
PyFrozenSet_Type
);
SETBUILTIN
(
"frozenset"
,
&
PyFrozenSet_Type
);
SETBUILTIN
(
"property"
,
&
PyProperty_Type
);
SETBUILTIN
(
"property"
,
&
PyProperty_Type
);
...
@@ -2329,10 +2343,6 @@ _PyBuiltin_Init(void)
...
@@ -2329,10 +2343,6 @@ _PyBuiltin_Init(void)
SETBUILTIN
(
"tuple"
,
&
PyTuple_Type
);
SETBUILTIN
(
"tuple"
,
&
PyTuple_Type
);
SETBUILTIN
(
"type"
,
&
PyType_Type
);
SETBUILTIN
(
"type"
,
&
PyType_Type
);
SETBUILTIN
(
"xrange"
,
&
PyRange_Type
);
SETBUILTIN
(
"xrange"
,
&
PyRange_Type
);
/* Note that open() is just an alias of file(). */
SETBUILTIN
(
"open"
,
&
PyFile_Type
);
SETBUILTIN
(
"file"
,
&
PyFile_Type
);
#ifdef Py_USING_UNICODE
#ifdef Py_USING_UNICODE
SETBUILTIN
(
"unicode"
,
&
PyUnicode_Type
);
SETBUILTIN
(
"unicode"
,
&
PyUnicode_Type
);
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment