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
f31b69f9
Kaydet (Commit)
f31b69f9
authored
Ock 14, 2008
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Applied patch #1816: sys.flags patch
üst
620fbe66
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
5 deletions
+149
-5
sys.rst
Doc/library/sys.rst
+38
-0
test_sys.py
Lib/test/test_sys.py
+12
-0
NEWS
Misc/NEWS
+5
-2
sysmodule.c
Python/sysmodule.c
+94
-3
No files found.
Doc/library/sys.rst
Dosyayı görüntüle @
f31b69f9
...
@@ -240,6 +240,44 @@ always available.
...
@@ -240,6 +240,44 @@ always available.
Use :mod:`atexit` instead.
Use :mod:`atexit` instead.
.. data:: flags
The struct sequence *flags* exposes the status of command line flags. The
attributes are read only.
+------------------------------+------------------------------------------+
| attribute | flag |
+==============================+==========================================+
| :const:`debug` | -d |
+------------------------------+------------------------------------------+
| :const:`py3k_warning` | -3 |
+------------------------------+------------------------------------------+
| :const:`division_warning` | -Q |
+------------------------------+------------------------------------------+
| :const:`division_new` | -Qnew |
+------------------------------+------------------------------------------+
| :const:`inspect` | -i |
+------------------------------+------------------------------------------+
| :const:`interactive` | -i |
+------------------------------+------------------------------------------+
| :const:`optimize` | -O or -OO |
+------------------------------+------------------------------------------+
| :const:`dont_write_bytecode` | -B |
+------------------------------+------------------------------------------+
| :const:`no_site` | -S |
+------------------------------+------------------------------------------+
| :const:`ingnore_environment` | -E |
+------------------------------+------------------------------------------+
| :const:`tabcheck` | -t or -tt |
+------------------------------+------------------------------------------+
| :const:`verbose` | -v |
+------------------------------+------------------------------------------+
| :const:`unicode` | -U |
+------------------------------+------------------------------------------+
.. versionadded:: 2.6
.. data:: float_info
.. data:: float_info
A dict holding information about the float type. It contains low level
A dict holding information about the float type. It contains low level
...
...
Lib/test/test_sys.py
Dosyayı görüntüle @
f31b69f9
...
@@ -352,6 +352,18 @@ class SysModuleTest(unittest.TestCase):
...
@@ -352,6 +352,18 @@ class SysModuleTest(unittest.TestCase):
# the test runs under regrtest.
# the test runs under regrtest.
self
.
assert_
(
sys
.
__stdout__
.
encoding
==
sys
.
__stderr__
.
encoding
)
self
.
assert_
(
sys
.
__stdout__
.
encoding
==
sys
.
__stderr__
.
encoding
)
def
test_sys_flags
(
self
):
self
.
failUnless
(
sys
.
flags
)
attrs
=
(
"debug"
,
"py3k_warning"
,
"division_warning"
,
"division_new"
,
"inspect"
,
"interactive"
,
"optimize"
,
"dont_write_bytecode"
,
"no_site"
,
"ingnore_environment"
,
"tabcheck"
,
"verbose"
,
"unicode"
)
for
attr
in
attrs
:
self
.
assert_
(
hasattr
(
sys
.
flags
,
attr
),
attr
)
self
.
assertEqual
(
type
(
getattr
(
sys
.
flags
,
attr
)),
int
,
attr
)
self
.
assert_
(
repr
(
sys
.
flags
))
def
test_main
():
def
test_main
():
test
.
test_support
.
run_unittest
(
SysModuleTest
)
test
.
test_support
.
run_unittest
(
SysModuleTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
f31b69f9
...
@@ -12,8 +12,11 @@ What's New in Python 2.6 alpha 1?
...
@@ -12,8 +12,11 @@ What's New in Python 2.6 alpha 1?
Core and builtins
Core and builtins
-----------------
-----------------
- Object/structseq.c: Implemented new structseq representation. structseqs
- Patch #1816: Added sys.flags structseq. It exposes the status of most
like the return value of os.stat are more readable.
command line arguments and PYTHON* environment variables.
- Object/structseq.c: Implemented new structseq representation. The patch
makes structseqs (e.g. the return value of os.stat) more readable.
- Patch #1700288: added a type attribute cache that caches method accesses,
- Patch #1700288: added a type attribute cache that caches method accesses,
resulting in speedups in heavily object-oriented code.
resulting in speedups in heavily object-oriented code.
...
...
Python/sysmodule.c
Dosyayı görüntüle @
f31b69f9
...
@@ -15,6 +15,7 @@ Data members:
...
@@ -15,6 +15,7 @@ Data members:
*/
*/
#include "Python.h"
#include "Python.h"
#include "structseq.h"
#include "code.h"
#include "code.h"
#include "frameobject.h"
#include "frameobject.h"
#include "eval.h"
#include "eval.h"
...
@@ -1045,6 +1046,90 @@ Py_SubversionShortBranch()
...
@@ -1045,6 +1046,90 @@ Py_SubversionShortBranch()
return
shortbranch
;
return
shortbranch
;
}
}
PyDoc_STRVAR
(
flags__doc__
,
"sys.flags
\n
\
\n
\
Flags provided through command line arguments or environment vars."
);
static
PyTypeObject
FlagsType
;
static
PyStructSequence_Field
flags_fields
[]
=
{
{
"debug"
,
"-d"
},
{
"py3k_warning"
,
"-3"
},
{
"division_warning"
,
"-Q"
},
{
"division_new"
,
"-Qnew"
},
{
"inspect"
,
"-i"
},
{
"interactive"
,
"-i"
},
{
"optimize"
,
"-O or -OO"
},
{
"dont_write_bytecode"
,
"-B"
},
/* {"no_user_site", "-s"}, */
{
"no_site"
,
"-S"
},
{
"ingnore_environment"
,
"-E"
},
{
"tabcheck"
,
"-t or -tt"
},
{
"verbose"
,
"-v"
},
#ifdef RISCOS
{
"ricos_wimp"
,
"???"
},
#endif
/* {"unbuffered", "-u"}, */
{
"unicode"
,
"-U"
},
/* {"skip_first", "-x"}, */
{
0
}
};
static
PyStructSequence_Desc
flags_desc
=
{
"sys.flags"
,
/* name */
flags__doc__
,
/* doc */
flags_fields
,
/* fields */
#ifdef RISCOS
14
#else
13
#endif
};
static
PyObject
*
make_flags
(
void
)
{
int
pos
=
0
;
PyObject
*
seq
;
seq
=
PyStructSequence_New
(
&
FlagsType
);
if
(
seq
==
NULL
)
return
NULL
;
#define SetFlag(flag) \
PyStructSequence_SET_ITEM(seq, pos++, PyInt_FromLong(flag))
SetFlag
(
Py_DebugFlag
);
SetFlag
(
Py_Py3kWarningFlag
);
SetFlag
(
Py_DivisionWarningFlag
);
SetFlag
(
_Py_QnewFlag
);
SetFlag
(
Py_InspectFlag
);
SetFlag
(
Py_InteractiveFlag
);
SetFlag
(
Py_OptimizeFlag
);
SetFlag
(
Py_DontWriteBytecodeFlag
);
/* SetFlag(Py_NoUserSiteDirectory); */
SetFlag
(
Py_NoSiteFlag
);
SetFlag
(
Py_IgnoreEnvironmentFlag
);
SetFlag
(
Py_TabcheckFlag
);
SetFlag
(
Py_VerboseFlag
);
#ifdef RISCOS
SetFlag
(
Py_RISCOSWimpFlag
);
#endif
/* SetFlag(saw_unbuffered_flag); */
SetFlag
(
Py_UnicodeFlag
);
/* SetFlag(skipfirstline); */
#undef SetFlag
if
(
PyErr_Occurred
())
{
return
NULL
;
}
Py_INCREF
(
seq
);
return
seq
;
}
PyObject
*
PyObject
*
_PySys_Init
(
void
)
_PySys_Init
(
void
)
{
{
...
@@ -1128,9 +1213,9 @@ _PySys_Init(void)
...
@@ -1128,9 +1213,9 @@ _PySys_Init(void)
v
=
Py_BuildValue
(
"(ssz)"
,
"CPython"
,
branch
,
svn_revision
);
v
=
Py_BuildValue
(
"(ssz)"
,
"CPython"
,
branch
,
svn_revision
);
PyDict_SetItemString
(
sysdict
,
"subversion"
,
v
);
PyDict_SetItemString
(
sysdict
,
"subversion"
,
v
);
Py_XDECREF
(
v
);
Py_XDECREF
(
v
);
PyDict_SetItemString
(
sysdict
,
"dont_write_bytecode"
,
PyDict_SetItemString
(
sysdict
,
"dont_write_bytecode"
,
v
=
PyBool_FromLong
(
Py_DontWriteBytecodeFlag
));
v
=
PyBool_FromLong
(
Py_DontWriteBytecodeFlag
));
Py_XDECREF
(
v
);
Py_XDECREF
(
v
);
/*
/*
* These release level checks are mutually exclusive and cover
* These release level checks are mutually exclusive and cover
* the field, so don't get too fancy with the pre-processor!
* the field, so don't get too fancy with the pre-processor!
...
@@ -1211,6 +1296,12 @@ _PySys_Init(void)
...
@@ -1211,6 +1296,12 @@ _PySys_Init(void)
PyDict_SetItemString
(
sysdict
,
"warnoptions"
,
warnoptions
);
PyDict_SetItemString
(
sysdict
,
"warnoptions"
,
warnoptions
);
}
}
PyStructSequence_InitType
(
&
FlagsType
,
&
flags_desc
);
PyDict_SetItemString
(
sysdict
,
"flags"
,
make_flags
());
/* prevent user from creating new instances */
FlagsType
.
tp_init
=
NULL
;
FlagsType
.
tp_new
=
NULL
;
if
(
PyErr_Occurred
())
if
(
PyErr_Occurred
())
return
NULL
;
return
NULL
;
return
m
;
return
m
;
...
...
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