]> granicus.if.org Git - python/commitdiff
Add sys.flags.quiet attribute for the new -q option, as noted missing by Eric in...
authorGeorg Brandl <georg@python.org>
Tue, 28 Dec 2010 18:30:18 +0000 (18:30 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 28 Dec 2010 18:30:18 +0000 (18:30 +0000)
Doc/library/sys.rst
Include/pydebug.h
Misc/NEWS
Modules/main.c
Python/pythonrun.c
Python/sysmodule.c

index 6aaf10c461b14e51e6867d9a1512b863c495116f..d10defb3fad020b1cf730a29ae13a4ac9fc01820 100644 (file)
@@ -264,6 +264,11 @@ always available.
    +------------------------------+------------------------------------------+
    | :const:`bytes_warning`       | -b                                       |
    +------------------------------+------------------------------------------+
+   | :const:`quiet`               | -q                                       |
+   +------------------------------+------------------------------------------+
+
+   .. versionchanged:: 3.2
+      Added ``quiet`` attribute for the new :option:`-q` flag.
 
 
 .. data:: float_info
index 1cbb342e4731fa700a596e2c06eaff7f802108cb..70c88f67a1db0c8a11d205f8d6dfe678f1443ade 100644 (file)
@@ -7,6 +7,7 @@ extern "C" {
 
 PyAPI_DATA(int) Py_DebugFlag;
 PyAPI_DATA(int) Py_VerboseFlag;
+PyAPI_DATA(int) Py_QuietFlag;
 PyAPI_DATA(int) Py_InteractiveFlag;
 PyAPI_DATA(int) Py_InspectFlag;
 PyAPI_DATA(int) Py_OptimizeFlag;
index 674ae64c203d47a77d751ade0c7376fa78fb896c..f69abcf1d1a73e2b60b5cfae28b834d35b601a42 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,8 @@ Core and Builtins
 - Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
   encoding instead of UTF-8.
 
+- Add sys.flags attribute for the new -q command-line option.
+
 Library
 -------
 
index 3803eee73832582147e3149fef45e8f51508fff4..93d093dbb8b334e1819184388b3c2d29682966c2 100644 (file)
@@ -319,7 +319,6 @@ Py_Main(int argc, wchar_t **argv)
     int stdin_is_interactive = 0;
     int help = 0;
     int version = 0;
-    int quiet = 0;
     int saw_unbuffered_flag = 0;
     PyCompilerFlags cf;
 
@@ -427,7 +426,7 @@ Py_Main(int argc, wchar_t **argv)
             break;
 
         case 'q':
-            quiet++;
+            Py_QuietFlag++;
             break;
 
         /* This space reserved for other options */
@@ -594,7 +593,7 @@ Py_Main(int argc, wchar_t **argv)
 #endif
     Py_Initialize();
 
-    if (!quiet && (Py_VerboseFlag ||
+    if (!Py_QuietFlag && (Py_VerboseFlag ||
                         (command == NULL && filename == NULL &&
                          module == NULL && stdin_is_interactive))) {
         fprintf(stderr, "Python %s on %s\n",
index f7335a2b21d3666a244506c00b022c296aebe709..e3836b8b7c8eabdd6fb8c584e440fb2122eb675c 100644 (file)
@@ -78,6 +78,7 @@ extern void _PyGILState_Fini(void);
 
 int Py_DebugFlag; /* Needed by parser.c */
 int Py_VerboseFlag; /* Needed by import.c */
+int Py_QuietFlag; /* Needed by sysmodule.c */
 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
 int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */
 int Py_NoSiteFlag; /* Suppress 'import site' */
index 0a14f0eb36add9b8188485b251ae3ad26d21cbd4..730567eaf70e981138afffdc26d514833cb79045 100644 (file)
@@ -1417,7 +1417,8 @@ static PyStructSequence_Field flags_fields[] = {
 #endif
     /* {"unbuffered",                   "-u"}, */
     /* {"skip_first",                   "-x"}, */
-    {"bytes_warning", "-b"},
+    {"bytes_warning",           "-b"},
+    {"quiet",                   "-q"},
     {0}
 };
 
@@ -1461,6 +1462,7 @@ make_flags(void)
     /* SetFlag(saw_unbuffered_flag); */
     /* SetFlag(skipfirstline); */
     SetFlag(Py_BytesWarningFlag);
+    SetFlag(Py_QuietFlag);
 #undef SetFlag
 
     if (PyErr_Occurred()) {