[Python-3000-checkins] r55864 - in python/branches/p3yk: Lib/CGIHTTPServer.py Lib/_strptime.py Lib/anydbm.py Lib/bsddb/__init__.py Lib/bsddb/dbshelve.py Lib/bsddb/dbtables.py Lib/bsddb/test/test_1413192.py Lib/bsddb/test/test_basics.py Lib/bsddb/test/test_env_close.py Lib/bsddb/test/test_sequence.py Lib/dbhash.py Lib/distutils/ccompiler.py Lib/distutils/cmd.py Lib/distutils/command/build_scripts.py Lib/distutils/command/install_scripts.py Lib/distutils/command/register.py Lib/distutils/dir_util.py Lib/dumbdbm.py Lib/encodings/uu_codec.py Lib/imputil.py Lib/mailbox.py Lib/mhlib.py Lib/os.py Lib/plat-atheos/IN.py Lib/plat-mac/bundlebuilder.py Lib/plat-mac/macostools.py Lib/plat-sunos5/IN.py Lib/plat-sunos5/STROPTS.py Lib/plat-unixware7/IN.py Lib/plat-unixware7/STROPTS.py Lib/pty.py Lib/stat.py Lib/tarfile.py Lib/tempfile.py Lib/test/output/test_tokenize Lib/test/test_builtin.py Lib/test/test_compile.py Lib/test/test_descr.py Lib/test/test_dumbdbm.py Lib/test/test_format.py Lib/test/test_grammar.py Lib/test/test_hexoct.py Lib/test/test_long.py Lib/test/test_strptime.py Lib/test/test_subprocess.py Lib/test/test_tarfile.py Lib/test/test_tempfile.py Lib/test/test_unicode_file.py Lib/test/test_uu.py Lib/test/test_xmlrpc.py Lib/test/test_zipimport.py Lib/test/tokenize_tests.txt Lib/tokenize.py Lib/uu.py Misc/NEWS Objects/longobject.c Objects/stringobject.c Objects/unicodeobject.c Python/ast.c Python/mystrtoul.c setup.py
georg.brandl
python-3000-checkins at python.org
Mon Jun 11 00:30:21 CEST 2007
Author: georg.brandl
Date: Mon Jun 11 00:29:40 2007
New Revision: 55864
Modified:
python/branches/p3yk/Lib/CGIHTTPServer.py
python/branches/p3yk/Lib/_strptime.py
python/branches/p3yk/Lib/anydbm.py
python/branches/p3yk/Lib/bsddb/__init__.py
python/branches/p3yk/Lib/bsddb/dbshelve.py
python/branches/p3yk/Lib/bsddb/dbtables.py
python/branches/p3yk/Lib/bsddb/test/test_1413192.py
python/branches/p3yk/Lib/bsddb/test/test_basics.py
python/branches/p3yk/Lib/bsddb/test/test_env_close.py
python/branches/p3yk/Lib/bsddb/test/test_sequence.py
python/branches/p3yk/Lib/dbhash.py
python/branches/p3yk/Lib/distutils/ccompiler.py
python/branches/p3yk/Lib/distutils/cmd.py
python/branches/p3yk/Lib/distutils/command/build_scripts.py
python/branches/p3yk/Lib/distutils/command/install_scripts.py
python/branches/p3yk/Lib/distutils/command/register.py
python/branches/p3yk/Lib/distutils/dir_util.py
python/branches/p3yk/Lib/dumbdbm.py
python/branches/p3yk/Lib/encodings/uu_codec.py
python/branches/p3yk/Lib/imputil.py
python/branches/p3yk/Lib/mailbox.py
python/branches/p3yk/Lib/mhlib.py
python/branches/p3yk/Lib/os.py
python/branches/p3yk/Lib/plat-atheos/IN.py
python/branches/p3yk/Lib/plat-mac/bundlebuilder.py
python/branches/p3yk/Lib/plat-mac/macostools.py
python/branches/p3yk/Lib/plat-sunos5/IN.py
python/branches/p3yk/Lib/plat-sunos5/STROPTS.py
python/branches/p3yk/Lib/plat-unixware7/IN.py
python/branches/p3yk/Lib/plat-unixware7/STROPTS.py
python/branches/p3yk/Lib/pty.py
python/branches/p3yk/Lib/stat.py
python/branches/p3yk/Lib/tarfile.py
python/branches/p3yk/Lib/tempfile.py
python/branches/p3yk/Lib/test/output/test_tokenize
python/branches/p3yk/Lib/test/test_builtin.py
python/branches/p3yk/Lib/test/test_compile.py
python/branches/p3yk/Lib/test/test_descr.py
python/branches/p3yk/Lib/test/test_dumbdbm.py
python/branches/p3yk/Lib/test/test_format.py
python/branches/p3yk/Lib/test/test_grammar.py
python/branches/p3yk/Lib/test/test_hexoct.py
python/branches/p3yk/Lib/test/test_long.py
python/branches/p3yk/Lib/test/test_strptime.py
python/branches/p3yk/Lib/test/test_subprocess.py
python/branches/p3yk/Lib/test/test_tarfile.py
python/branches/p3yk/Lib/test/test_tempfile.py
python/branches/p3yk/Lib/test/test_unicode_file.py
python/branches/p3yk/Lib/test/test_uu.py
python/branches/p3yk/Lib/test/test_xmlrpc.py
python/branches/p3yk/Lib/test/test_zipimport.py
python/branches/p3yk/Lib/test/tokenize_tests.txt
python/branches/p3yk/Lib/tokenize.py
python/branches/p3yk/Lib/uu.py
python/branches/p3yk/Misc/NEWS
python/branches/p3yk/Objects/longobject.c
python/branches/p3yk/Objects/stringobject.c
python/branches/p3yk/Objects/unicodeobject.c
python/branches/p3yk/Python/ast.c
python/branches/p3yk/Python/mystrtoul.c
python/branches/p3yk/setup.py
Log:
PEP 3127: new octal literals, binary literals.
Modified: python/branches/p3yk/Lib/CGIHTTPServer.py
==============================================================================
--- python/branches/p3yk/Lib/CGIHTTPServer.py (original)
+++ python/branches/p3yk/Lib/CGIHTTPServer.py Mon Jun 11 00:29:40 2007
@@ -353,7 +353,7 @@
st = os.stat(path)
except os.error:
return False
- return st.st_mode & 0111 != 0
+ return st.st_mode & 0o111 != 0
def test(HandlerClass = CGIHTTPRequestHandler,
Modified: python/branches/p3yk/Lib/_strptime.py
==============================================================================
--- python/branches/p3yk/Lib/_strptime.py (original)
+++ python/branches/p3yk/Lib/_strptime.py Mon Jun 11 00:29:40 2007
@@ -107,7 +107,7 @@
# magical; just happened to have used it everywhere else where a
# static date was needed.
am_pm = []
- for hour in (01,22):
+ for hour in (1, 22):
time_tuple = time.struct_time((1999,3,17,hour,44,55,2,76,0))
am_pm.append(time.strftime("%p", time_tuple).lower())
self.am_pm = am_pm
Modified: python/branches/p3yk/Lib/anydbm.py
==============================================================================
--- python/branches/p3yk/Lib/anydbm.py (original)
+++ python/branches/p3yk/Lib/anydbm.py Mon Jun 11 00:29:40 2007
@@ -3,7 +3,7 @@
Instead of
import dbm
- d = dbm.open(file, 'w', 0666)
+ d = dbm.open(file, 'w', 0o666)
use
@@ -63,7 +63,7 @@
error = tuple(_errors)
-def open(file, flag = 'r', mode = 0666):
+def open(file, flag = 'r', mode = 0o666):
# guess the type of an existing database
from whichdb import whichdb
result=whichdb(file)
Modified: python/branches/p3yk/Lib/bsddb/__init__.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/__init__.py (original)
+++ python/branches/p3yk/Lib/bsddb/__init__.py Mon Jun 11 00:29:40 2007
@@ -294,7 +294,7 @@
#----------------------------------------------------------------------
# Compatibility object factory functions
-def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
+def hashopen(file, flag='c', mode=0o666, pgsize=None, ffactor=None, nelem=None,
cachesize=None, lorder=None, hflags=0):
flags = _checkflag(flag, file)
@@ -310,7 +310,7 @@
#----------------------------------------------------------------------
-def btopen(file, flag='c', mode=0666,
+def btopen(file, flag='c', mode=0o666,
btflags=0, cachesize=None, maxkeypage=None, minkeypage=None,
pgsize=None, lorder=None):
@@ -328,7 +328,7 @@
#----------------------------------------------------------------------
-def rnopen(file, flag='c', mode=0666,
+def rnopen(file, flag='c', mode=0o666,
rnflags=0, cachesize=None, pgsize=None, lorder=None,
rlen=None, delim=None, source=None, pad=None):
Modified: python/branches/p3yk/Lib/bsddb/dbshelve.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/dbshelve.py (original)
+++ python/branches/p3yk/Lib/bsddb/dbshelve.py Mon Jun 11 00:29:40 2007
@@ -40,7 +40,7 @@
#------------------------------------------------------------------------
-def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH,
+def open(filename, flags=db.DB_CREATE, mode=0o660, filetype=db.DB_HASH,
dbenv=None, dbname=None):
"""
A simple factory function for compatibility with the standard
Modified: python/branches/p3yk/Lib/bsddb/dbtables.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/dbtables.py (original)
+++ python/branches/p3yk/Lib/bsddb/dbtables.py Mon Jun 11 00:29:40 2007
@@ -134,9 +134,9 @@
class bsdTableDB :
- def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
+ def __init__(self, filename, dbhome, create=0, truncate=0, mode=0o600,
recover=0, dbflags=0):
- """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600)
+ """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0o600)
Open database name in the dbhome BerkeleyDB directory.
Use keyword arguments when calling this constructor.
Modified: python/branches/p3yk/Lib/bsddb/test/test_1413192.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_1413192.py (original)
+++ python/branches/p3yk/Lib/bsddb/test/test_1413192.py Mon Jun 11 00:29:40 2007
@@ -18,4 +18,4 @@
the_txn = env.txn_begin()
map = db.DB(env)
-map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0666, txn=the_txn)
+map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0o666, txn=the_txn)
Modified: python/branches/p3yk/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_basics.py (original)
+++ python/branches/p3yk/Lib/bsddb/test/test_basics.py Mon Jun 11 00:29:40 2007
@@ -44,7 +44,7 @@
dbtype = db.DB_UNKNOWN # must be set in derived class
dbopenflags = 0
dbsetflags = 0
- dbmode = 0660
+ dbmode = 0o660
dbname = None
useEnv = 0
envflags = 0
Modified: python/branches/p3yk/Lib/bsddb/test/test_env_close.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_env_close.py (original)
+++ python/branches/p3yk/Lib/bsddb/test/test_env_close.py Mon Jun 11 00:29:40 2007
@@ -50,10 +50,10 @@
dbenv = db.DBEnv()
dbenv.open(self.homeDir,
db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
- 0666)
+ 0o666)
d = db.DB(dbenv)
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+ d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0o666)
try:
dbenv.close()
@@ -75,10 +75,10 @@
dbenv = db.DBEnv()
dbenv.open(self.homeDir,
db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
- 0666)
+ 0o666)
d = db.DB(dbenv)
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+ d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0o666)
try:
dbenv.close()
Modified: python/branches/p3yk/Lib/bsddb/test/test_sequence.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_sequence.py (original)
+++ python/branches/p3yk/Lib/bsddb/test/test_sequence.py Mon Jun 11 00:29:40 2007
@@ -26,9 +26,9 @@
tempfile.tempdir = None
self.dbenv = db.DBEnv()
- self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666)
+ self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0o666)
self.d = db.DB(self.dbenv)
- self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0666)
+ self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0o666)
def tearDown(self):
if hasattr(self, 'seq'):
Modified: python/branches/p3yk/Lib/dbhash.py
==============================================================================
--- python/branches/p3yk/Lib/dbhash.py (original)
+++ python/branches/p3yk/Lib/dbhash.py Mon Jun 11 00:29:40 2007
@@ -12,5 +12,5 @@
error = bsddb.error # Exported for anydbm
-def open(file, flag = 'r', mode=0666):
+def open(file, flag = 'r', mode=0o666):
return bsddb.hashopen(file, flag, mode)
Modified: python/branches/p3yk/Lib/distutils/ccompiler.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/ccompiler.py (original)
+++ python/branches/p3yk/Lib/distutils/ccompiler.py Mon Jun 11 00:29:40 2007
@@ -1040,7 +1040,7 @@
def move_file (self, src, dst):
return move_file (src, dst, dry_run=self.dry_run)
- def mkpath (self, name, mode=0777):
+ def mkpath (self, name, mode=0o777):
mkpath (name, mode, self.dry_run)
Modified: python/branches/p3yk/Lib/distutils/cmd.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/cmd.py (original)
+++ python/branches/p3yk/Lib/distutils/cmd.py Mon Jun 11 00:29:40 2007
@@ -357,7 +357,7 @@
util.execute(func, args, msg, dry_run=self.dry_run)
- def mkpath (self, name, mode=0777):
+ def mkpath (self, name, mode=0o777):
dir_util.mkpath(name, mode, dry_run=self.dry_run)
Modified: python/branches/p3yk/Lib/distutils/command/build_scripts.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/command/build_scripts.py (original)
+++ python/branches/p3yk/Lib/distutils/command/build_scripts.py Mon Jun 11 00:29:40 2007
@@ -119,8 +119,8 @@
if self.dry_run:
log.info("changing mode of %s", file)
else:
- oldmode = os.stat(file)[ST_MODE] & 07777
- newmode = (oldmode | 0555) & 07777
+ oldmode = os.stat(file)[ST_MODE] & 0o7777
+ newmode = (oldmode | 0o555) & 0o7777
if newmode != oldmode:
log.info("changing mode of %s from %o to %o",
file, oldmode, newmode)
Modified: python/branches/p3yk/Lib/distutils/command/install_scripts.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/command/install_scripts.py (original)
+++ python/branches/p3yk/Lib/distutils/command/install_scripts.py Mon Jun 11 00:29:40 2007
@@ -53,7 +53,7 @@
if self.dry_run:
log.info("changing mode of %s", file)
else:
- mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
+ mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777
log.info("changing mode of %s to %o", file, mode)
os.chmod(file, mode)
Modified: python/branches/p3yk/Lib/distutils/command/register.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/command/register.py (original)
+++ python/branches/p3yk/Lib/distutils/command/register.py Mon Jun 11 00:29:40 2007
@@ -183,7 +183,7 @@
username, password))
f.close()
try:
- os.chmod(rc, 0600)
+ os.chmod(rc, 0o600)
except:
pass
elif choice == '2':
Modified: python/branches/p3yk/Lib/distutils/dir_util.py
==============================================================================
--- python/branches/p3yk/Lib/distutils/dir_util.py (original)
+++ python/branches/p3yk/Lib/distutils/dir_util.py Mon Jun 11 00:29:40 2007
@@ -18,7 +18,7 @@
# I don't use os.makedirs because a) it's new to Python 1.5.2, and
# b) it blows up if the directory already exists (I want to silently
# succeed in that case).
-def mkpath (name, mode=0777, verbose=0, dry_run=0):
+def mkpath (name, mode=0o777, verbose=0, dry_run=0):
"""Create a directory and any missing ancestor directories. If the
directory already exists (or if 'name' is the empty string, which
means the current directory, which of course exists), then do
@@ -85,7 +85,7 @@
# mkpath ()
-def create_tree (base_dir, files, mode=0777, verbose=0, dry_run=0):
+def create_tree (base_dir, files, mode=0o777, verbose=0, dry_run=0):
"""Create all the empty directories under 'base_dir' needed to
put 'files' there. 'base_dir' is just the a name of a directory
Modified: python/branches/p3yk/Lib/dumbdbm.py
==============================================================================
--- python/branches/p3yk/Lib/dumbdbm.py (original)
+++ python/branches/p3yk/Lib/dumbdbm.py Mon Jun 11 00:29:40 2007
@@ -219,7 +219,7 @@
self._os.chmod(file, self._mode)
-def open(file, flag=None, mode=0666):
+def open(file, flag=None, mode=0o666):
"""Open the database file, filename, and return corresponding object.
The flag argument, used to control how the database is opened in the
@@ -228,7 +228,7 @@
not exist.
The optional mode argument is the UNIX mode of the file, used only when
- the database has to be created. It defaults to octal code 0666 (and
+ the database has to be created. It defaults to octal code 0o666 (and
will be modified by the prevailing umask).
"""
Modified: python/branches/p3yk/Lib/encodings/uu_codec.py
==============================================================================
--- python/branches/p3yk/Lib/encodings/uu_codec.py (original)
+++ python/branches/p3yk/Lib/encodings/uu_codec.py Mon Jun 11 00:29:40 2007
@@ -12,7 +12,7 @@
### Codec APIs
-def uu_encode(input,errors='strict',filename='<data>',mode=0666):
+def uu_encode(input,errors='strict',filename='<data>',mode=0o666):
""" Encodes the object input and returns a tuple (output
object, length consumed).
@@ -31,7 +31,7 @@
write = outfile.write
# Encode
- write('begin %o %s\n' % (mode & 0777, filename))
+ write('begin %o %s\n' % (mode & 0o777, filename))
chunk = read(45)
while chunk:
write(b2a_uu(chunk))
Modified: python/branches/p3yk/Lib/imputil.py
==============================================================================
--- python/branches/p3yk/Lib/imputil.py (original)
+++ python/branches/p3yk/Lib/imputil.py Mon Jun 11 00:29:40 2007
@@ -476,7 +476,7 @@
s = _os_stat(pathname)
except OSError:
return None
- return (s.st_mode & 0170000) == 0040000
+ return (s.st_mode & 0o170000) == 0o040000
def _timestamp(pathname):
"Return the file modification time as a Long."
Modified: python/branches/p3yk/Lib/mailbox.py
==============================================================================
--- python/branches/p3yk/Lib/mailbox.py (original)
+++ python/branches/p3yk/Lib/mailbox.py Mon Jun 11 00:29:40 2007
@@ -227,10 +227,10 @@
Mailbox.__init__(self, dirname, factory, create)
if not os.path.exists(self._path):
if create:
- os.mkdir(self._path, 0700)
- os.mkdir(os.path.join(self._path, 'tmp'), 0700)
- os.mkdir(os.path.join(self._path, 'new'), 0700)
- os.mkdir(os.path.join(self._path, 'cur'), 0700)
+ os.mkdir(self._path, 0o700)
+ os.mkdir(os.path.join(self._path, 'tmp'), 0o700)
+ os.mkdir(os.path.join(self._path, 'new'), 0o700)
+ os.mkdir(os.path.join(self._path, 'cur'), 0o700)
else:
raise NoSuchMailboxError(self._path)
self._toc = {}
@@ -802,9 +802,9 @@
Mailbox.__init__(self, path, factory, create)
if not os.path.exists(self._path):
if create:
- os.mkdir(self._path, 0700)
+ os.mkdir(self._path, 0o700)
os.close(os.open(os.path.join(self._path, '.mh_sequences'),
- os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0600))
+ os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600))
else:
raise NoSuchMailboxError(self._path)
self._locked = False
Modified: python/branches/p3yk/Lib/mhlib.py
==============================================================================
--- python/branches/p3yk/Lib/mhlib.py (original)
+++ python/branches/p3yk/Lib/mhlib.py Mon Jun 11 00:29:40 2007
@@ -67,7 +67,7 @@
MH_PROFILE = '~/.mh_profile'
PATH = '~/Mail'
MH_SEQUENCES = '.mh_sequences'
-FOLDER_PROTECT = 0700
+FOLDER_PROTECT = 0o700
# Imported modules
Modified: python/branches/p3yk/Lib/os.py
==============================================================================
--- python/branches/p3yk/Lib/os.py (original)
+++ python/branches/p3yk/Lib/os.py Mon Jun 11 00:29:40 2007
@@ -147,8 +147,8 @@
# Super directory utilities.
# (Inspired by Eric Raymond; the doc strings are mostly his)
-def makedirs(name, mode=0777):
- """makedirs(path [, mode=0777])
+def makedirs(name, mode=0o777):
+ """makedirs(path [, mode=0o777])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
Modified: python/branches/p3yk/Lib/plat-atheos/IN.py
==============================================================================
--- python/branches/p3yk/Lib/plat-atheos/IN.py (original)
+++ python/branches/p3yk/Lib/plat-atheos/IN.py Mon Jun 11 00:29:40 2007
@@ -557,7 +557,7 @@
# Included from bits/dirent.h
def _D_ALLOC_NAMLEN(d): return (_D_EXACT_NAMLEN (d) + 1)
-def IFTODT(mode): return (((mode) & 0170000) >> 12)
+def IFTODT(mode): return (((mode) & 0o170000) >> 12)
def DTTOIF(dirtype): return ((dirtype) << 12)
@@ -567,17 +567,17 @@
MAXNAMLEN = 255
# Included from posix/stat.h
-S_IFMT = 00170000
-S_IFSOCK = 0140000
-S_IFLNK = 0120000
-S_IFREG = 0100000
-S_IFBLK = 0060000
-S_IFDIR = 0040000
-S_IFCHR = 0020000
-S_IFIFO = 0010000
-S_ISUID = 0004000
-S_ISGID = 0002000
-S_ISVTX = 0001000
+S_IFMT = 0o0170000
+S_IFSOCK = 0o140000
+S_IFLNK = 0o120000
+S_IFREG = 0o100000
+S_IFBLK = 0o060000
+S_IFDIR = 0o040000
+S_IFCHR = 0o020000
+S_IFIFO = 0o010000
+S_ISUID = 0o004000
+S_ISGID = 0o002000
+S_ISVTX = 0o001000
def S_ISLNK(m): return (((m) & S_IFMT) == S_IFLNK)
def S_ISREG(m): return (((m) & S_IFMT) == S_IFREG)
@@ -592,18 +592,18 @@
def S_ISSOCK(m): return (((m) & S_IFMT) == S_IFSOCK)
-S_IRWXU = 00700
-S_IRUSR = 00400
-S_IWUSR = 00200
-S_IXUSR = 00100
-S_IRWXG = 00070
-S_IRGRP = 00040
-S_IWGRP = 00020
-S_IXGRP = 00010
-S_IRWXO = 00007
-S_IROTH = 00004
-S_IWOTH = 00002
-S_IXOTH = 00001
+S_IRWXU = 0o0700
+S_IRUSR = 0o0400
+S_IWUSR = 0o0200
+S_IXUSR = 0o0100
+S_IRWXG = 0o0070
+S_IRGRP = 0o0040
+S_IWGRP = 0o0020
+S_IXGRP = 0o0010
+S_IRWXO = 0o0007
+S_IROTH = 0o0004
+S_IWOTH = 0o0002
+S_IXOTH = 0o0001
S_IRWXUGO = (S_IRWXU|S_IRWXG|S_IRWXO)
S_IALLUGO = (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH)
@@ -612,24 +612,24 @@
_STAT_VER_KERNEL = 0
# Included from posix/fcntl.h
-O_ACCMODE = 0003
+O_ACCMODE = 0o003
O_RWMASK = O_ACCMODE
O_RDONLY = 00
-O_WRONLY = 01
-O_RDWR = 02
-O_CREAT = 0100
-O_EXCL = 0200
-O_NOCTTY = 0400
-O_TRUNC = 01000
-O_APPEND = 02000
-O_NONBLOCK = 04000
+O_WRONLY = 0o1
+O_RDWR = 0o2
+O_CREAT = 0o100
+O_EXCL = 0o200
+O_NOCTTY = 0o400
+O_TRUNC = 0o1000
+O_APPEND = 0o2000
+O_NONBLOCK = 0o4000
O_NDELAY = O_NONBLOCK
-O_SYNC = 010000
+O_SYNC = 0o10000
O_FSYNC = O_SYNC
-O_ASYNC = 020000
+O_ASYNC = 0o20000
FASYNC = O_ASYNC
-O_DIRECTORY = 040000
-O_NOTRAVERSE = 0100000
+O_DIRECTORY = 0o40000
+O_NOTRAVERSE = 0o100000
O_NOFOLLOW = O_NOTRAVERSE
F_DUPFD = 0
F_GETFD = 1
Modified: python/branches/p3yk/Lib/plat-mac/bundlebuilder.py
==============================================================================
--- python/branches/p3yk/Lib/plat-mac/bundlebuilder.py (original)
+++ python/branches/p3yk/Lib/plat-mac/bundlebuilder.py Mon Jun 11 00:29:40 2007
@@ -504,7 +504,7 @@
standalone = self.standalone
semi_standalone = self.semi_standalone
open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals())
- os.chmod(bootstrappath, 0775)
+ os.chmod(bootstrappath, 0o775)
if self.iconfile is not None:
iconbase = os.path.basename(self.iconfile)
@@ -603,7 +603,7 @@
walk(path)
else:
mod = os.stat(path)[stat.ST_MODE]
- if not (mod & 0100):
+ if not (mod & 0o100):
continue
relpath = path[len(self.bundlepath):]
self.message("Stripping %s" % relpath, 2)
Modified: python/branches/p3yk/Lib/plat-mac/macostools.py
==============================================================================
--- python/branches/p3yk/Lib/plat-mac/macostools.py (original)
+++ python/branches/p3yk/Lib/plat-mac/macostools.py Mon Jun 11 00:29:40 2007
@@ -61,7 +61,7 @@
if os.sep == ':' and not ':' in head:
head = head + ':'
mkdirs(head)
- os.mkdir(dst, 0777)
+ os.mkdir(dst, 0o777)
def touched(dst):
"""Tell the finder a file has changed. No-op on MacOSX."""
Modified: python/branches/p3yk/Lib/plat-sunos5/IN.py
==============================================================================
--- python/branches/p3yk/Lib/plat-sunos5/IN.py (original)
+++ python/branches/p3yk/Lib/plat-sunos5/IN.py Mon Jun 11 00:29:40 2007
@@ -97,7 +97,7 @@
NZERO = 20
NULL = 0
NULL = 0
-CMASK = 022
+CMASK = 0o22
CDLIMIT = (1<<11)
NBPS = 0x20000
NBPSCTR = 512
@@ -733,13 +733,13 @@
_XRS_ID = 0x78727300
GETCONTEXT = 0
SETCONTEXT = 1
-UC_SIGMASK = 001
-UC_STACK = 002
-UC_CPU = 004
-UC_MAU = 010
+UC_SIGMASK = 0o01
+UC_STACK = 0o02
+UC_CPU = 0o04
+UC_MAU = 0o10
UC_FPU = UC_MAU
-UC_INTR = 020
-UC_ASR = 040
+UC_INTR = 0o20
+UC_ASR = 0o40
UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR)
UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
_SIGQUEUE_MAX = 32
@@ -1021,14 +1021,14 @@
AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME)
AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
AT_BLKSIZE|AT_NBLOCKS|AT_VCODE)
-VSUID = 04000
-VSGID = 02000
-VSVTX = 01000
-VREAD = 00400
-VWRITE = 00200
-VEXEC = 00100
-MODEMASK = 07777
-PERMMASK = 00777
+VSUID = 0o4000
+VSGID = 0o2000
+VSVTX = 0o1000
+VREAD = 0o0400
+VWRITE = 0o0200
+VEXEC = 0o0100
+MODEMASK = 0o7777
+PERMMASK = 0o0777
def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID)
VSA_ACL = 0x0001
Modified: python/branches/p3yk/Lib/plat-sunos5/STROPTS.py
==============================================================================
--- python/branches/p3yk/Lib/plat-sunos5/STROPTS.py (original)
+++ python/branches/p3yk/Lib/plat-sunos5/STROPTS.py Mon Jun 11 00:29:40 2007
@@ -94,7 +94,7 @@
NZERO = 20
NULL = 0
NULL = 0
-CMASK = 022
+CMASK = 0o22
CDLIMIT = (1<<11)
NBPS = 0x20000
NBPSCTR = 512
@@ -730,13 +730,13 @@
_XRS_ID = 0x78727300
GETCONTEXT = 0
SETCONTEXT = 1
-UC_SIGMASK = 001
-UC_STACK = 002
-UC_CPU = 004
-UC_MAU = 010
+UC_SIGMASK = 0o01
+UC_STACK = 0o02
+UC_CPU = 0o04
+UC_MAU = 0o10
UC_FPU = UC_MAU
-UC_INTR = 020
-UC_ASR = 040
+UC_INTR = 0o20
+UC_ASR = 0o40
UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR)
UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
_SIGQUEUE_MAX = 32
@@ -1400,14 +1400,14 @@
AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME)
AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
AT_BLKSIZE|AT_NBLOCKS|AT_VCODE)
-VSUID = 04000
-VSGID = 02000
-VSVTX = 01000
-VREAD = 00400
-VWRITE = 00200
-VEXEC = 00100
-MODEMASK = 07777
-PERMMASK = 00777
+VSUID = 0o4000
+VSGID = 0o2000
+VSVTX = 0o1000
+VREAD = 0o0400
+VWRITE = 0o0200
+VEXEC = 0o0100
+MODEMASK = 0o7777
+PERMMASK = 0o0777
def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID)
VSA_ACL = 0x0001
Modified: python/branches/p3yk/Lib/plat-unixware7/IN.py
==============================================================================
--- python/branches/p3yk/Lib/plat-unixware7/IN.py (original)
+++ python/branches/p3yk/Lib/plat-unixware7/IN.py Mon Jun 11 00:29:40 2007
@@ -187,8 +187,8 @@
NC_TPI_COTS_ORD = 3
NC_TPI_RAW = 4
NC_NOFLAG = 00
-NC_VISIBLE = 01
-NC_BROADCAST = 02
+NC_VISIBLE = 0o1
+NC_BROADCAST = 0o2
NC_NOPROTOFMLY = "-"
NC_LOOPBACK = "loopback"
NC_INET = "inet"
Modified: python/branches/p3yk/Lib/plat-unixware7/STROPTS.py
==============================================================================
--- python/branches/p3yk/Lib/plat-unixware7/STROPTS.py (original)
+++ python/branches/p3yk/Lib/plat-unixware7/STROPTS.py Mon Jun 11 00:29:40 2007
@@ -65,41 +65,41 @@
ES_MACADTLID = 7
ES_PRVID = 8
ES_TPGETMAJOR = 9
-SA_EXEC = 001
-SA_WRITE = 002
-SA_READ = 004
-SA_SUBSIZE = 010
+SA_EXEC = 0o01
+SA_WRITE = 0o02
+SA_READ = 0o04
+SA_SUBSIZE = 0o10
# Included from sys/stropts_f.h
X_STR = (ord('S')<<8)
-X_I_BASE = (X_STR|0200)
-X_I_NREAD = (X_STR|0201)
-X_I_PUSH = (X_STR|0202)
-X_I_POP = (X_STR|0203)
-X_I_LOOK = (X_STR|0204)
-X_I_FLUSH = (X_STR|0205)
-X_I_SRDOPT = (X_STR|0206)
-X_I_GRDOPT = (X_STR|0207)
-X_I_STR = (X_STR|0210)
-X_I_SETSIG = (X_STR|0211)
-X_I_GETSIG = (X_STR|0212)
-X_I_FIND = (X_STR|0213)
-X_I_LINK = (X_STR|0214)
-X_I_UNLINK = (X_STR|0215)
-X_I_PEEK = (X_STR|0217)
-X_I_FDINSERT = (X_STR|0220)
-X_I_SENDFD = (X_STR|0221)
-X_I_RECVFD = (X_STR|0222)
+X_I_BASE = (X_STR|0o200)
+X_I_NREAD = (X_STR|0o201)
+X_I_PUSH = (X_STR|0o202)
+X_I_POP = (X_STR|0o203)
+X_I_LOOK = (X_STR|0o204)
+X_I_FLUSH = (X_STR|0o205)
+X_I_SRDOPT = (X_STR|0o206)
+X_I_GRDOPT = (X_STR|0o207)
+X_I_STR = (X_STR|0o210)
+X_I_SETSIG = (X_STR|0o211)
+X_I_GETSIG = (X_STR|0o212)
+X_I_FIND = (X_STR|0o213)
+X_I_LINK = (X_STR|0o214)
+X_I_UNLINK = (X_STR|0o215)
+X_I_PEEK = (X_STR|0o217)
+X_I_FDINSERT = (X_STR|0o220)
+X_I_SENDFD = (X_STR|0o221)
+X_I_RECVFD = (X_STR|0o222)
# Included from unistd.h
# Included from sys/unistd.h
-R_OK = 004
-W_OK = 002
-X_OK = 001
+R_OK = 0o04
+W_OK = 0o02
+X_OK = 0o01
F_OK = 000
-EFF_ONLY_OK = 010
-EX_OK = 020
+EFF_ONLY_OK = 0o10
+EX_OK = 0o20
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
@@ -289,40 +289,40 @@
ANYMARK = 0x01
LASTMARK = 0x02
STR = (ord('S')<<8)
-I_NREAD = (STR|01)
-I_PUSH = (STR|02)
-I_POP = (STR|03)
-I_LOOK = (STR|04)
-I_FLUSH = (STR|05)
-I_SRDOPT = (STR|06)
-I_GRDOPT = (STR|07)
-I_STR = (STR|010)
-I_SETSIG = (STR|011)
-I_GETSIG = (STR|012)
-I_FIND = (STR|013)
-I_LINK = (STR|014)
-I_UNLINK = (STR|015)
-I_PEEK = (STR|017)
-I_FDINSERT = (STR|020)
-I_SENDFD = (STR|021)
-I_RECVFD = (STR|022)
-I_E_RECVFD = (STR|016)
-I_RECVFD = (STR|016)
-I_RECVFD = (STR|022)
-I_SWROPT = (STR|023)
-I_GWROPT = (STR|024)
-I_LIST = (STR|025)
-I_PLINK = (STR|026)
-I_PUNLINK = (STR|027)
-I_FLUSHBAND = (STR|034)
-I_CKBAND = (STR|035)
-I_GETBAND = (STR|036)
-I_ATMARK = (STR|037)
-I_SETCLTIME = (STR|040)
-I_GETCLTIME = (STR|041)
-I_CANPUT = (STR|042)
-I_S_RECVFD = (STR|043)
-I_STATS = (STR|044)
-I_BIGPIPE = (STR|045)
-I_GETTP = (STR|046)
+I_NREAD = (STR|0o1)
+I_PUSH = (STR|0o2)
+I_POP = (STR|0o3)
+I_LOOK = (STR|0o4)
+I_FLUSH = (STR|0o5)
+I_SRDOPT = (STR|0o6)
+I_GRDOPT = (STR|0o7)
+I_STR = (STR|0o10)
+I_SETSIG = (STR|0o11)
+I_GETSIG = (STR|0o12)
+I_FIND = (STR|0o13)
+I_LINK = (STR|0o14)
+I_UNLINK = (STR|0o15)
+I_PEEK = (STR|0o17)
+I_FDINSERT = (STR|0o20)
+I_SENDFD = (STR|0o21)
+I_RECVFD = (STR|0o22)
+I_E_RECVFD = (STR|0o16)
+I_RECVFD = (STR|0o16)
+I_RECVFD = (STR|0o22)
+I_SWROPT = (STR|0o23)
+I_GWROPT = (STR|0o24)
+I_LIST = (STR|0o25)
+I_PLINK = (STR|0o26)
+I_PUNLINK = (STR|0o27)
+I_FLUSHBAND = (STR|0o34)
+I_CKBAND = (STR|0o35)
+I_GETBAND = (STR|0o36)
+I_ATMARK = (STR|0o37)
+I_SETCLTIME = (STR|0o40)
+I_GETCLTIME = (STR|0o41)
+I_CANPUT = (STR|0o42)
+I_S_RECVFD = (STR|0o43)
+I_STATS = (STR|0o44)
+I_BIGPIPE = (STR|0o45)
+I_GETTP = (STR|0o46)
INFTIM = -1
Modified: python/branches/p3yk/Lib/pty.py
==============================================================================
--- python/branches/p3yk/Lib/pty.py (original)
+++ python/branches/p3yk/Lib/pty.py Mon Jun 11 00:29:40 2007
@@ -55,7 +55,7 @@
pass
else:
try:
- tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0)
+ tty_name, master_fd = sgi._getpty(os.O_RDWR, 0o666, 0)
except IOError as msg:
raise os.error, msg
return master_fd, tty_name
Modified: python/branches/p3yk/Lib/stat.py
==============================================================================
--- python/branches/p3yk/Lib/stat.py (original)
+++ python/branches/p3yk/Lib/stat.py Mon Jun 11 00:29:40 2007
@@ -24,21 +24,21 @@
# Extract bits from the mode
def S_IMODE(mode):
- return mode & 07777
+ return mode & 0o7777
def S_IFMT(mode):
- return mode & 0170000
+ return mode & 0o170000
# Constants used as S_IFMT() for various file types
# (not all are implemented on all systems)
-S_IFDIR = 0040000
-S_IFCHR = 0020000
-S_IFBLK = 0060000
-S_IFREG = 0100000
-S_IFIFO = 0010000
-S_IFLNK = 0120000
-S_IFSOCK = 0140000
+S_IFDIR = 0o040000
+S_IFCHR = 0o020000
+S_IFBLK = 0o060000
+S_IFREG = 0o100000
+S_IFIFO = 0o010000
+S_IFLNK = 0o120000
+S_IFSOCK = 0o140000
# Functions to test for each file type
@@ -65,25 +65,25 @@
# Names for permission bits
-S_ISUID = 04000
-S_ISGID = 02000
+S_ISUID = 0o4000
+S_ISGID = 0o2000
S_ENFMT = S_ISGID
-S_ISVTX = 01000
-S_IREAD = 00400
-S_IWRITE = 00200
-S_IEXEC = 00100
-S_IRWXU = 00700
-S_IRUSR = 00400
-S_IWUSR = 00200
-S_IXUSR = 00100
-S_IRWXG = 00070
-S_IRGRP = 00040
-S_IWGRP = 00020
-S_IXGRP = 00010
-S_IRWXO = 00007
-S_IROTH = 00004
-S_IWOTH = 00002
-S_IXOTH = 00001
+S_ISVTX = 0o1000
+S_IREAD = 0o0400
+S_IWRITE = 0o0200
+S_IEXEC = 0o0100
+S_IRWXU = 0o0700
+S_IRUSR = 0o0400
+S_IWUSR = 0o0200
+S_IXUSR = 0o0100
+S_IRWXG = 0o0070
+S_IRGRP = 0o0040
+S_IWGRP = 0o0020
+S_IXGRP = 0o0010
+S_IRWXO = 0o0007
+S_IROTH = 0o0004
+S_IWOTH = 0o0002
+S_IXOTH = 0o0001
# Names for file flags
Modified: python/branches/p3yk/Lib/tarfile.py
==============================================================================
--- python/branches/p3yk/Lib/tarfile.py (original)
+++ python/branches/p3yk/Lib/tarfile.py Mon Jun 11 00:29:40 2007
@@ -141,26 +141,26 @@
#---------------------------------------------------------
# Bits used in the mode field, values in octal.
#---------------------------------------------------------
-S_IFLNK = 0120000 # symbolic link
-S_IFREG = 0100000 # regular file
-S_IFBLK = 0060000 # block device
-S_IFDIR = 0040000 # directory
-S_IFCHR = 0020000 # character device
-S_IFIFO = 0010000 # fifo
-
-TSUID = 04000 # set UID on execution
-TSGID = 02000 # set GID on execution
-TSVTX = 01000 # reserved
-
-TUREAD = 0400 # read by owner
-TUWRITE = 0200 # write by owner
-TUEXEC = 0100 # execute/search by owner
-TGREAD = 0040 # read by group
-TGWRITE = 0020 # write by group
-TGEXEC = 0010 # execute/search by group
-TOREAD = 0004 # read by other
-TOWRITE = 0002 # write by other
-TOEXEC = 0001 # execute/search by other
+S_IFLNK = 0o120000 # symbolic link
+S_IFREG = 0o100000 # regular file
+S_IFBLK = 0o060000 # block device
+S_IFDIR = 0o040000 # directory
+S_IFCHR = 0o020000 # character device
+S_IFIFO = 0o010000 # fifo
+
+TSUID = 0o4000 # set UID on execution
+TSGID = 0o2000 # set GID on execution
+TSVTX = 0o1000 # reserved
+
+TUREAD = 0o400 # read by owner
+TUWRITE = 0o200 # write by owner
+TUEXEC = 0o100 # execute/search by owner
+TGREAD = 0o040 # read by group
+TGWRITE = 0o020 # write by group
+TGEXEC = 0o010 # execute/search by group
+TOREAD = 0o004 # read by other
+TOWRITE = 0o002 # write by other
+TOEXEC = 0o001 # execute/search by other
#---------------------------------------------------------
# initialization
@@ -192,7 +192,7 @@
"""
# There are two possible encodings for a number field, see
# itn() below.
- if s[0] != chr(0200):
+ if s[0] != chr(0o200):
try:
n = int(nts(s) or "0", 8)
except ValueError:
@@ -210,7 +210,7 @@
# POSIX 1003.1-1988 requires numbers to be encoded as a string of
# octal digits followed by a null-byte, this allows values up to
# (8**(digits-1))-1. GNU tar allows storing numbers greater than
- # that if necessary. A leading 0200 byte indicates this particular
+ # that if necessary. A leading 0o200 byte indicates this particular
# encoding, the following digits-1 bytes are a big-endian
# representation. This allows values up to (256**(digits-1))-1.
if 0 <= n < 8 ** (digits - 1):
@@ -226,9 +226,9 @@
s = ""
for i in range(digits - 1):
- s = chr(n & 0377) + s
+ s = chr(n & 0o377) + s
n >>= 8
- s = chr(0200) + s
+ s = chr(0o200) + s
return s
def uts(s, encoding, errors):
@@ -920,7 +920,7 @@
of the member.
"""
self.name = name # member name
- self.mode = 0644 # file permissions
+ self.mode = 0o644 # file permissions
self.uid = 0 # user id
self.gid = 0 # group id
self.size = 0 # file size
@@ -960,7 +960,7 @@
"""
info = {
"name": normpath(self.name),
- "mode": self.mode & 07777,
+ "mode": self.mode & 0o7777,
"uid": self.uid,
"gid": self.gid,
"size": self.size,
@@ -1103,7 +1103,7 @@
"""
parts = [
stn(info.get("name", ""), 100),
- itn(info.get("mode", 0) & 07777, 8, format),
+ itn(info.get("mode", 0) & 0o7777, 8, format),
itn(info.get("uid", 0), 8, format),
itn(info.get("gid", 0), 8, format),
itn(info.get("size", 0), 12, format),
@@ -2019,7 +2019,7 @@
# Extract directory with a safe mode, so that
# all files below can be extracted as well.
try:
- os.makedirs(os.path.join(path, tarinfo.name), 0700)
+ os.makedirs(os.path.join(path, tarinfo.name), 0o700)
except EnvironmentError:
pass
directories.append(tarinfo)
Modified: python/branches/p3yk/Lib/tempfile.py
==============================================================================
--- python/branches/p3yk/Lib/tempfile.py (original)
+++ python/branches/p3yk/Lib/tempfile.py Mon Jun 11 00:29:40 2007
@@ -200,7 +200,7 @@
name = next(namer)
filename = _os.path.join(dir, name)
try:
- fd = _os.open(filename, flags, 0600)
+ fd = _os.open(filename, flags, 0o600)
fp = _os.fdopen(fd, 'w')
fp.write('blat')
fp.close()
@@ -239,7 +239,7 @@
name = next(names)
file = _os.path.join(dir, pre + name + suf)
try:
- fd = _os.open(file, flags, 0600)
+ fd = _os.open(file, flags, 0o600)
_set_cloexec(fd)
return (fd, _os.path.abspath(file))
except OSError as e:
@@ -331,7 +331,7 @@
name = next(names)
file = _os.path.join(dir, prefix + name + suffix)
try:
- _os.mkdir(file, 0700)
+ _os.mkdir(file, 0o700)
return file
except OSError as e:
if e.errno == _errno.EEXIST:
Modified: python/branches/p3yk/Lib/test/output/test_tokenize
==============================================================================
--- python/branches/p3yk/Lib/test/output/test_tokenize (original)
+++ python/branches/p3yk/Lib/test/output/test_tokenize Mon Jun 11 00:29:40 2007
@@ -124,66 +124,80 @@
39,5-39,7: OP '!='
39,8-39,11: NUMBER '255'
39,11-39,12: NEWLINE '\n'
-40,0-40,4: NUMBER '0377'
-40,5-40,7: OP '!='
-40,8-40,11: NUMBER '255'
-40,11-40,12: NEWLINE '\n'
+40,0-40,5: NUMBER '0o377'
+40,6-40,8: OP '!='
+40,9-40,12: NUMBER '255'
+40,12-40,13: NEWLINE '\n'
41,0-41,10: NUMBER '2147483647'
41,13-41,15: OP '!='
-41,16-41,28: NUMBER '017777777777'
-41,28-41,29: NEWLINE '\n'
+41,16-41,29: NUMBER '0o17777777777'
+41,29-41,30: NEWLINE '\n'
42,0-42,1: OP '-'
42,1-42,11: NUMBER '2147483647'
42,11-42,12: OP '-'
42,12-42,13: NUMBER '1'
42,14-42,16: OP '!='
-42,17-42,29: NUMBER '020000000000'
-42,29-42,30: NEWLINE '\n'
-43,0-43,12: NUMBER '037777777777'
-43,13-43,15: OP '!='
-43,16-43,17: OP '-'
-43,17-43,18: NUMBER '1'
-43,18-43,19: NEWLINE '\n'
+42,17-42,30: NUMBER '0o20000000000'
+42,30-42,31: NEWLINE '\n'
+43,0-43,13: NUMBER '0o37777777777'
+43,14-43,16: OP '!='
+43,17-43,18: OP '-'
+43,18-43,19: NUMBER '1'
+43,19-43,20: NEWLINE '\n'
44,0-44,10: NUMBER '0xffffffff'
44,11-44,13: OP '!='
44,14-44,15: OP '-'
44,15-44,16: NUMBER '1'
-44,16-44,17: NEWLINE '\n'
+44,16-44,17: OP ';'
+44,18-44,31: NUMBER '0o37777777777'
+44,32-44,34: OP '!='
+44,35-44,36: OP '-'
+44,36-44,37: NUMBER '1'
+44,37-44,38: OP ';'
+44,39-44,40: OP '-'
+44,40-44,49: NUMBER '0o1234567'
+44,50-44,52: OP '=='
+44,53-44,64: NUMBER '0O001234567'
+44,64-44,65: OP ';'
+44,66-44,73: NUMBER '0b10101'
+44,74-44,76: OP '=='
+44,77-44,87: NUMBER '0B00010101'
+44,87-44,88: NEWLINE '\n'
45,0-45,1: NL '\n'
46,0-46,15: COMMENT '# Long integers'
46,15-46,16: NL '\n'
47,0-47,1: NAME 'x'
47,2-47,3: OP '='
-47,4-47,6: NUMBER '0L'
-47,6-47,7: NEWLINE '\n'
+47,4-47,5: NUMBER '0'
+47,5-47,6: NEWLINE '\n'
48,0-48,1: NAME 'x'
48,2-48,3: OP '='
-48,4-48,6: NUMBER '0l'
-48,6-48,7: NEWLINE '\n'
+48,4-48,5: NUMBER '0'
+48,5-48,6: NEWLINE '\n'
49,0-49,1: NAME 'x'
49,2-49,3: OP '='
-49,4-49,23: NUMBER '0xffffffffffffffffL'
-49,23-49,24: NEWLINE '\n'
+49,4-49,22: NUMBER '0xffffffffffffffff'
+49,22-49,23: NEWLINE '\n'
50,0-50,1: NAME 'x'
50,2-50,3: OP '='
-50,4-50,23: NUMBER '0xffffffffffffffffl'
-50,23-50,24: NEWLINE '\n'
+50,4-50,22: NUMBER '0xffffffffffffffff'
+50,22-50,23: NEWLINE '\n'
51,0-51,1: NAME 'x'
51,2-51,3: OP '='
-51,4-51,23: NUMBER '077777777777777777L'
+51,4-51,23: NUMBER '0o77777777777777777'
51,23-51,24: NEWLINE '\n'
52,0-52,1: NAME 'x'
52,2-52,3: OP '='
-52,4-52,23: NUMBER '077777777777777777l'
+52,4-52,23: NUMBER '0B11101010111111111'
52,23-52,24: NEWLINE '\n'
53,0-53,1: NAME 'x'
53,2-53,3: OP '='
-53,4-53,35: NUMBER '123456789012345678901234567890L'
-53,35-53,36: NEWLINE '\n'
+53,4-53,34: NUMBER '123456789012345678901234567890'
+53,34-53,35: NEWLINE '\n'
54,0-54,1: NAME 'x'
54,2-54,3: OP '='
-54,4-54,35: NUMBER '123456789012345678901234567890l'
-54,35-54,36: NEWLINE '\n'
+54,4-54,34: NUMBER '123456789012345678901234567890'
+54,34-54,35: NEWLINE '\n'
55,0-55,1: NL '\n'
56,0-56,24: COMMENT '# Floating-point numbers'
56,24-56,25: NL '\n'
Modified: python/branches/p3yk/Lib/test/test_builtin.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_builtin.py (original)
+++ python/branches/p3yk/Lib/test/test_builtin.py Mon Jun 11 00:29:40 2007
@@ -795,8 +795,27 @@
self.assertRaises(TypeError, int, 1, 12)
- self.assertEqual(int('0123', 0), 83)
+ # tests with base 0
+ self.assertRaises(ValueError, int, ' 0123 ', 0) # old octal syntax
+ self.assertEqual(int('000', 0), 0)
+ self.assertEqual(int('0o123', 0), 83)
+ self.assertEqual(int('0x123', 0), 291)
+ self.assertEqual(int('0b100', 0), 4)
+ self.assertEqual(int(' 0O123 ', 0), 83)
+ self.assertEqual(int(' 0X123 ', 0), 291)
+ self.assertEqual(int(' 0B100 ', 0), 4)
+
+ # without base still base 10
+ self.assertEqual(int('0123'), 123)
+ self.assertEqual(int('0123', 10), 123)
+
+ # tests with prefix and base != 0
self.assertEqual(int('0x123', 16), 291)
+ self.assertEqual(int('0o123', 8), 83)
+ self.assertEqual(int('0b100', 2), 4)
+ self.assertEqual(int('0X123', 16), 291)
+ self.assertEqual(int('0O123', 8), 83)
+ self.assertEqual(int('0B100', 2), 4)
# SF bug 1334662: int(string, base) wrong answers
# Various representations of 2**32 evaluated to 0
@@ -1348,10 +1367,10 @@
self.assertEquals(next(it, 42), 42)
def test_oct(self):
- self.assertEqual(oct(100), '0144')
- self.assertEqual(oct(100), '0144')
- self.assertEqual(oct(-100), '-0144')
- self.assertEqual(oct(-100), '-0144')
+ self.assertEqual(oct(100), '0o144')
+ self.assertEqual(oct(100), '0o144')
+ self.assertEqual(oct(-100), '-0o144')
+ self.assertEqual(oct(-100), '-0o144')
self.assertRaises(TypeError, oct, ())
def write_testfile(self):
Modified: python/branches/p3yk/Lib/test/test_compile.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_compile.py (original)
+++ python/branches/p3yk/Lib/test/test_compile.py Mon Jun 11 00:29:40 2007
@@ -158,21 +158,22 @@
def test_literals_with_leading_zeroes(self):
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
- "080000000000000", "000000000000009", "000000000000008"]:
+ "080000000000000", "000000000000009", "000000000000008",
+ "0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2",
+ "0b101j2", "0o153j2", "0b100e1", "0o777e1", "0777",
+ "000777", "000000000000007"]:
self.assertRaises(SyntaxError, eval, arg)
- self.assertEqual(eval("0777"), 511)
- self.assertEqual(eval("000777"), 511)
self.assertEqual(eval("0xff"), 255)
- self.assertEqual(eval("0XfF"), 255)
self.assertEqual(eval("0777."), 777)
self.assertEqual(eval("0777.0"), 777)
self.assertEqual(eval("000000000000000000000000000000000000000000000000000777e0"), 777)
self.assertEqual(eval("0777e1"), 7770)
self.assertEqual(eval("0e0"), 0)
- self.assertEqual(eval("0000E-012"), 0)
+ self.assertEqual(eval("0000e-012"), 0)
self.assertEqual(eval("09.5"), 9.5)
self.assertEqual(eval("0777j"), 777j)
+ self.assertEqual(eval("000"), 0)
self.assertEqual(eval("00j"), 0j)
self.assertEqual(eval("00.0"), 0)
self.assertEqual(eval("0e3"), 0)
@@ -181,9 +182,12 @@
self.assertEqual(eval("090000000000000e0"), 90000000000000.)
self.assertEqual(eval("090000000000000e-0"), 90000000000000.)
self.assertEqual(eval("090000000000000j"), 90000000000000j)
- self.assertEqual(eval("000000000000007"), 7)
self.assertEqual(eval("000000000000008."), 8.)
self.assertEqual(eval("000000000000009."), 9.)
+ self.assertEqual(eval("0b101010"), 42)
+ self.assertEqual(eval("-0b000000000010"), -2)
+ self.assertEqual(eval("0o777"), 511)
+ self.assertEqual(eval("-0o0000010"), -8)
def test_unary_minus(self):
# Verify treatment of unary minus on negative numbers SF bug #660455
Modified: python/branches/p3yk/Lib/test/test_descr.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_descr.py (original)
+++ python/branches/p3yk/Lib/test/test_descr.py Mon Jun 11 00:29:40 2007
@@ -2124,17 +2124,14 @@
class octlong(int):
__slots__ = []
def __str__(self):
- s = oct(self)
- if s[-1] == 'L':
- s = s[:-1]
- return s
+ return oct(self)
def __add__(self, other):
return self.__class__(super(octlong, self).__add__(other))
__radd__ = __add__
- vereq(str(octlong(3) + 5), "010")
+ vereq(str(octlong(3) + 5), "0o10")
# (Note that overriding __radd__ here only seems to work
# because the example uses a short int left argument.)
- vereq(str(5 + octlong(3000)), "05675")
+ vereq(str(5 + octlong(3000)), "0o5675")
a = octlong(12345)
vereq(a, 12345)
vereq(int(a), 12345)
Modified: python/branches/p3yk/Lib/test/test_dumbdbm.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_dumbdbm.py (original)
+++ python/branches/p3yk/Lib/test/test_dumbdbm.py Mon Jun 11 00:29:40 2007
@@ -44,17 +44,17 @@
return
try:
- old_umask = os.umask(0002)
- f = dumbdbm.open(_fname, 'c', 0637)
+ old_umask = os.umask(0o002)
+ f = dumbdbm.open(_fname, 'c', 0o637)
f.close()
finally:
os.umask(old_umask)
- expected_mode = 0635
+ expected_mode = 0o635
if os.name != 'posix':
# Windows only supports setting the read-only attribute.
# This shouldn't fail, but doesn't work like Unix either.
- expected_mode = 0666
+ expected_mode = 0o666
import stat
st = os.stat(_fname + '.dat')
Modified: python/branches/p3yk/Lib/test/test_format.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_format.py (original)
+++ python/branches/p3yk/Lib/test/test_format.py Mon Jun 11 00:29:40 2007
@@ -122,7 +122,7 @@
# same, except no 0 flag
testboth("%#+27.23X", big, " +0X001234567890ABCDEF12345")
-big = 012345670123456701234567012345670 # 32 octal digits
+big = 0o12345670123456701234567012345670 # 32 octal digits
testboth("%o", big, "12345670123456701234567012345670")
testboth("%o", -big, "-12345670123456701234567012345670")
testboth("%5o", -big, "-12345670123456701234567012345670")
@@ -142,25 +142,26 @@
testboth("%34.33o", big, " 012345670123456701234567012345670")
testboth("%-34.33o", big, "012345670123456701234567012345670 ")
testboth("%o", big, "12345670123456701234567012345670")
-testboth("%#o", big, "012345670123456701234567012345670")
-testboth("%#o", -big, "-012345670123456701234567012345670")
-testboth("%#.34o", -big, "-0012345670123456701234567012345670")
-testboth("%#+.34o", big, "+0012345670123456701234567012345670")
-testboth("%# .34o", big, " 0012345670123456701234567012345670")
-testboth("%#+.34o", big, "+0012345670123456701234567012345670")
-testboth("%#-+.34o", big, "+0012345670123456701234567012345670")
-testboth("%#-+37.34o", big, "+0012345670123456701234567012345670 ")
-testboth("%#+37.34o", big, " +0012345670123456701234567012345670")
+testboth("%#o", big, "0o12345670123456701234567012345670")
+testboth("%#o", -big, "-0o12345670123456701234567012345670")
+testboth("%#.34o", -big, "-0o0012345670123456701234567012345670")
+testboth("%#+.34o", big, "+0o0012345670123456701234567012345670")
+testboth("%# .34o", big, " 0o0012345670123456701234567012345670")
+testboth("%#-+.34o", big, "+0o0012345670123456701234567012345670")
+testboth("%#-+39.34o", big, "+0o0012345670123456701234567012345670 ")
+testboth("%#+39.34o", big, " +0o0012345670123456701234567012345670")
# next one gets one leading zero from precision
testboth("%.33o", big, "012345670123456701234567012345670")
-# base marker shouldn't change that, since "0" is redundant
-testboth("%#.33o", big, "012345670123456701234567012345670")
-# but reduce precision, and base marker should add a zero
-testboth("%#.32o", big, "012345670123456701234567012345670")
-# one leading zero from precision, and another from "0" flag & width
+# one leading zero from precision
+testboth("%#.33o", big, "0o012345670123456701234567012345670")
+# leading zero vanishes
+testboth("%#.32o", big, "0o12345670123456701234567012345670")
+# one leading zero from precision, and another from '0' flag & width
testboth("%034.33o", big, "0012345670123456701234567012345670")
-# base marker shouldn't change that
-testboth("%0#34.33o", big, "0012345670123456701234567012345670")
+# max width includes base marker; padding zeroes come after marker
+testboth("%0#38.33o", big, "0o000012345670123456701234567012345670")
+# padding spaces come before marker
+testboth("%#36.33o", big, " 0o012345670123456701234567012345670")
# Some small ints, in both Python int and long flavors).
testboth("%d", 42, "42")
@@ -171,10 +172,10 @@
testboth("%#x", 1, "0x1")
testboth("%#X", 1, "0X1")
testboth("%#X", 1, "0X1")
-testboth("%#o", 1, "01")
-testboth("%#o", 1, "01")
-testboth("%#o", 0, "0")
-testboth("%#o", 0, "0")
+testboth("%#o", 1, "0o1")
+testboth("%#o", 1, "0o1")
+testboth("%#o", 0, "0o0")
+testboth("%#o", 0, "0o0")
testboth("%o", 0, "0")
testboth("%o", 0, "0")
testboth("%d", 0, "0")
@@ -189,10 +190,10 @@
testboth("%x", 0x42, "42")
testboth("%x", -0x42, "-42")
-testboth("%o", 042, "42")
-testboth("%o", -042, "-42")
-testboth("%o", 042, "42")
-testboth("%o", -042, "-42")
+testboth("%o", 0o42, "42")
+testboth("%o", -0o42, "-42")
+testboth("%o", 0o42, "42")
+testboth("%o", -0o42, "-42")
# Test exception for unknown format characters
if verbose:
Modified: python/branches/p3yk/Lib/test/test_grammar.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_grammar.py (original)
+++ python/branches/p3yk/Lib/test/test_grammar.py Mon Jun 11 00:29:40 2007
@@ -27,26 +27,32 @@
self.assertEquals(x, 0, 'backslash ending comment')
def testPlainIntegers(self):
+ self.assertEquals(type(000), type(0))
self.assertEquals(0xff, 255)
- self.assertEquals(0377, 255)
- self.assertEquals(2147483647, 017777777777)
+ self.assertEquals(0o377, 255)
+ self.assertEquals(2147483647, 0o17777777777)
+ self.assertEquals(0b1001, 9)
from sys import maxint
if maxint == 2147483647:
- self.assertEquals(-2147483647-1, -020000000000)
+ self.assertEquals(-2147483647-1, -0o20000000000)
# XXX -2147483648
- self.assert_(037777777777 > 0)
+ self.assert_(0o37777777777 > 0)
self.assert_(0xffffffff > 0)
- for s in '2147483648', '040000000000', '0x100000000':
+ self.assert_(0b1111111111111111111111111111111 > 0)
+ for s in ('2147483648', '0o40000000000', '0x100000000',
+ '0b10000000000000000000000000000000'):
try:
x = eval(s)
except OverflowError:
self.fail("OverflowError on huge integer literal %r" % s)
elif maxint == 9223372036854775807:
- self.assertEquals(-9223372036854775807-1, -01000000000000000000000)
- self.assert_(01777777777777777777777 > 0)
+ self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000)
+ self.assert_(0o1777777777777777777777 > 0)
self.assert_(0xffffffffffffffff > 0)
- for s in '9223372036854775808', '02000000000000000000000', \
- '0x10000000000000000':
+ self.assert_(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
+ for s in '9223372036854775808', '0o2000000000000000000000', \
+ '0x10000000000000000', \
+ '0b100000000000000000000000000000000000000000000000000000000000000':
try:
x = eval(s)
except OverflowError:
@@ -56,13 +62,13 @@
def testLongIntegers(self):
x = 0
- x = 0
- x = 0xffffffffffffffff
x = 0xffffffffffffffff
- x = 077777777777777777
- x = 077777777777777777
- x = 123456789012345678901234567890
+ x = 0Xffffffffffffffff
+ x = 0o77777777777777777
+ x = 0O77777777777777777
x = 123456789012345678901234567890
+ x = 0b100000000000000000000000000000000000000000000000000000000000000000000
+ x = 0B111111111111111111111111111111111111111111111111111111111111111111111
def testFloats(self):
x = 3.14
Modified: python/branches/p3yk/Lib/test/test_hexoct.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_hexoct.py (original)
+++ python/branches/p3yk/Lib/test/test_hexoct.py Mon Jun 11 00:29:40 2007
@@ -65,49 +65,49 @@
def test_oct_baseline(self):
# Baseline tests
self.assertEqual(00, 0)
- self.assertEqual(020, 16)
+ self.assertEqual(0o20, 16)
if platform_long_is_32_bits:
- self.assertEqual(017777777777, 2147483647)
+ self.assertEqual(0o17777777777, 2147483647)
else:
- self.assertEqual(0777777777777777777777, 9223372036854775807)
+ self.assertEqual(0o777777777777777777777, 9223372036854775807)
# Ditto with a minus sign and parentheses
self.assertEqual(-(00), 0)
- self.assertEqual(-(020), -16)
+ self.assertEqual(-(0o20), -16)
if platform_long_is_32_bits:
- self.assertEqual(-(017777777777), -2147483647)
+ self.assertEqual(-(0o17777777777), -2147483647)
else:
- self.assertEqual(-(0777777777777777777777), -9223372036854775807)
+ self.assertEqual(-(0o777777777777777777777), -9223372036854775807)
# Ditto with a minus sign and NO parentheses
self.assertEqual(-00, 0)
- self.assertEqual(-020, -16)
+ self.assertEqual(-0o20, -16)
if platform_long_is_32_bits:
- self.assertEqual(-017777777777, -2147483647)
+ self.assertEqual(-0o17777777777, -2147483647)
else:
- self.assertEqual(-0777777777777777777777, -9223372036854775807)
+ self.assertEqual(-0o777777777777777777777, -9223372036854775807)
def test_oct_unsigned(self):
if platform_long_is_32_bits:
# Positive constants
- self.assertEqual(020000000000, 2147483648)
- self.assertEqual(037777777777, 4294967295)
+ self.assertEqual(0o20000000000, 2147483648)
+ self.assertEqual(0o37777777777, 4294967295)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(020000000000), -2147483648)
- self.assertEqual(-(037777777777), -4294967295)
+ self.assertEqual(-(0o20000000000), -2147483648)
+ self.assertEqual(-(0o37777777777), -4294967295)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-020000000000, -2147483648)
- self.assertEqual(-037777777777, -4294967295)
+ self.assertEqual(-0o20000000000, -2147483648)
+ self.assertEqual(-0o37777777777, -4294967295)
else:
# Positive constants
- self.assertEqual(01000000000000000000000, 9223372036854775808)
- self.assertEqual(01777777777777777777777, 18446744073709551615)
+ self.assertEqual(0o1000000000000000000000, 9223372036854775808)
+ self.assertEqual(0o1777777777777777777777, 18446744073709551615)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(01000000000000000000000), -9223372036854775808)
- self.assertEqual(-(01777777777777777777777), -18446744073709551615)
+ self.assertEqual(-(0o1000000000000000000000), -9223372036854775808)
+ self.assertEqual(-(0o1777777777777777777777), -18446744073709551615)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-01000000000000000000000, -9223372036854775808)
- self.assertEqual(-01777777777777777777777, -18446744073709551615)
+ self.assertEqual(-0o1000000000000000000000, -9223372036854775808)
+ self.assertEqual(-0o1777777777777777777777, -18446744073709551615)
def test_main():
test_support.run_unittest(TextHexOct)
Modified: python/branches/p3yk/Lib/test/test_long.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_long.py (original)
+++ python/branches/p3yk/Lib/test/test_long.py Mon Jun 11 00:29:40 2007
@@ -195,9 +195,6 @@
self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2))
def slow_format(self, x, base):
- if (x, base) == (0, 8):
- # this is an oddball!
- return "0"
digits = []
sign = 0
if x < 0:
@@ -208,7 +205,7 @@
digits.reverse()
digits = digits or [0]
return '-'[:sign] + \
- {8: '0', 10: '', 16: '0x'}[base] + \
+ {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
"".join(map(lambda i: "0123456789abcdef"[i], digits))
def check_format_1(self, x):
Modified: python/branches/p3yk/Lib/test/test_strptime.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_strptime.py (original)
+++ python/branches/p3yk/Lib/test/test_strptime.py Mon Jun 11 00:29:40 2007
@@ -463,8 +463,8 @@
"of the year")
test_helper((1917, 12, 31), "Dec 31 on Monday with year starting and "
"ending on Monday")
- test_helper((2007, 01, 07), "First Sunday of 2007")
- test_helper((2007, 01, 14), "Second Sunday of 2007")
+ test_helper((2007, 1, 7), "First Sunday of 2007")
+ test_helper((2007, 1, 14), "Second Sunday of 2007")
test_helper((2006, 12, 31), "Last Sunday of 2006")
test_helper((2006, 12, 24), "Second to last Sunday of 2006")
Modified: python/branches/p3yk/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_subprocess.py (original)
+++ python/branches/p3yk/Lib/test/test_subprocess.py Mon Jun 11 00:29:40 2007
@@ -533,7 +533,7 @@
os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
sys.executable)
os.close(f)
- os.chmod(fname, 0700)
+ os.chmod(fname, 0o700)
p = subprocess.Popen(fname)
p.wait()
os.remove(fname)
@@ -575,7 +575,7 @@
os.write(f, "exec %s -c 'import sys; sys.exit(47)'\n" %
sys.executable)
os.close(f)
- os.chmod(fname, 0700)
+ os.chmod(fname, 0o700)
rc = subprocess.call(fname)
os.remove(fname)
self.assertEqual(rc, 47)
Modified: python/branches/p3yk/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_tarfile.py (original)
+++ python/branches/p3yk/Lib/test/test_tarfile.py Mon Jun 11 00:29:40 2007
@@ -164,7 +164,7 @@
def test_check_members(self):
for tarinfo in self.tar:
- self.assert_(int(tarinfo.mtime) == 07606136617,
+ self.assert_(int(tarinfo.mtime) == 0o7606136617,
"wrong mtime for %s" % tarinfo.name)
if not tarinfo.name.startswith("ustar/"):
continue
@@ -299,7 +299,7 @@
self.assert_(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
"wrong md5sum for %s" % tarinfo.name)
- kwargs["mtime"] = 07606136617
+ kwargs["mtime"] = 0o7606136617
kwargs["uid"] = 1000
kwargs["gid"] = 100
if "old-v7" not in tarinfo.name:
@@ -979,7 +979,7 @@
# uid > 8 digits
tarinfo = tarfile.TarInfo("name")
- tarinfo.uid = 010000000
+ tarinfo.uid = 0o10000000
self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
def test_gnu_limits(self):
@@ -992,7 +992,7 @@
# uid >= 256 ** 7
tarinfo = tarfile.TarInfo("name")
- tarinfo.uid = 04000000000000000000
+ tarinfo.uid = 0o4000000000000000000
self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT)
def test_pax_limits(self):
@@ -1004,7 +1004,7 @@
tarinfo.tobuf(tarfile.PAX_FORMAT)
tarinfo = tarfile.TarInfo("name")
- tarinfo.uid = 04000000000000000000
+ tarinfo.uid = 0o4000000000000000000
tarinfo.tobuf(tarfile.PAX_FORMAT)
Modified: python/branches/p3yk/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_tempfile.py (original)
+++ python/branches/p3yk/Lib/test/test_tempfile.py Mon Jun 11 00:29:40 2007
@@ -264,7 +264,7 @@
file = self.do_create()
mode = stat.S_IMODE(os.stat(file.name).st_mode)
- expected = 0600
+ expected = 0o600
if sys.platform in ('win32', 'os2emx', 'mac'):
# There's no distinction among 'user', 'group' and 'world';
# replicate the 'user' bits.
@@ -482,8 +482,8 @@
dir = self.do_create()
try:
mode = stat.S_IMODE(os.stat(dir).st_mode)
- mode &= 0777 # Mask off sticky bits inherited from /tmp
- expected = 0700
+ mode &= 0o777 # Mask off sticky bits inherited from /tmp
+ expected = 0o700
if sys.platform in ('win32', 'os2emx', 'mac'):
# There's no distinction among 'user', 'group' and 'world';
# replicate the 'user' bits.
@@ -517,7 +517,7 @@
self.name = tempfile.mktemp(dir=dir, prefix=pre, suffix=suf)
# Create the file. This will raise an exception if it's
# mysteriously appeared in the meanwhile.
- os.close(os.open(self.name, self._bflags, 0600))
+ os.close(os.open(self.name, self._bflags, 0o600))
def __del__(self):
self._unlink(self.name)
Modified: python/branches/p3yk/Lib/test/test_unicode_file.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_unicode_file.py (original)
+++ python/branches/p3yk/Lib/test/test_unicode_file.py Mon Jun 11 00:29:40 2007
@@ -48,7 +48,7 @@
self.failUnless(os.path.exists(os.path.abspath(filename)))
self.failUnless(os.path.isfile(os.path.abspath(filename)))
self.failUnless(os.access(os.path.abspath(filename), os.R_OK))
- os.chmod(filename, 0777)
+ os.chmod(filename, 0o777)
os.utime(filename, None)
os.utime(filename, (time.time(), time.time()))
# Copy/rename etc tests using the same filename
Modified: python/branches/p3yk/Lib/test/test_uu.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_uu.py (original)
+++ python/branches/p3yk/Lib/test/test_uu.py Mon Jun 11 00:29:40 2007
@@ -24,21 +24,21 @@
inp = cStringIO.StringIO(plaintext)
out = cStringIO.StringIO()
uu.encode(inp, out, "t1")
- self.assertEqual(out.getvalue(), encodedtextwrapped % (0666, "t1"))
+ self.assertEqual(out.getvalue(), encodedtextwrapped % (0o666, "t1"))
inp = cStringIO.StringIO(plaintext)
out = cStringIO.StringIO()
- uu.encode(inp, out, "t1", 0644)
- self.assertEqual(out.getvalue(), encodedtextwrapped % (0644, "t1"))
+ uu.encode(inp, out, "t1", 0o644)
+ self.assertEqual(out.getvalue(), encodedtextwrapped % (0o644, "t1"))
def test_decode(self):
- inp = cStringIO.StringIO(encodedtextwrapped % (0666, "t1"))
+ inp = cStringIO.StringIO(encodedtextwrapped % (0o666, "t1"))
out = cStringIO.StringIO()
uu.decode(inp, out)
self.assertEqual(out.getvalue(), plaintext)
inp = cStringIO.StringIO(
"UUencoded files may contain many lines,\n" +
"even some that have 'begin' in them.\n" +
- encodedtextwrapped % (0666, "t1")
+ encodedtextwrapped % (0o666, "t1")
)
out = cStringIO.StringIO()
uu.decode(inp, out)
@@ -75,14 +75,14 @@
def test_encode(self):
sys.stdin = cStringIO.StringIO(plaintext)
sys.stdout = cStringIO.StringIO()
- uu.encode("-", "-", "t1", 0666)
+ uu.encode("-", "-", "t1", 0o666)
self.assertEqual(
sys.stdout.getvalue(),
- encodedtextwrapped % (0666, "t1")
+ encodedtextwrapped % (0o666, "t1")
)
def test_decode(self):
- sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0666, "t1"))
+ sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0o666, "t1"))
sys.stdout = cStringIO.StringIO()
uu.decode("-", "-")
self.assertEqual(sys.stdout.getvalue(), plaintext)
@@ -120,21 +120,21 @@
fin = open(self.tmpin, 'rb')
fout = open(self.tmpout, 'w')
- uu.encode(fin, fout, self.tmpin, mode=0644)
+ uu.encode(fin, fout, self.tmpin, mode=0o644)
fin.close()
fout.close()
fout = open(self.tmpout, 'r')
s = fout.read()
fout.close()
- self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin))
+ self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin))
# in_file and out_file as filenames
- uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0644)
+ uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0o644)
fout = open(self.tmpout, 'r')
s = fout.read()
fout.close()
- self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin))
+ self.assertEqual(s, encodedtextwrapped % (0o644, self.tmpin))
finally:
self._kill(fin)
@@ -143,7 +143,7 @@
def test_decode(self):
try:
f = open(self.tmpin, 'w')
- f.write(encodedtextwrapped % (0644, self.tmpout))
+ f.write(encodedtextwrapped % (0o644, self.tmpout))
f.close()
f = open(self.tmpin, 'r')
@@ -161,7 +161,7 @@
def test_decodetwice(self):
# Verify that decode() will refuse to overwrite an existing file
try:
- f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout))
+ f = cStringIO.StringIO(encodedtextwrapped % (0o644, self.tmpout))
f = open(self.tmpin, 'r')
uu.decode(f)
Modified: python/branches/p3yk/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_xmlrpc.py (original)
+++ python/branches/p3yk/Lib/test/test_xmlrpc.py Mon Jun 11 00:29:40 2007
@@ -22,9 +22,9 @@
u'ukey\u4000': 'regular value',
'datetime1': xmlrpclib.DateTime('20050210T11:41:23'),
'datetime2': xmlrpclib.DateTime(
- (2005, 02, 10, 11, 41, 23, 0, 1, -1)),
+ (2005, 2, 10, 11, 41, 23, 0, 1, -1)),
'datetime3': xmlrpclib.DateTime(
- datetime.datetime(2005, 02, 10, 11, 41, 23)),
+ datetime.datetime(2005, 2, 10, 11, 41, 23)),
}]
class XMLRPCTestCase(unittest.TestCase):
@@ -38,7 +38,7 @@
# by the marshalling code. This can't be done via test_dump_load()
# since with use_datetime set to 1 the unmarshaller would create
# datetime objects for the 'datetime[123]' keys as well
- dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
+ dt = datetime.datetime(2005, 2, 10, 11, 41, 23)
s = xmlrpclib.dumps((dt,))
(newdt,), m = xmlrpclib.loads(s, use_datetime=1)
self.assertEquals(newdt, dt)
@@ -51,7 +51,7 @@
# This checks that an unwrapped datetime.date object can be handled
# by the marshalling code. This can't be done via test_dump_load()
# since the unmarshaller produces a datetime object
- d = datetime.datetime(2005, 02, 10, 11, 41, 23).date()
+ d = datetime.datetime(2005, 2, 10, 11, 41, 23).date()
s = xmlrpclib.dumps((d,))
(newd,), m = xmlrpclib.loads(s, use_datetime=1)
self.assertEquals(newd.date(), d)
@@ -65,7 +65,7 @@
# This checks that an unwrapped datetime.time object can be handled
# by the marshalling code. This can't be done via test_dump_load()
# since the unmarshaller produces a datetime object
- t = datetime.datetime(2005, 02, 10, 11, 41, 23).time()
+ t = datetime.datetime(2005, 2, 10, 11, 41, 23).time()
s = xmlrpclib.dumps((t,))
(newt,), m = xmlrpclib.loads(s, use_datetime=1)
today = datetime.datetime.now().date().strftime("%Y%m%d")
Modified: python/branches/p3yk/Lib/test/test_zipimport.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_zipimport.py (original)
+++ python/branches/p3yk/Lib/test/test_zipimport.py Mon Jun 11 00:29:40 2007
@@ -364,7 +364,7 @@
finally:
# If we leave "the read-only bit" set on Windows, nothing can
# delete TESTMOD, and later tests suffer bogus failures.
- os.chmod(TESTMOD, 0666)
+ os.chmod(TESTMOD, 0o666)
test_support.unlink(TESTMOD)
def testNotZipFile(self):
Modified: python/branches/p3yk/Lib/test/tokenize_tests.txt
==============================================================================
--- python/branches/p3yk/Lib/test/tokenize_tests.txt (original)
+++ python/branches/p3yk/Lib/test/tokenize_tests.txt Mon Jun 11 00:29:40 2007
@@ -37,21 +37,21 @@
# Ordinary integers
0xff != 255
-0377 != 255
-2147483647 != 017777777777
--2147483647-1 != 020000000000
-037777777777 != -1
-0xffffffff != -1
+0o377 != 255
+2147483647 != 0o17777777777
+-2147483647-1 != 0o20000000000
+0o37777777777 != -1
+0xffffffff != -1; 0o37777777777 != -1; -0o1234567 == 0O001234567; 0b10101 == 0B00010101
# Long integers
-x = 0L
-x = 0l
-x = 0xffffffffffffffffL
-x = 0xffffffffffffffffl
-x = 077777777777777777L
-x = 077777777777777777l
-x = 123456789012345678901234567890L
-x = 123456789012345678901234567890l
+x = 0
+x = 0
+x = 0xffffffffffffffff
+x = 0xffffffffffffffff
+x = 0o77777777777777777
+x = 0B11101010111111111
+x = 123456789012345678901234567890
+x = 123456789012345678901234567890
# Floating-point numbers
x = 3.14
Modified: python/branches/p3yk/Lib/tokenize.py
==============================================================================
--- python/branches/p3yk/Lib/tokenize.py (original)
+++ python/branches/p3yk/Lib/tokenize.py Mon Jun 11 00:29:40 2007
@@ -49,10 +49,11 @@
Ignore = Whitespace + any(r'\\\r?\n' + Whitespace) + maybe(Comment)
Name = r'[a-zA-Z_]\w*'
-Hexnumber = r'0[xX][\da-fA-F]*[lL]?'
-Octnumber = r'0[0-7]*[lL]?'
-Decnumber = r'[1-9]\d*[lL]?'
-Intnumber = group(Hexnumber, Octnumber, Decnumber)
+Hexnumber = r'0[xX][\da-fA-F]*'
+Binnumber = r'0[bB][01]*'
+Octnumber = r'0[oO][0-7]*'
+Decnumber = r'(?:0+|[1-9]\d*)'
+Intnumber = group(Hexnumber, Binnumber, Octnumber, Decnumber)
Exponent = r'[eE][-+]?\d+'
Pointfloat = group(r'\d+\.\d*', r'\.\d+') + maybe(Exponent)
Expfloat = r'\d+' + Exponent
Modified: python/branches/p3yk/Lib/uu.py
==============================================================================
--- python/branches/p3yk/Lib/uu.py (original)
+++ python/branches/p3yk/Lib/uu.py Mon Jun 11 00:29:40 2007
@@ -68,11 +68,11 @@
if name is None:
name = '-'
if mode is None:
- mode = 0666
+ mode = 0o666
#
# Write the data
#
- out_file.write('begin %o %s\n' % ((mode&0777),name))
+ out_file.write('begin %o %s\n' % ((mode & 0o777),name))
data = in_file.read(45)
while len(data) > 0:
out_file.write(binascii.b2a_uu(data))
Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS (original)
+++ python/branches/p3yk/Misc/NEWS Mon Jun 11 00:29:40 2007
@@ -26,6 +26,10 @@
Core and Builtins
-----------------
+- PEP 3127: octal literals now start with "0o". Old-style octal literals
+ are invalid. There are binary literals with a prefix of "0b".
+ This also affects int(x, 0).
+
- None, True, False are now keywords.
- PEP 3119: isinstance() and issubclass() can be overridden.
Modified: python/branches/p3yk/Objects/longobject.c
==============================================================================
--- python/branches/p3yk/Objects/longobject.c (original)
+++ python/branches/p3yk/Objects/longobject.c Mon Jun 11 00:29:40 2007
@@ -1424,7 +1424,7 @@
/* Convert a long int object to a string, using a given conversion base.
Return a string object.
- If base is 8 or 16, add the proper prefix '0' or '0x'. */
+ If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. */
static PyObject *
long_format(PyObject *aa, int base)
@@ -1551,14 +1551,18 @@
Py_DECREF(scratch);
}
- if (base == 8) {
- if (size_a != 0)
- *--p = '0';
- }
- else if (base == 16) {
+ if (base == 16) {
*--p = 'x';
*--p = '0';
}
+ else if (base == 8) {
+ *--p = 'o';
+ *--p = '0';
+ }
+ else if (base == 2) {
+ *--p = 'b';
+ *--p = '0';
+ }
else if (base != 10) {
*--p = '#';
*--p = '0' + base%10;
@@ -1675,9 +1679,9 @@
PyObject *
PyLong_FromString(char *str, char **pend, int base)
{
- int sign = 1;
+ int sign = 1, error_if_nonzero = 0;
char *start, *orig_str = str;
- PyLongObject *z;
+ PyLongObject *z = NULL;
PyObject *strobj, *strrepr;
Py_ssize_t slen;
@@ -1701,10 +1705,21 @@
base = 10;
else if (str[1] == 'x' || str[1] == 'X')
base = 16;
- else
+ else if (str[1] == 'o' || str[1] == 'O')
base = 8;
+ else if (str[1] == 'b' || str[1] == 'B')
+ base = 2;
+ else {
+ /* "old" (C-style) octal literal, now invalid.
+ it might still be zero though */
+ error_if_nonzero = 1;
+ base = 10;
+ }
}
- if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
+ if (str[0] == '0' &&
+ ((base == 16 && (str[1] == 'x' || str[1] == 'X')) ||
+ (base == 8 && (str[1] == 'o' || str[1] == 'O')) ||
+ (base == 2 && (str[1] == 'b' || str[1] == 'B'))))
str += 2;
start = str;
@@ -1908,6 +1923,15 @@
}
if (z == NULL)
return NULL;
+ if (error_if_nonzero) {
+ /* reset the base to 0, else the exception message
+ doesn't make too much sense */
+ base = 0;
+ if (z->ob_size != 0)
+ goto onError;
+ /* there might still be other problems, therefore base
+ remains zero here for the same reason */
+ }
if (str == start)
goto onError;
if (sign < 0)
Modified: python/branches/p3yk/Objects/stringobject.c
==============================================================================
--- python/branches/p3yk/Objects/stringobject.c (original)
+++ python/branches/p3yk/Objects/stringobject.c Mon Jun 11 00:29:40 2007
@@ -4243,6 +4243,7 @@
result = val->ob_type->tp_str(val);
break;
case 'o':
+ numnondigits = 2;
result = val->ob_type->tp_as_number->nb_oct(val);
break;
case 'x':
@@ -4283,32 +4284,16 @@
assert(numdigits > 0);
/* Get rid of base marker unless F_ALT */
- if ((flags & F_ALT) == 0) {
- /* Need to skip 0x, 0X or 0. */
- int skipped = 0;
- switch (type) {
- case 'o':
- assert(buf[sign] == '0');
- /* If 0 is only digit, leave it alone. */
- if (numdigits > 1) {
- skipped = 1;
- --numdigits;
- }
- break;
- case 'x':
- case 'X':
- assert(buf[sign] == '0');
- assert(buf[sign + 1] == 'x');
- skipped = 2;
- numnondigits -= 2;
- break;
- }
- if (skipped) {
- buf += skipped;
- len -= skipped;
- if (sign)
- buf[0] = '-';
- }
+ if (((flags & F_ALT) == 0 &&
+ (type == 'o' || type == 'x' || type == 'X'))) {
+ assert(buf[sign] == '0');
+ assert(buf[sign+1] == 'x' || buf[sign+1] == 'X' ||
+ buf[sign+1] == 'o');
+ numnondigits -= 2;
+ buf += 2;
+ len -= 2;
+ if (sign)
+ buf[0] = '-';
assert(len == numnondigits + numdigits);
assert(numdigits > 0);
}
@@ -4377,9 +4362,10 @@
prec = 1;
if ((flags & F_ALT) &&
- (type == 'x' || type == 'X')) {
- /* When converting under %#x or %#X, there are a number
+ (type == 'x' || type == 'X' || type == 'o')) {
+ /* When converting under %#o, %#x or %#X, there are a number
* of issues that cause pain:
+ * - for %#o, we want a different base marker than C
* - when 0 is being converted, the C standard leaves off
* the '0x' or '0X', which is inconsistent with other
* %#x/%#X conversions and inconsistent with Python's
@@ -4407,7 +4393,7 @@
prec, type);
}
- /* buf = '+'/'-'/'' + '0'/'0x'/'' + '[0-9]'*max(prec, len(x in octal))
+ /* buf = '+'/'-'/'' + '0o'/'0x'/'' + '[0-9]'*max(prec, len(x in octal))
* worst case buf = '-0x' + [0-9]*prec, where prec >= 11
*/
if (buflen <= 14 || buflen <= (size_t)3 + (size_t)prec) {
@@ -4805,7 +4791,8 @@
if (width > len)
width--;
}
- if ((flags & F_ALT) && (c == 'x' || c == 'X')) {
+ if ((flags & F_ALT) &&
+ (c == 'x' || c == 'X' || c == 'o')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
if (fill != ' ') {
@@ -4828,7 +4815,7 @@
if (sign)
*res++ = sign;
if ((flags & F_ALT) &&
- (c == 'x' || c == 'X')) {
+ (c == 'x' || c == 'X' || c == 'o')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
*res++ = *pbuf++;
Modified: python/branches/p3yk/Objects/unicodeobject.c
==============================================================================
--- python/branches/p3yk/Objects/unicodeobject.c (original)
+++ python/branches/p3yk/Objects/unicodeobject.c Mon Jun 11 00:29:40 2007
@@ -7354,9 +7354,10 @@
}
if ((flags & F_ALT) &&
- (type == 'x' || type == 'X')) {
- /* When converting under %#x or %#X, there are a number
+ (type == 'x' || type == 'X' || type == 'o')) {
+ /* When converting under %#o, %#x or %#X, there are a number
* of issues that cause pain:
+ * - for %#o, we want a different base marker than C
* - when 0 is being converted, the C standard leaves off
* the '0x' or '0X', which is inconsistent with other
* %#x/%#X conversions and inconsistent with Python's
@@ -7814,7 +7815,7 @@
if (width > len)
width--;
}
- if ((flags & F_ALT) && (c == 'x' || c == 'X')) {
+ if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
if (fill != ' ') {
@@ -7836,7 +7837,7 @@
if (fill == ' ') {
if (sign)
*res++ = sign;
- if ((flags & F_ALT) && (c == 'x' || c == 'X')) {
+ if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) {
assert(pbuf[0] == '0');
assert(pbuf[1] == c);
*res++ = *pbuf++;
Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c (original)
+++ python/branches/p3yk/Python/ast.c Mon Jun 11 00:29:40 2007
@@ -3029,8 +3029,6 @@
#ifndef WITHOUT_COMPLEX
imflag = *end == 'j' || *end == 'J';
#endif
- if (*end == 'l' || *end == 'L')
- return PyLong_FromString((char *)s, (char **)0, 0);
if (s[0] == '0') {
x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
if (x < 0 && errno == 0) {
Modified: python/branches/p3yk/Python/mystrtoul.c
==============================================================================
--- python/branches/p3yk/Python/mystrtoul.c (original)
+++ python/branches/p3yk/Python/mystrtoul.c Mon Jun 11 00:29:40 2007
@@ -91,7 +91,7 @@
** This is a general purpose routine for converting
** an ascii string to an integer in an arbitrary base.
** Leading white space is ignored. If 'base' is zero
-** it looks for a leading 0, 0x or 0X to tell which
+** it looks for a leading 0b, 0o or 0x to tell which
** base. If these are absent it defaults to 10.
** Base must be 0 or between 2 and 36 (inclusive).
** If 'ptr' is non-NULL it will contain a pointer to
@@ -110,29 +110,57 @@
while (*str && isspace(Py_CHARMASK(*str)))
++str;
- /* check for leading 0 or 0x for auto-base or base 16 */
+ /* check for leading 0b, 0o or 0x for auto-base or base 16 */
switch (base) {
- case 0: /* look for leading 0, 0x or 0X */
- if (*str == '0') {
+ case 0: /* look for leading 0b, 0o or 0x */
+ if (*str == '0') {
+ ++str;
+ if (*str == 'x' || *str == 'X') {
++str;
- if (*str == 'x' || *str == 'X') {
- ++str;
- base = 16;
- }
- else
- base = 8;
- }
- else
- base = 10;
- break;
-
- case 16: /* skip leading 0x or 0X */
- if (*str == '0') {
+ base = 16;
+ } else if (*str == 'o' || *str == 'O') {
++str;
- if (*str == 'x' || *str == 'X')
+ base = 8;
+ } else if (*str == 'b' || *str == 'B') {
+ ++str;
+ base = 2;
+ } else {
+ /* skip all zeroes... */
+ while (*str == '0')
+ ++str;
+ while (isspace(Py_CHARMASK(*str)))
++str;
+ if (ptr)
+ *ptr = str;
+ return 0;
}
- break;
+ }
+ else
+ base = 10;
+ break;
+
+ /* even with explicit base, skip leading 0? prefix */
+ case 16:
+ if (*str == '0') {
+ ++str;
+ if (*str == 'x' || *str == 'X')
+ ++str;
+ }
+ break;
+ case 8:
+ if (*str == '0') {
+ ++str;
+ if (*str == 'o' || *str == 'O')
+ ++str;
+ }
+ break;
+ case 2:
+ if(*str == '0') {
+ ++str;
+ if (*str == 'b' || *str == 'B')
+ ++str;
+ }
+ break;
}
/* catch silly bases */
Modified: python/branches/p3yk/setup.py
==============================================================================
--- python/branches/p3yk/setup.py (original)
+++ python/branches/p3yk/setup.py Mon Jun 11 00:29:40 2007
@@ -1499,8 +1499,8 @@
def install(self):
outfiles = install_lib.install(self)
- self.set_file_modes(outfiles, 0644, 0755)
- self.set_dir_modes(self.install_dir, 0755)
+ self.set_file_modes(outfiles, 0o644, 0o755)
+ self.set_dir_modes(self.install_dir, 0o755)
return outfiles
def set_file_modes(self, files, defaultMode, sharedLibMode):
More information about the Python-3000-checkins
mailing list