This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sys.flags is missing bytes_warning
Type: behavior Stage:
Components: Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: brett.cannon, christian.heimes, schmir
Priority: high Keywords: patch

Created on 2008-05-08 10:19 by schmir, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bytes_warning.patch schmir, 2008-05-08 10:19 compute size with sizeof operator
Messages (9)
msg66411 - (view) Author: Ralf Schmitt (schmir) Date: 2008-05-08 10:19
sys.flags is missing bytes_warning:

Python 2.6a2+ (trunk, May  8 2008, 12:09:50) 
[GCC 4.2.3 (Debian 4.2.3-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> sys.flags
sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0,
inspect=0, interactive=0, optimize=0, dont_write_bytecode=0,
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0,
unicode=0)

This is only used from warnings.py currently:

~/pydev/trunk/ ack bytes_warning                                       
                                 
Lib/warnings.py
311:    bytes_warning = sys.flags.bytes_warning
312:    if bytes_warning > 1:
314:    elif bytes_warning:

Python/sysmodule.c
1172:	{"bytes_warning", "-b"},

(I only see an attribute error in frozen programs).

The attached patch fixes it by not using the sizeof operator to compute
the size of the array.

This gives:
>>> sys.flags
sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0,
inspect=0, interactive=0, optimize=0, dont_write_bytecode=0,
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0,
unicode=0, bytes_warning=0)
msg66412 - (view) Author: Ralf Schmitt (schmir) Date: 2008-05-08 10:23
brett, I added you to the nosy list, as you seem to have committed this
in r62303 (http://hgpy.de/py/trunk/rev/ac1ae32a476c)
msg66431 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-08 18:02
Ralf, can you do a ``make clean`` and then try again? I had this happen to 
me with an old checkout until I did that and then everything worked fine.
msg66435 - (view) Author: Ralf Schmitt (schmir) Date: 2008-05-08 19:58
sure, I even removed the whole source tree:
~/pydev/trunk/ ./python                                          
ralf@rat64 ok
Python 2.6a3+ (trunk, May  8 2008, 21:52:39) 
[GCC 4.2.3 (Debian 4.2.3-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> sys.flags
sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0,
inspect=0, interactive=0, optimize=0, dont_write_bytecode=0,
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0,
unicode=0)

You can count the entries manually if you don't believe. The given count
is off by one.
msg66438 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-08 20:25
Fixed in r62896.
msg66440 - (view) Author: Ralf Schmitt (schmir) Date: 2008-05-08 20:27
why not use sizeof? you'll probably run into this again..
msg66444 - (view) Author: Ralf Schmitt (schmir) Date: 2008-05-08 20:38
btw, I guess that sentinel entry in that array could also be removed?
msg66445 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-08 20:41
I didn't use sizeof because I didn't think of it; the solution to just 
change the numbers was right in front of me and I am swamped with other 
work so I went with what I knew would work.

As for removing the array, perhaps, but I don't have time to try that out.
msg66447 - (view) Author: Ralf Schmitt (schmir) Date: 2008-05-08 20:44
ok brett, I see in IRC you're doing lot's of commits currently. sorry
for bothering you. I'll maybe try myself, it's a minor issue anyway...
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47039
2008-05-08 20:44:02schmirsetmessages: + msg66447
2008-05-08 20:41:32brett.cannonsetmessages: + msg66445
2008-05-08 20:38:44schmirsetmessages: + msg66444
2008-05-08 20:27:37schmirsetmessages: + msg66440
2008-05-08 20:25:10brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg66438
2008-05-08 19:58:56schmirsetmessages: + msg66435
2008-05-08 18:02:25brett.cannonsetmessages: + msg66431
2008-05-08 17:10:49christian.heimessetpriority: high
assignee: christian.heimes
nosy: + christian.heimes
2008-05-08 10:23:47schmirsetnosy: + brett.cannon
messages: + msg66412
2008-05-08 10:19:59schmircreate