f



ERROR:root:code for hash md5 was not found

Hi,

We are running are running Python program on Redhat 5.5.

When executing our program we get the following error ( see below).

Any ideas what this is due to?

br,

//mike

/pysibelius/lib/common/
DataTypes.py
Overwriten ...
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/python/lib/python2.7/hashlib.py", line 91, in
__get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found
0
1/11/2012 11:19:32 AM
comp.lang.python 77058 articles. 6 followers. Post Follow

16 Replies
5097 Views

Similar Articles

[PageSpeed] 58

Le 11/01/2012 12:19, mike a �crit :
> Hi,
>
> We are running are running Python program on Redhat 5.5.
>
> When executing our program we get the following error ( see below).
>
> Any ideas what this is due to?

On my computer hashlib has "md5" :



Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> h=hashlib.new("md5")
>>> h.update("Hello")
>>> h.hexdigest()
'd992641f1b2b9c08b569c0a17c4e7cb8'

While if I ask for a hash method that hashlib does not know, I get the 
same error as you :

 >>> g=hashlib.new("bla")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib/python2.6/hashlib.py", line 101, in __hash_new
     return __get_builtin_constructor(name)(string)
   File "/usr/lib/python2.6/hashlib.py", line 80, in 
__get_builtin_constructor
     raise ValueError, "unsupported hash type"
ValueError: unsupported hash type


You should give us a more comprehensive example of your problem.

Laurent

0
moky.math (63)
1/11/2012 11:28:52 AM
On Jan 11, 12:28=A0pm, Laurent Claessens <moky.m...@gmail.com> wrote:
> Le 11/01/2012 12:19, mike a crit :
>
> > Hi,
>
> > We are running are running Python program on Redhat 5.5.
>
> > When executing our program we get the following error ( see below).
>
> > Any ideas what this is due to?
>
> On my computer hashlib has "md5" :
>
> Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>>=
 import hashlib
> >>> h=3Dhashlib.new("md5")
> >>> h.update("Hello")
> >>> h.hexdigest()
>
> 'd992641f1b2b9c08b569c0a17c4e7cb8'
>
> While if I ask for a hash method that hashlib does not know, I get the
> same error as you :
>
> =A0>>> g=3Dhashlib.new("bla")
> Traceback (most recent call last):
> =A0 =A0File "<stdin>", line 1, in <module>
> =A0 =A0File "/usr/lib/python2.6/hashlib.py", line 101, in __hash_new
> =A0 =A0 =A0return __get_builtin_constructor(name)(string)
> =A0 =A0File "/usr/lib/python2.6/hashlib.py", line 80, in
> __get_builtin_constructor
> =A0 =A0 =A0raise ValueError, "unsupported hash type"
> ValueError: unsupported hash type
>
> You should give us a more comprehensive example of your problem.
>
> Laurent

Hi,

Thanks for reply.

I did some more digging and found that our class imports a "yacc.py"
that uses

import re, types, sys, cStringIO, hashlib, os.path

so it has hashlib.

yacc.py seems to be an old version 1.3 ( I found 2.3 -->).

Reading about hashlib it seems to be dependent on os installation of
OpenSSL but I cannot find out how.

br,

//mike

yacc.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
#--------------------------------------------------------------------------=
---
# ply: yacc.py
#
# Author: David M. Beazley (beazley@cs.uchicago.edu)
#         Department of Computer Science
#         University of Chicago
#         Chicago, IL 60637
#
# Copyright (C) 2001, David M. Beazley
#
# $Header: /cvsroot/ply/ply/yacc.py,v 1.15 2002/12/12 21:16:18 beazley
Exp $
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307  USA
#
# See the file COPYING for a complete copy of the LGPL.
#
#
# This implements an LR parser that is constructed from grammar rules
defined
# as Python functions.  Roughly speaking, this module is a cross
between
# John Aycock's Spark system and the GNU bison utility.
#
# Disclaimer:  This is a work in progress. SLR parsing seems to work
fairly
# well and there is extensive error checking. LALR(1) is in progress.
The
# rest of this file is a bit of a mess.  Please pardon the dust.
#
# The current implementation is only somewhat object-oriented. The
# LR parser itself is defined in terms of an object (which allows
multiple
# parsers to co-exist).  However, most of the variables used during
table
# construction are defined in terms of global variables.  Users
shouldn't
# notice unless they are trying to define multiple parsers at the same
# time using threads (in which case they should have their head
examined).
#--------------------------------------------------------------------------=
---

__version__ =3D "1.3"

#--------------------------------------------------------------------------=
---
#                     =3D=3D=3D User configurable parameters =3D=3D=3D
#
# Change these to modify the default behavior of yacc (if you wish)
#--------------------------------------------------------------------------=
---

yaccdebug   =3D 1                # Debugging mode.  If set, yacc
generates a
                               # a 'parser.out' file in the current
directory

debug_file  =3D 'parser.out'     # Default name of the debugging file
tab_module  =3D 'parsetab'       # Default name of the table module
default_lr  =3D 'SLR'            # Default LR table generation method

error_count =3D 3                # Number of symbols that must be
shifted to leave recovery mode

import re, types, sys, cStringIO, hashlib, os.path

# Exception raised for yacc-related errors
class YaccError(Exception):   pass

#--------------------------------------------------------------------------=
---
#                        =3D=3D=3D  LR Parsing Engine =3D=3D=3D
#
# The following classes are used for the LR parser itself.  These are
not
# used during table construction and are independent of the actual LR
# table generation algorithm
#--------------------------------------------------------------------------=
---

# This class is used to hold non-terminal grammar symbols during
parsing.
# It normally has the following attributes set:
#        .type       =3D Grammar symbol type
#        .value      =3D Symbol value
#        .lineno     =3D Starting line number
#        .endlineno  =3D Ending line number (optional, set
automatically)

class YaccSymbol:
    def __str__(self):    return self.type
    def __repr__(self):   return str(self)

# This class is a wrapper around the objects actually passed to each
# grammar rule.   Index lookup and assignment actually assign the
# .value attribute of the underlying YaccSymbol object.
# The lineno() method returns the line number of a given
# item (or 0 if not defined).   The linespan() method returns
# a tuple of (startline,endline) representing the range of lines
# for a symbol.

class YaccSlice:
    def __init__(self,s):
        self.slice =3D s
        self.pbstack =3D []

    def __getitem__(self,n):
        return self.slice[n].value

    def __setitem__(self,n,v):
        self.slice[n].value =3D v

    def lineno(self,n):
        return getattr(self.slice[n],"lineno",0)

    def linespan(self,n):
        startline =3D getattr(self.slice[n],"lineno",0)
        endline =3D getattr(self.slice[n],"endlineno",startline)
        return startline,endline

    def pushback(self,n):
        if n <=3D 0:
            raise ValueError, "Expected a positive value"
        if n > (len(self.slice)-1):
            raise ValueError, "Can't push %d tokens. Only %d are
available." % (n,len(self.slice)-1)
        for i in range(0,n):
            self.pbstack.append(self.slice[-i-1])

# The LR Parsing engine.   This is defined as a class so that multiple
parsers
# can exist in the same process.  A user never instantiates this
directly.
# Instead, the global yacc() function should be used to create a
suitable Parser
# object.

class Parser:
    def __init__(self,magic=3DNone):

        # This is a hack to keep users from trying to instantiate a
Parser
        # object directly.

        if magic !=3D "xyzzy":
            raise YaccError, "Can't instantiate Parser. Use yacc()
instead."

        # Reset internal state
        self.productions =3D None          # List of productions
        self.errorfunc   =3D None          # Error handling function
        self.action      =3D { }           # LR Action table
        self.goto        =3D { }           # LR goto table
        self.require     =3D { }           # Attribute require table
        self.method      =3D "Unknown LR"  # Table construction method
used

    def errok(self):
        self.errorcount =3D 0

    def restart(self):
        del self.statestack[:]
        del self.symstack[:]
        sym =3D YaccSymbol()
        sym.type =3D '$'
        self.symstack.append(sym)
        self.statestack.append(0)

    def parse(self,input=3DNone,lexer=3DNone,debug=3D0):
        lookahead =3D None                 # Current lookahead symbol
        lookaheadstack =3D [ ]             # Stack of lookahead symbols
        actions =3D self.action            # Local reference to action
table
        goto    =3D self.goto              # Local reference to goto
table
        prod    =3D self.productions       # Local reference to
production list
        pslice  =3D YaccSlice(None)        # Slice object passed to
grammar rules
        pslice.parser =3D self             # Parser object
        self.errorcount =3D 0              # Used during error recovery

        # If no lexer was given, we will try to use the lex module
        if not lexer:
            import lex as lexer

        pslice.lexer =3D lexer

        # If input was supplied, pass to lexer
        if input:
            lexer.input(input)

        # Tokenize function
        get_token =3D lexer.token

        statestack =3D [ ]                # Stack of parsing states
        self.statestack =3D statestack
        symstack   =3D [ ]                # Stack of grammar symbols
        self.symstack =3D symstack

        errtoken   =3D None               # Err token

        # The start state is assumed to be (0,$)
        statestack.append(0)
        sym =3D YaccSymbol()
        sym.type =3D '$'
        symstack.append(sym)

        while 1:
            # Get the next symbol on the input.  If a lookahead symbol
            # is already set, we just use that. Otherwise, we'll pull
            # the next token off of the lookaheadstack or from the
lexer
            if not lookahead:
                if not lookaheadstack:
                    lookahead =3D get_token()     # Get the next token
                else:
                    lookahead =3D lookaheadstack.pop()
                if not lookahead:
                    lookahead =3D YaccSymbol()
                    lookahead.type =3D '$'
            if debug:
                print "#%-20s : %s" % (lookahead, [xx.type for xx in
symstack])

            # Check the action table
            s =3D statestack[-1]
            ltype =3D lookahead.type
            t =3D actions.get((s,ltype),None)

            if t is not None:
                if t > 0:
                    # shift a symbol on the stack
                    if ltype =3D=3D '$':
                        # Error, end of input
                        print "#yacc: Parse error. EOF"
                        return
                    statestack.append(t)
                    symstack.append(lookahead)
                    lookahead =3D None

                    # Decrease error count on successful shift
                    if self.errorcount > 0:
                        self.errorcount -=3D 1

                    continue

                if t < 0:
                    # reduce a symbol on the stack, emit a production
                    p =3D prod[-t]
                    pname =3D p.name
                    plen  =3D p.len

                    # Get production function
                    sym =3D YaccSymbol()
                    sym.type =3D pname       # Production name
                    sym.value =3D None

                    if plen:
                        targ =3D symstack[-plen-1:]
                        targ[0] =3D sym
                        try:
                            sym.lineno =3D targ[1].lineno
                            sym.endlineno =3D
getattr(targ[-1],"endlineno",targ[-1].lineno)
                        except AttributeError:
                            sym.lineno =3D 0
                        del symstack[-plen:]
                        del statestack[-plen:]
                    else:
                        sym.lineno =3D 0
                        targ =3D [ sym ]
                    pslice.slice =3D targ
                    pslice.pbstack =3D []
                    # Call the grammar rule with our special slice
object
                    p.func(pslice)

                    # Validate attributes of the resulting value
attribute
#                  if require:
#                      try:
#                          t0 =3D targ[0]
#                          r =3D Requires.get(t0.type,None)
#                          t0d =3D t0.__dict__
#                          if r:
#                              for field in r:
#                                  tn =3D t0
#                                  for fname in field:
#                                      try:
#                                          tf =3D tn.__dict__
#                                          tn =3D tf.get(fname)
#                                      except StandardError:
#                                          tn =3D None
#                                      if not tn:
#                                          print "#%s:%d: Rule %s
doesn't set required attribute '%s'" % \
#
(p.file,p.line,p.name,".".join(field))
#                      except TypeError,LookupError:
#                          print "#Bad requires directive " % r
#                          pass


                    # If there was a pushback, put that on the stack
                    if pslice.pbstack:
                        lookaheadstack.append(lookahead)
                        for _t in pslice.pbstack:
                            lookaheadstack.append(_t)
                        lookahead =3D None

                    symstack.append(sym)
                    statestack.append(goto[statestack[-1],pname])
                    continue

                if t =3D=3D 0:
                    n =3D symstack[-1]
                    return getattr(n,"value",None)

            if t =3D=3D None:
                # We have some kind of parsing error here.  To handle
this,
                # we are going to push the current token onto the
tokenstack
                # and replace it with an 'error' token.  If there are
any synchronization
                # rules, they may catch it.
                #
                # In addition to pushing the error token, we call call
the user defined p_error()
                # function if this is the first syntax error.   This
function is only called
                # if errorcount =3D=3D 0.

                if not self.errorcount:
                    self.errorcount =3D error_count
                    errtoken =3D lookahead
                    if errtoken.type =3D=3D '$':
                        errtoken =3D None               # End of file!
                    if self.errorfunc:
                        global errok,token,restart
                        errok =3D self.errok        # Set some special
functions available in error recovery
                        token =3D get_token
                        restart =3D self.restart
                        tok =3D self.errorfunc(errtoken)
                        del errok, token, restart   # Delete special
functions

                        if not self.errorcount:
                            # User must have done some kind of panic
mode recovery on their own.  The returned token
                            # is the next lookahead
                            lookahead =3D tok
                            errtoken =3D None
                            continue
                    else:
                        if errtoken:
                            if hasattr(errtoken,"lineno"): lineno =3D
lookahead.lineno
                            else: lineno =3D 0
                            if lineno:
                                print "#yacc: Syntax error at line %d,
token=3D%s" % (lineno, errtoken.type)
                            else:
                                print "#yacc: Syntax error, token=3D%s"
% errtoken.type
                        else:
                            print "#yacc: Parse error in input. EOF"
                            return

                else:
                    self.errorcount =3D error_count

                # case 1:  the statestack only has 1 entry on it.  If
we're in this state, the
                # entire parse has been rolled back and we're
completely hosed.   The token is
                # discarded and we just keep going.

                if len(statestack) <=3D 1 and lookahead.type !=3D '$':
                    lookahead =3D None
                    errtoken =3D None
                    # Nuke the pushback stack
                    del lookaheadstack[:]
                    continue

                # case 2: the statestack has a couple of entries on
it, but we're
                # at the end of the file. nuke the top entry and
generate an error token

                # Start nuking entries on the stack
                if lookahead.type =3D=3D '$':
                    # Whoa. We're really hosed here. Bail out
                    return

                if lookahead.type !=3D 'error':
                    sym =3D symstack[-1]
                    if sym.type =3D=3D 'error':
                        # Hmmm. Error is on top of stack, we'll just
nuke input
                        # symbol and continue
                        lookahead =3D None
                        continue
                    t =3D YaccSymbol()
                    t.type =3D 'error'
                    if hasattr(lookahead,"lineno"):
                        t.lineno =3D lookahead.lineno
                    t.value =3D lookahead
                    lookaheadstack.append(lookahead)
                    lookahead =3D t
                else:
                    symstack.pop()
                    statestack.pop()

                continue

            # Call an error function here
            raise RuntimeError, "yacc: internal parser error!!!\n"

#
---------------------------------------------------------------------------=
--
#                          =3D=3D=3D Parser Construction =3D=3D=3D
#
# The following functions and variables are used to implement the
yacc() function
# itself.   This is pretty hairy stuff involving lots of error
checking,
# construction of LR items, kernels, and so forth.   Although a lot of
# this work is done using global variables, the resulting Parser
object
# is completely self contained--meaning that it is safe to repeatedly
# call yacc() with different grammars in the same application.
#
---------------------------------------------------------------------------=
--

#
---------------------------------------------------------------------------=
--
# validate_file()
#
# This function checks to see if there are duplicated p_rulename()
functions
# in the parser module file.  Without this function, it is really easy
for
# users to make mistakes by cutting and pasting code fragments (and
it's a real
# bugger to try and figure out why the resulting parser doesn't
work).  Therefore,
# we just do a little regular expression pattern matching of def
statements
# to try and detect duplicates.
#
---------------------------------------------------------------------------=
--

def validate_file(filename):
    base,ext =3D os.path.splitext(filename)
    if ext !=3D '.py': return 1          # No idea. Assume it's okay.

    try:
        f =3D open(filename)
        lines =3D f.readlines()
        f.close()
    except IOError:
        return 1                       # Oh well

    # Match def p_funcname(
    fre =3D re.compile(r'\s*def\s+(p_[a-zA-Z_0-9]*)\(')
    counthash =3D { }
    linen =3D 1
    noerror =3D 1
    for l in lines:
        m =3D fre.match(l)
        if m:
            name =3D m.group(1)
            prev =3D counthash.get(name)
            if not prev:
                counthash[name] =3D linen
            else:
                print "#%s:%d: Function %s redefined. Previously
defined on line %d" % (filename,linen,name,prev)
                noerror =3D 0
        linen +=3D 1
    return noerror

# This function looks for functions that might be grammar rules, but
which don't have the proper p_suffix.
def validate_dict(d):
    for n,v in d.items():
        if n[0:2] =3D=3D 'p_' and isinstance(v,types.FunctionType):
continue
        if n[0:2] =3D=3D 't_': continue

        if n[0:2] =3D=3D 'p_':
            print "#yacc: Warning. '%s' not defined as a function" % n
        if isinstance(v,types.FunctionType) and
v.func_code.co_argcount =3D=3D 1:
            try:
                doc =3D v.__doc__.split(" ")
                if doc[1] =3D=3D ':':
                    print "#%s:%d: Warning. Possible grammar rule '%s'
defined without p_ prefix." % (v.func_code.co_filename,
v.func_code.co_firstlineno,n)
            except StandardError:
                pass

#
---------------------------------------------------------------------------=
--
#                           =3D=3D=3D GRAMMAR FUNCTIONS =3D=3D=3D
#
# The following global variables and functions are used to store,
manipulate,
# and verify the grammar rules specified by the user.
#
---------------------------------------------------------------------------=
--

# Initialize all of the global variables used during grammar
construction
def initialize_vars():
    global Productions, Prodnames, Prodmap, Terminals
    global Nonterminals, First, Follow, Precedence, LRitems
    global Errorfunc, Signature, Requires

    Productions  =3D [None]  # A list of all of the productions.  The
first
                           # entry is always reserved for the purpose
of
                           # building an augmented grammar

    Prodnames    =3D { }     # A dictionary mapping the names of
nonterminals to a list of all
                           # productions of that nonterminal.

    Prodmap      =3D { }     # A dictionary that is only used to detect
duplicate
                           # productions.

    Terminals    =3D { }     # A dictionary mapping the names of
terminal symbols to a
                           # list of the rules where they are used.

    Nonterminals =3D { }     # A dictionary mapping names of
nonterminals to a list
                           # of rule numbers where they are used.

    First        =3D { }     # A dictionary of precomputed FIRST(x)
symbols

    Follow       =3D { }     # A dictionary of precomputed FOLLOW(x)
symbols

    Precedence   =3D { }     # Precedence rules for each terminal.
Contains tuples of the
                           # form ('right',level) or ('nonassoc',
level) or ('left',level)

    LRitems      =3D [ ]     # A list of all LR items for the grammar.
These are the
                           # productions with the "dot" like E -> E .
PLUS E

    Errorfunc    =3D None    # User defined error handler

    Signature    =3D hashlib.md5()   # Digital signature of the grammar
rules, precedence
                               # and other information.  Used to
determined when a
                               # parsing table needs to be
regenerated.

    Requires     =3D { }     # Requires list

    # File objects used when creating the parser.out debugging file
    global _vf, _vfc
    _vf           =3D cStringIO.StringIO()
    _vfc          =3D cStringIO.StringIO()

#
---------------------------------------------------------------------------=
--
# class Production:
#
# This class stores the raw information about a single production or
grammar rule.
# It has a few required attributes:
#
#       name     - Name of the production (nonterminal)
#       prod     - A list of symbols making up its production
#       number   - Production number.
#
# In addition, a few additional attributes are used to help with
debugging or
# optimization of table generation.
#
#       file     - File where production action is defined.
#       lineno   - Line number where action is defined
#       func     - Action function
#       prec     - Precedence level
#       lr_next  - Next LR item. Example, if we are ' E -> E . PLUS E'
#                  then lr_next refers to 'E -> E PLUS . E'
#       lr_index - LR item index (location of the ".") in the prod
list.
#       len      - Length of the production (number of symbols on
right hand side)
#
---------------------------------------------------------------------------=
--

class Production:
    def __init__(self,**kw):
        for k,v in kw.items():
            setattr(self,k,v)
        self.lr_index =3D -1
        self.lr0_added =3D 0    # Flag indicating whether or not added
to LR0 closure
        self.usyms =3D [ ]

    def __str__(self):
        if self.prod:
            s =3D "%s -> %s" % (self.name," ".join(self.prod))
        else:
            s =3D "%s -> <empty>" % self.name
        return s

    def __repr__(self):
        return str(self)

    # Compute lr_items from the production
    def lr_item(self,n):
        if n > len(self.prod): return None
        p =3D Production()
        p.name =3D self.name
        p.prod =3D list(self.prod)
        p.number =3D self.number
        p.lr_index =3D n
        p.prod.insert(n,".")
        p.prod =3D tuple(p.prod)
        p.len =3D len(p.prod)
        p.usyms =3D self.usyms

        # Precompute list of productions immediately following
        try:
            p.lrafter =3D Prodnames[p.prod[n+1]]
        except (IndexError,KeyError),e:
            p.lrafter =3D []
        try:
            p.lrbefore =3D p.prod[n-1]
        except IndexError:
            p.lrbefore =3D None

        return p

class MiniProduction:
    pass

# Utility function
def is_identifier(s):
    for c in s:
        if not (c.isalnum() or c =3D=3D '_'): return 0
    return 1

#
---------------------------------------------------------------------------=
--
# add_production()
#
# Given an action function, this function assembles a production rule.
# The production rule is assumed to be found in the function's
docstring.
# This rule has the general syntax:
#
#              name1 ::=3D production1
#                     |  production2
#                     |  production3
#                    ...
#                     |  productionn
#              name2 ::=3D production1
#                     |  production2
#                    ...
#
---------------------------------------------------------------------------=
--

def add_production(f,file,line,prodname,syms):

    if Terminals.has_key(prodname):
        print "#%s:%d: Illegal rule name '%s'. Already defined as a
token." % (file,line,prodname)
        return -1
    if prodname =3D=3D 'error':
        print "#%s:%d: Illegal rule name '%s'. error is a reserved
word." % (file,line,prodname)
        return -1

    if not is_identifier(prodname):
        print "#%s:%d: Illegal rule name '%s'" % (file,line,prodname)
        return -1

    for s in syms:
        if not is_identifier(s) and s !=3D '%prec':
            print "#%s:%d: Illegal name '%s' in rule '%s'" %
(file,line,s, prodname)
            return -1

    # See if the rule is already in the rulemap
    map =3D "%s -> %s" % (prodname,syms)
    if Prodmap.has_key(map):
        m =3D Prodmap[map]
        print "#%s:%d: Duplicate rule %s." % (file,line, m)
        print "#%s:%d: Previous definition at %s:%d" % (file,line,
m.file, m.line)
        return -1

    p =3D Production()
    p.name =3D prodname
    p.prod =3D syms
    p.file =3D file
    p.line =3D line
    p.func =3D f
    p.number =3D len(Productions)


    Productions.append(p)
    Prodmap[map] =3D p
    if not Nonterminals.has_key(prodname):
        Nonterminals[prodname] =3D [ ]

    # Add all terminals to Terminals
    i =3D 0
    while i < len(p.prod):
        t =3D p.prod[i]
        if t =3D=3D '%prec':
            try:
                precname =3D p.prod[i+1]
            except IndexError:
                print "#%s:%d: Syntax error. Nothing follows %%prec."
% (p.file,p.line)
                return -1

            prec =3D Precedence.get(precname,None)
            if not prec:
                print "#%s:%d: Nothing known about the precedence of
'%s'" % (p.file,p.line,precname)
                return -1
            else:
                p.prec =3D prec
            del p.prod[i]
            del p.prod[i]
            continue

        if Terminals.has_key(t):
            Terminals[t].append(p.number)
            # Is a terminal.  We'll assign a precedence to p based on
this
            if not hasattr(p,"prec"):
                p.prec =3D Precedence.get(t,('right',0))
        else:
            if not Nonterminals.has_key(t):
                Nonterminals[t] =3D [ ]
            Nonterminals[t].append(p.number)
        i +=3D 1

    if not hasattr(p,"prec"):
        p.prec =3D ('right',0)

    # Set final length of productions
    p.len  =3D len(p.prod)
    p.prod =3D tuple(p.prod)

    # Calculate unique syms in the production
    p.usyms =3D [ ]
    for s in p.prod:
        if s not in p.usyms:
            p.usyms.append(s)

    # Add to the global productions list
    try:
        Prodnames[p.name].append(p)
    except KeyError:
        Prodnames[p.name] =3D [ p ]
    return 0

# Given a raw rule function, this function rips out its doc string
# and adds rules to the grammar

def add_function(f):
    line =3D f.func_code.co_firstlineno
    file =3D f.func_code.co_filename
    error =3D 0

    if f.func_code.co_argcount > 1:
        print "#%s:%d: Rule '%s' has too many arguments." %
(file,line,f.__name__)
        return -1

    if f.func_code.co_argcount < 1:
        print "#%s:%d: Rule '%s' requires an argument." %
(file,line,f.__name__)
        return -1

    if f.__doc__:
        # Split the doc string into lines
        pstrings =3D f.__doc__.splitlines()
        lastp =3D None
        dline =3D line
        for ps in pstrings:
            dline +=3D 1
            p =3D ps.split()
            if not p: continue
            try:
                if p[0] =3D=3D '|':
                    # This is a continuation of a previous rule
                    if not lastp:
                        print "#%s:%d: Misplaced '|'." % (file,dline)
                        return -1
                    prodname =3D lastp
                    if len(p) > 1:
                        syms =3D p[1:]
                    else:
                        syms =3D [ ]
                else:
                    prodname =3D p[0]
                    lastp =3D prodname
                    assign =3D p[1]
                    if len(p) > 2:
                        syms =3D p[2:]
                    else:
                        syms =3D [ ]
                    if assign !=3D ':' and assign !=3D '::=3D':
                        print "#%s:%d: Syntax error. Expected ':'" %
(file,dline)
                        return -1
                e =3D add_production(f,file,dline,prodname,syms)
                error +=3D e
            except StandardError:
                print "#%s:%d: Syntax error in rule '%s'" %
(file,dline,ps)
                error -=3D 1
    else:
        print "#%s:%d: No documentation string specified in function
'%s'" % (file,line,f.__name__)
    return error


# Cycle checking code (Michael Dyck)

def compute_reachable():
    '''
    Find each symbol that can be reached from the start symbol.
    Print a warning for any nonterminals that can't be reached.
    (Unused terminals have already had their warning.)
    '''
    Reachable =3D { }
    for s in Terminals.keys() + Nonterminals.keys():
        Reachable[s] =3D 0

    mark_reachable_from( Productions[0].prod[0], Reachable )

    for s in Nonterminals.keys():
        if not Reachable[s]:
            print "#yacc: Symbol '%s' is unreachable." % s

def mark_reachable_from(s, Reachable):
    '''
    Mark all symbols that are reachable from symbol s.
    '''
    if Reachable[s]:
        # We've already reached symbol s.
        return
    Reachable[s] =3D 1
    for p in Prodnames.get(s,[]):
        for r in p.prod:
            mark_reachable_from(r, Reachable)

#
---------------------------------------------------------------------------=
--
# compute_terminates()
#
# This function looks at the various parsing rules and tries to detect
# infinite recursion cycles (grammar rules where there is no possible
way
# to derive a string of only terminals).
#
---------------------------------------------------------------------------=
--
def compute_terminates():
    '''
    Raise an error for any symbols that don't terminate.
    '''
    Terminates =3D {}

    # Terminals:
    for t in Terminals.keys():
        Terminates[t] =3D 1

    Terminates['$'] =3D 1

    # Nonterminals:

    # Initialize to false:
    for n in Nonterminals.keys():
        Terminates[n] =3D 0

    # Then propagate termination until no change:
    while 1:
        some_change =3D 0
        for (n,pl) in Prodnames.items():
            # Nonterminal n terminates iff any of its productions
terminates.
            for p in pl:
                # Production p terminates iff all of its rhs symbols
terminate.
                for s in p.prod:
                    if not Terminates[s]:
                        # The symbol s does not terminate,
                        # so production p does not terminate.
                        p_terminates =3D 0
                        break
                else:
                    # didn't break from the loop,
                    # so every symbol s terminates
                    # so production p terminates.
                    p_terminates =3D 1

                if p_terminates:
                    # symbol n terminates!
                    if not Terminates[n]:
                        Terminates[n] =3D 1
                        some_change =3D 1
                    # Don't need to consider any more productions for
this n.
                    break

        if not some_change:
            break

    some_error =3D 0
    for (s,terminates) in Terminates.items():
        if not terminates:
            if not Prodnames.has_key(s) and not Terminals.has_key(s)
and s !=3D 'error':
                # s is used-but-not-defined, and we've already warned
of that,
                # so it would be overkill to say that it's also non-
terminating.
                pass
            else:
                print "#yacc: Infinite recursion detected for symbol
'%s'." % s
                some_error =3D 1

    return some_error

#
---------------------------------------------------------------------------=
--
# verify_productions()
#
# This function examines all of the supplied rules to see if they seem
valid.
#
---------------------------------------------------------------------------=
--
def verify_productions(cycle_check=3D1):
    error =3D 0
    for p in Productions:
        if not p: continue

        for s in p.prod:
            if not Prodnames.has_key(s) and not Terminals.has_key(s)
and s !=3D 'error':
                print "#%s:%d: Symbol '%s' used, but not defined as a
token or a rule." % (p.file,p.line,s)
                error =3D 1
                continue

    unused_tok =3D 0
    # Now verify all of the tokens
    if yaccdebug:
        _vf.write("Unused terminals:\n\n")
    for s,v in Terminals.items():
        if s !=3D 'error' and not v:
            print "#yacc: Warning. Token '%s' defined, but not used."
% s
            if yaccdebug: _vf.write("   %s\n"% s)
            unused_tok +=3D 1

    # Print out all of the productions
    if yaccdebug:
        _vf.write("\nGrammar\n\n")
        for i in range(1,len(Productions)):
            _vf.write("Rule %-5d %s\n" % (i, Productions[i]))

    unused_prod =3D 0
    # Verify the use of all productions
    for s,v in Nonterminals.items():
        if not v:
            p =3D Prodnames[s][0]
            print "#%s:%d: Warning. Rule '%s' defined, but not used."
% (p.file,p.line, s)
            unused_prod +=3D 1


    if unused_tok =3D=3D 1:
        print "#yacc: Warning. There is 1 unused token."
    if unused_tok > 1:
        print "#yacc: Warning. There are %d unused tokens." %
unused_tok

    if unused_prod =3D=3D 1:
        print "#yacc: Warning. There is 1 unused rule."
    if unused_prod > 1:
        print "#yacc: Warning. There are %d unused rules." %
unused_prod

    if yaccdebug:
        _vf.write("\nTerminals, with rules where they appear\n\n")
        ks =3D Terminals.keys()
        ks.sort()
        for k in ks:
            _vf.write("%-20s : %s\n" % (k, " ".join([str(s) for s in
Terminals[k]])))
        _vf.write("\nNonterminals, with rules where they appear\n\n")
        ks =3D Nonterminals.keys()
        ks.sort()
        for k in ks:
            _vf.write("%-20s : %s\n" % (k, " ".join([str(s) for s in
Nonterminals[k]])))

    if (cycle_check):
        compute_reachable()
        error +=3D compute_terminates()
#        error +=3D check_cycles()
    return error

#
---------------------------------------------------------------------------=
--
# build_lritems()
#
# This function walks the list of productions and builds a complete
set of the
# LR items.  The LR items are stored in two ways:  First, they are
uniquely
# numbered and placed in the list _lritems.  Second, a linked list of
LR items
# is built for each production.  For example:
#
#   E -> E PLUS E
#
# Creates the list
#
#  [E -> . E PLUS E, E -> E . PLUS E, E -> E PLUS . E, E -> E PLUS
E . ]
#
---------------------------------------------------------------------------=
--

def build_lritems():
    for p in Productions:
        lastlri =3D p
        lri =3D p.lr_item(0)
        i =3D 0
        while 1:
            lri =3D p.lr_item(i)
            lastlri.lr_next =3D lri
            if not lri: break
            lri.lr_num =3D len(LRitems)
            LRitems.append(lri)
            lastlri =3D lri
            i +=3D 1

    # In order for the rest of the parser generator to work, we need
to
    # guarantee that no more lritems are generated.  Therefore, we
nuke
    # the p.lr_item method.  (Only used in debugging)
    # Production.lr_item =3D None

#
---------------------------------------------------------------------------=
--
# add_precedence()
#
# Given a list of precedence rules, add to the precedence table.
#
---------------------------------------------------------------------------=
--

def add_precedence(plist):
    plevel =3D 0
    error =3D 0
    for p in plist:
        plevel +=3D 1
        try:
            prec =3D p[0]
            terms =3D p[1:]
            if prec !=3D 'left' and prec !=3D 'right' and prec !=3D
'nonassoc':
                print "#yacc: Invalid precedence '%s'" % prec
                return -1
            for t in terms:
                if Precedence.has_key(t):
                    print "#yacc: Precedence already specified for
terminal '%s'" % t
                    error +=3D 1
                    continue
                Precedence[t] =3D (prec,plevel)
        except:
            print "#yacc: Invalid precedence table."
            error +=3D 1

    return error

#
---------------------------------------------------------------------------=
--
# augment_grammar()
#
# Compute the augmented grammar.  This is just a rule S' -> start
where start
# is the starting symbol.
#
---------------------------------------------------------------------------=
--

def augment_grammar(start=3DNone):
    if not start:
        start =3D Productions[1].name
    Productions[0] =3D
Production(name=3D"S'",prod=3D[start],number=3D0,len=3D1,prec=3D('right',
0),func=3DNone)
    Productions[0].usyms =3D [ start ]
    Nonterminals[start].append(0)


#
-------------------------------------------------------------------------
# first()
#
# Compute the value of FIRST1(beta) where beta is a tuple of symbols.
#
# During execution of compute_first1, the result may be incomplete.
# Afterward (e.g., when called from compute_follow()), it will be
complete.
#
-------------------------------------------------------------------------
def first(beta):

    # We are computing First(x1,x2,x3,...,xn)
    result =3D [ ]
    for x in beta:
        x_produces_empty =3D 0

        # Add all the non-<empty> symbols of First[x] to the result.
        for f in First[x]:
            if f =3D=3D '<empty>':
                x_produces_empty =3D 1
            else:
                if f not in result: result.append(f)

        if x_produces_empty:
            # We have to consider the next x in beta,
            # i.e. stay in the loop.
            pass
        else:
            # We don't have to consider any further symbols in beta.
            break
    else:
        # There was no 'break' from the loop,
        # so x_produces_empty was true for all x in beta,
        # so beta produces empty as well.
        result.append('<empty>')

    return result


# FOLLOW(x)
# Given a non-terminal.  This function computes the set of all symbols
# that might follow it.  Dragon book, p. 189.

def compute_follow(start=3DNone):
    # Add '$' to the follow list of the start symbol
    for k in Nonterminals.keys():
        Follow[k] =3D [ ]

    if not start:
        start =3D Productions[1].name

    Follow[start] =3D [ '$' ]

    while 1:
        didadd =3D 0
        for p in Productions[1:]:
            # Here is the production set
            for i in range(len(p.prod)):
                B =3D p.prod[i]
                if Nonterminals.has_key(B):
                    # Okay. We got a non-terminal in a production
                    fst =3D first(p.prod[i+1:])
                    hasempty =3D 0
                    for f in fst:
                        if f !=3D '<empty>' and f not in Follow[B]:
                            Follow[B].append(f)
                            didadd =3D 1
                        if f =3D=3D '<empty>':
                            hasempty =3D 1
                    if hasempty or i =3D=3D (len(p.prod)-1):
                        # Add elements of follow(a) to follow(b)
                        for f in Follow[p.name]:
                            if f not in Follow[B]:
                                Follow[B].append(f)
                                didadd =3D 1
        if not didadd: break

    if 0 and yaccdebug:
        _vf.write('\nFollow:\n')
        for k in Nonterminals.keys():
            _vf.write("%-20s : %s\n" % (k, " ".join([str(s) for s in
Follow[k]])))

#
-------------------------------------------------------------------------
# compute_first1()
#
# Compute the value of FIRST1(X) for all symbols
#
-------------------------------------------------------------------------
def compute_first1():

    # Terminals:
    for t in Terminals.keys():
        First[t] =3D [t]

    First['$'] =3D ['$']
    First['#'] =3D ['#'] # what's this for?

    # Nonterminals:

    # Initialize to the empty set:
    for n in Nonterminals.keys():
        First[n] =3D []

    # Then propagate symbols until no change:
    while 1:
        some_change =3D 0
        for n in Nonterminals.keys():
            for p in Prodnames[n]:
                for f in first(p.prod):
                    if f not in First[n]:
                        First[n].append( f )
                        some_change =3D 1
        if not some_change:
            break

    if 0 and yaccdebug:
        _vf.write('\nFirst:\n')
        for k in Nonterminals.keys():
            _vf.write("%-20s : %s\n" %
                (k, " ".join([str(s) for s in First[k]])))

#
---------------------------------------------------------------------------=
--
#                           =3D=3D=3D SLR Generation =3D=3D=3D
#
# The following functions are used to construct SLR (Simple LR)
parsing tables
# as described on p.221-229 of the dragon book.
#
---------------------------------------------------------------------------=
--

# Global variables for the LR parsing engine
def lr_init_vars():
    global _lr_action, _lr_goto, _lr_method
    global _lr_goto_cache

    _lr_action       =3D { }        # Action table
    _lr_goto         =3D { }        # Goto table
    _lr_method       =3D "Unknown"  # LR method used
    _lr_goto_cache   =3D { }

# Compute the LR(0) closure operation on I, where I is a set of LR(0)
items.
# prodlist is a list of productions.

_add_count =3D 0       # Counter used to detect cycles

def lr0_closure(I):
    global _add_count

    _add_count +=3D 1
    prodlist =3D Productions

    # Add everything in I to J
    J =3D I[:]
    didadd =3D 1
    while didadd:
        didadd =3D 0
        for j in J:
            for x in j.lrafter:
                if x.lr0_added =3D=3D _add_count: continue
                # Add B --> .G to J
                J.append(x.lr_next)
                x.lr0_added =3D _add_count
                didadd =3D 1

    return J

# Compute the LR(0) goto function goto(I,X) where I is a set
# of LR(0) items and X is a grammar symbol.   This function is written
# in a way that guarantees uniqueness of the generated goto sets
# (i.e. the same goto set will never be returned as two different
Python
# objects).  With uniqueness, we can later do fast set comparisons
using
# id(obj) instead of element-wise comparison.

def lr0_goto(I,x):
    # First we look for a previously cached entry
    g =3D _lr_goto_cache.get((id(I),x),None)
    if g: return g

    # Now we generate the goto set in a way that guarantees uniqueness
    # of the result

    s =3D _lr_goto_cache.get(x,None)
    if not s:
        s =3D { }
        _lr_goto_cache[x] =3D s

    gs =3D [ ]
    for p in I:
        n =3D p.lr_next
        if n and n.lrbefore =3D=3D x:
            s1 =3D s.get(id(n),None)
            if not s1:
                s1 =3D { }
                s[id(n)] =3D s1
            gs.append(n)
            s =3D s1
    g =3D s.get('$',None)
    if not g:
        if gs:
            g =3D lr0_closure(gs)
            s['$'] =3D g
        else:
            s['$'] =3D gs
    _lr_goto_cache[(id(I),x)] =3D g
    return g

# Compute the kernel of a set of LR(0) items
def lr0_kernel(I):
    KI =3D [ ]
    for p in I:
        if p.name =3D=3D "S'" or p.lr_index > 0 or p.len =3D=3D 0:
            KI.append(p)

    return KI

_lr0_cidhash =3D { }

# Compute the LR(0) sets of item function
def lr0_items():

    C =3D [ lr0_closure([Productions[0].lr_next]) ]
    i =3D 0
    for I in C:
        _lr0_cidhash[id(I)] =3D i
        i +=3D 1

    # Loop over the items in C and each grammar symbols
    i =3D 0
    while i < len(C):
        I =3D C[i]
        i +=3D 1

        # Collect all of the symbols that could possibly be in the
goto(I,X) sets
        asyms =3D { }
        for ii in I:
            for s in ii.usyms:
                asyms[s] =3D None

        for x in asyms.keys():
            g =3D lr0_goto(I,x)
            if not g:  continue
            if _lr0_cidhash.has_key(id(g)): continue
            _lr0_cidhash[id(g)] =3D len(C)
            C.append(g)

    return C

#
---------------------------------------------------------------------------=
--
# slr_parse_table()
#
# This function constructs an SLR table.
#
---------------------------------------------------------------------------=
--
def slr_parse_table():
    global _lr_method
    goto =3D _lr_goto           # Goto array
    action =3D _lr_action       # Action array
    actionp =3D { }             # Action production array (temporary)

    _lr_method =3D "SLR"

    n_srconflict =3D 0
    n_rrconflict =3D 0

    print "#yacc: Generating SLR parsing table..."
    if yaccdebug:
        _vf.write("\n\nParsing method: SLR\n\n")

    # Step 1: Construct C =3D { I0, I1, ... IN}, collection of LR(0)
items
    # This determines the number of states

    C =3D lr0_items()

    # Build the parser table, state by state
    st =3D 0
    for I in C:
        # Loop over each production in I
        actlist =3D [ ]              # List of actions

        if yaccdebug:
            _vf.write("\nstate %d\n\n" % st)
            for p in I:
                _vf.write("    (%d) %s\n" % (p.number, str(p)))
            _vf.write("\n")

        for p in I:
            try:
                if p.prod[-1] =3D=3D ".":
                    if p.name =3D=3D "S'":
                        # Start symbol. Accept!
                        action[st,"$"] =3D 0
                        actionp[st,"$"] =3D p
                    else:
                        # We are at the end of a production.  Reduce!
                        for a in Follow[p.name]:
                            actlist.append((a,p,"reduce using rule %d
(%s)" % (p.number,p)))
                            r =3D action.get((st,a),None)
                            if r is not None:
                                # Whoa. Have a shift/reduce or reduce/
reduce conflict
                                if r > 0:
                                    # Need to decide on shift or
reduce here
                                    # By default we favor shifting.
Need to add
                                    # some precedence rules here.
                                    sprec,slevel =3D
Productions[actionp[st,a].number].prec
                                    rprec,rlevel =3D Precedence.get(a,
('right',0))
                                    if (slevel < rlevel) or ((slevel
=3D=3D rlevel) and (rprec =3D=3D 'left')):
                                        # We really need to reduce
here.
                                        action[st,a] =3D -p.number
                                        actionp[st,a] =3D p
                                        if not slevel and not rlevel:
                                            _vfc.write("shift/reduce
conflict in state %d resolved as reduce.\n" % st)
                                            _vf.write("  ! shift/
reduce conflict for %s resolved as reduce.\n" % a)
                                            n_srconflict +=3D 1
                                    elif (slevel =3D=3D rlevel) and (rprec
=3D=3D 'nonassoc'):
                                        action[st,a] =3D None
                                    else:
                                        # Hmmm. Guess we'll keep the
shift
                                        if not slevel and not rlevel:
                                            _vfc.write("shift/reduce
conflict in state %d resolved as shift.\n" % st)
                                            _vf.write("  ! shift/
reduce conflict for %s resolved as shift.\n" % a)
                                            n_srconflict
+=3D1
                                elif r < 0:
                                    # Reduce/reduce conflict.   In
this case, we favor the rule
                                    # that was defined first in the
grammar file
                                    oldp =3D Productions[-r]
                                    pp =3D Productions[p.number]
                                    if oldp.line > pp.line:
                                        action[st,a] =3D -p.number
                                        actionp[st,a] =3D p
                                    # print "#Reduce/reduce conflict
in state %d" % st
                                    n_rrconflict +=3D 1
                                    _vfc.write("reduce/reduce conflict
in state %d resolved using rule %d (%s).\n" % (st,
actionp[st,a].number, actionp[st,a]))
                                    _vf.write("  ! reduce/reduce
conflict for %s resolved using rule %d (%s).\n" %
(a,actionp[st,a].number, actionp[st,a]))
                                else:
                                    print "#Unknown conflict in state
%d" % st
                            else:
                                action[st,a] =3D -p.number
                                actionp[st,a] =3D p
                else:
                    i =3D p.lr_index
                    a =3D p.prod[i+1]       # Get symbol right after the
"."
                    if Terminals.has_key(a):
                        g =3D lr0_goto(I,a)
                        j =3D _lr0_cidhash.get(id(g),-1)
                        if j >=3D 0:
                            # We are in a shift state
                            actlist.append((a,p,"shift and go to state
%d" % j))
                            r =3D action.get((st,a),None)
                            if r is not None:
                                # Whoa have a shift/reduce or shift/
shift conflict
                                if r > 0:
                                    if r !=3D j:
                                        print "#Shift/shift conflict
in state %d" % st
                                elif r < 0:
                                    # Do a precedence check.
                                    #   -  if precedence of reduce
rule is higher, we reduce.
                                    #   -  if precedence of reduce is
same and left assoc, we reduce.
                                    #   -  otherwise we shift
                                    rprec,rlevel =3D
Productions[actionp[st,a].number].prec
                                    sprec,slevel =3D Precedence.get(a,
('right',0))
                                    if (slevel > rlevel) or ((slevel
=3D=3D rlevel) and (rprec !=3D 'left')):
                                        # We decide to shift here...
highest precedence to shift
                                        action[st,a] =3D j
                                        actionp[st,a] =3D p
                                        if not slevel and not rlevel:
                                            n_srconflict +=3D 1
                                            _vfc.write("shift/reduce
conflict in state %d resolved as shift.\n" % st)
                                            _vf.write("  ! shift/
reduce conflict for %s resolved as shift.\n" % a)
                                    elif (slevel =3D=3D rlevel) and (rprec
=3D=3D 'nonassoc'):
                                        action[st,a] =3D None
=20
else:
                                        # Hmmm. Guess we'll keep the
reduce
                                        if not slevel and not rlevel:
                                            n_srconflict +=3D1
                                            _vfc.write("shift/reduce
conflict in state %d resolved as reduce.\n" % st)
                                            _vf.write("  ! shift/
reduce conflict for %s resolved as reduce.\n" % a)

                                else:
                                    print "#Unknown conflict in state
%d" % st
                            else:
                                action[st,a] =3D j
                                actionp[st,a] =3D p

            except StandardError,e:
                raise YaccError, "Hosed in slr_parse_table", e

        # Print the actions associated with each terminal
        if yaccdebug:
          for a,p,m in actlist:
            if action.has_key((st,a)):
                if p is actionp[st,a]:
                    _vf.write("    %-15s %s\n" % (a,m))
          _vf.write("\n")
          for a,p,m in actlist:
            if action.has_key((st,a)):
                if p is not actionp[st,a]:
                    _vf.write("  ! %-15s [ %s ]\n" % (a,m))

        # Construct the goto table for this state
        if yaccdebug:
            _vf.write("\n")
        nkeys =3D { }
        for ii in I:
            for s in ii.usyms:
                if Nonterminals.has_key(s):
                    nkeys[s] =3D None
        for n in nkeys.keys():
            g =3D lr0_goto(I,n)
            j =3D _lr0_cidhash.get(id(g),-1)
            if j >=3D 0:
                goto[st,n] =3D j
                if yaccdebug:
                    _vf.write("    %-15s shift and go to state %d\n" %
(n,j))

        st +=3D 1

    if n_srconflict =3D=3D 1:
        print "#yacc: %d shift/reduce conflict" % n_srconflict
    if n_srconflict > 1:
        print "#yacc: %d shift/reduce conflicts" %
n_srconflict
    if n_rrconflict =3D=3D 1:
        print "#yacc: %d reduce/reduce conflict" % n_rrconflict
    if n_rrconflict > 1:
        print "#yacc: %d reduce/reduce conflicts" % n_rrconflict


#
---------------------------------------------------------------------------=
--
#                       =3D=3D=3D=3D LALR(1) Parsing =3D=3D=3D=3D
# **** UNFINISHED!  6/16/01
#
---------------------------------------------------------------------------=
--


# Compute the lr1_closure of a set I.  I is a list of tuples (p,a)
where
# p is a LR0 item and a is a terminal

_lr1_add_count =3D 0

def lr1_closure(I):
    global _lr1_add_count

    _lr1_add_count +=3D 1

    J =3D I[:]

    # Loop over items (p,a) in I.
    ji =3D 0
    while ji < len(J):
        p,a =3D J[ji]
        #  p =3D [ A -> alpha . B beta]

        #  For each production B -> gamma
        for B in p.lr1_after:
            f =3D tuple(p.lr1_beta + (a,))

            # For each terminal b in first(Beta a)
            for b in first(f):
                # Check if (B -> . gamma, b) is in J
                # Only way this can happen is if the add count
mismatches
                pn =3D B.lr_next
                if pn.lr_added.get(b,0) =3D=3D _lr1_add_count: continue
                pn.lr_added[b] =3D _lr1_add_count
                J.append((pn,b))
        ji +=3D 1

    return J

def lalr_parse_table():

    # Compute some lr1 information about all of the productions
    for p in LRitems:
        try:
            after =3D p.prod[p.lr_index + 1]
            p.lr1_after =3D Prodnames[after]
            p.lr1_beta =3D p.prod[p.lr_index + 2:]
        except LookupError:
            p.lr1_after =3D [ ]
            p.lr1_beta =3D [ ]
        p.lr_added =3D { }

    # Compute the LR(0) items
    C =3D lr0_items()
    CK =3D []
    for I in C:
        CK.append(lr0_kernel(I))

    print CK

#
---------------------------------------------------------------------------=
--
#                          =3D=3D=3D=3D LR Utility functions =3D=3D=3D=3D
#
---------------------------------------------------------------------------=
--

#
---------------------------------------------------------------------------=
--
# _lr_write_tables()
#
# This function writes the LR parsing tables to a file
#
---------------------------------------------------------------------------=
--

def lr_write_tables(modulename=3Dtab_module):
    filename =3D modulename + ".py"
    try:
        f =3D open(filename,"w")

        f.write("""
# %s
# This file is automatically generated. Do not edit.

_lr_method =3D %s

_lr_signature =3D %s
""" % (filename, repr(_lr_method), repr(Signature.digest())))

        # Change smaller to 0 to go back to original tables
        smaller =3D 1

        # Factor out names to try and make smaller
        if smaller:
            items =3D { }

            for k,v in _lr_action.items():
                i =3D items.get(k[1])
                if not i:
                    i =3D ([],[])
                    items[k[1]] =3D i
                i[0].append(k[0])
                i[1].append(v)

            f.write("\n_lr_action_items =3D {")
            for k,v in items.items():
                f.write("%r:([" % k)
                for i in v[0]:
                    f.write("%r," % i)
                f.write("],[")
                for i in v[1]:
                    f.write("%r," % i)

                f.write("]),")
            f.write("}\n")

            f.write("""
_lr_action =3D { }
for _k, _v in _lr_action_items.items():
   for _x,_y in zip(_v[0],_v[1]):
       _lr_action[(_x,_k)] =3D _y
del _lr_action_items
""")

        else:
            f.write("\n_lr_action =3D { ");
            for k,v in _lr_action.items():
                f.write("(%r,%r):%r," % (k[0],k[1],v))
            f.write("}\n");

        if smaller:
            # Factor out names to try and make smaller
            items =3D { }

            for k,v in _lr_goto.items():
                i =3D items.get(k[1])
                if not i:
                    i =3D ([],[])
                    items[k[1]] =3D i
                i[0].append(k[0])
                i[1].append(v)

            f.write("\n_lr_goto_items =3D {")
            for k,v in items.items():
                f.write("%r:([" % k)
                for i in v[0]:
                    f.write("%r," % i)
                f.write("],[")
                for i in v[1]:
                    f.write("%r," % i)

                f.write("]),")
            f.write("}\n")

            f.write("""
_lr_goto =3D { }
for _k, _v in _lr_goto_items.items():
   for _x,_y in zip(_v[0],_v[1]):
       _lr_goto[(_x,_k)] =3D _y
del _lr_goto_items
""")
        else:
            f.write("\n_lr_goto =3D { ");
            for k,v in _lr_goto.items():
                f.write("(%r,%r):%r," %
(k[0],k[1],v))
            f.write("}\n");

        # Write production table
        f.write("_lr_productions =3D [\n")
        for p in Productions:
            if p:
                if (p.func):
                    f.write("  (%r,%d,%r,%r,%d),\n" % (p.name, p.len,
p.func.__name__,p.file,p.line))
                else:
                    f.write("  (%r,%d,None,None,None),\n" % (p.name,
p.len))
            else:
                f.write("  None,\n")
        f.write("]\n")
        f.close()

    except IOError,e:
        print "#Unable to create '%s'" % filename
        print e
        return

def lr_read_tables(module=3Dtab_module,optimize=3D0):
    global _lr_action, _lr_goto, _lr_productions, _lr_method
    try:
        exec "import %s as parsetab" % module

        if (optimize) or (Signature.digest() =3D=3D
parsetab._lr_signature):
            _lr_action =3D parsetab._lr_action
            _lr_goto   =3D parsetab._lr_goto
            _lr_productions =3D parsetab._lr_productions
            _lr_method =3D parsetab._lr_method
            return 1
        else:
            return 0

    except (ImportError,AttributeError):
        return 0

#
---------------------------------------------------------------------------=
--
# yacc(module)
#
# Build the parser module
#
---------------------------------------------------------------------------=
--

def yacc(method=3Ddefault_lr, debug=3Dyaccdebug, module=3DNone,
tabmodule=3Dtab_module, start=3DNone, check_recursion=3D1, optimize=3D0):
    global yaccdebug
    yaccdebug =3D debug

    initialize_vars()
    files =3D { }
    error =3D 0

    # Add starting symbol to signature
    if start:
        Signature.update(start)

    # Try to figure out what module we are working with
    if module:
        # User supplied a module object.
        if not isinstance(module, types.ModuleType):
            raise ValueError,"Expected a module"

        ldict =3D module.__dict__

    else:
        # No module given.  We might be able to get information from
the caller.
        # Throw an exception and unwind the traceback to get the
globals

        try:
            raise RuntimeError
        except RuntimeError:
            e,b,t =3D sys.exc_info()
            f =3D t.tb_frame
            f =3D f.f_back           # Walk out to our calling function
            ldict =3D f.f_globals    # Grab its globals dictionary

    # If running in optimized mode.  We're going to

    if (optimize and lr_read_tables(tabmodule,1)):
        # Read parse table
        del Productions[:]
        for p in _lr_productions:
            if not p:
                Productions.append(None)
            else:
                m =3D MiniProduction()
                m.name =3D p[0]
                m.len  =3D p[1]
                m.file =3D p[3]
                m.line =3D p[4]
                if p[2]:
                    m.func =3D ldict[p[2]]
                Productions.append(m)

    else:
        # Get the tokens map
        tokens =3D ldict.get("tokens",None)

        if not tokens:
            raise YaccError,"module does not define a list 'tokens'"
        if not (isinstance(tokens,types.ListType) or
isinstance(tokens,types.TupleType)):
            raise YaccError,"tokens must be a list or tuple."

        # Check to see if a requires dictionary is defined.
        requires =3D ldict.get("require",None)
        if requires:
            if not (isinstance(requires,types.DictType)):
                raise YaccError,"require must be a dictionary."

            for r,v in requires.items():
                try:
                    if not (isinstance(v,types.ListType)):
                        raise TypeError
                    v1 =3D [x.split(".") for x in v]
                    Requires[r] =3D v1
                except StandardError:
                    print "#Invalid specification for rule '%s' in
require. Expected a list of strings" % r


        # Build the dictionary of terminals.  We a record a 0 in the
        # dictionary to track whether or not a terminal is actually
        # used in the grammar

        if 'error' in tokens:
            print "#yacc: Illegal token 'error'.  Is a reserved word."
            raise YaccError,"Illegal token name"

        for n in tokens:
            if Terminals.has_key(n):
                print "#yacc: Warning. Token '%s' multiply defined." %
n
            Terminals[n] =3D [ ]

        Terminals['error'] =3D [ ]

        # Get the precedence map (if any)
        prec =3D ldict.get("precedence",None)
        if prec:
            if not (isinstance(prec,types.ListType) or
isinstance(prec,types.TupleType)):
                raise YaccError,"precedence must be a list or tuple."
            add_precedence(prec)
            Signature.update(repr(prec))

        for n in tokens:
            if not Precedence.has_key(n):
                Precedence[n] =3D ('right',0)         # Default, right
associative, 0 precedence

        # Look for error handler
        ef =3D ldict.get('p_error',None)
        if ef:
            if not isinstance(ef,types.FunctionType):
                raise YaccError,"'p_error' defined, but is not a
function."
            eline =3D ef.func_code.co_firstlineno
            efile =3D ef.func_code.co_filename
            files[efile] =3D None

            if (ef.func_code.co_argcount !=3D 1):
                raise YaccError,"%s:%d: p_error() requires 1
argument." % (efile,eline)
            global Errorfunc
            Errorfunc =3D ef
        else:
            print "#yacc: Warning. no p_error() function is defined."

        # Get the list of built-in functions with p_ prefix
        symbols =3D [ldict[f] for f in ldict.keys()
               if (isinstance(ldict[f],types.FunctionType) and
ldict[f].__name__[:2] =3D=3D 'p_'
                   and ldict[f].__name__ !=3D 'p_error')]

        # Check for non-empty symbols
        if len(symbols) =3D=3D 0:
            raise YaccError,"no rules of the form p_rulename are
defined."

        # Sort the symbols by line number
        symbols.sort(lambda x,y:
cmp(x.func_code.co_firstlineno,y.func_code.co_firstlineno))

        # Add all of the symbols to the grammar
        for f in symbols:
            if (add_function(f)) < 0:
                error +=3D 1
            else:
                files[f.func_code.co_filename] =3D None

        # Make a signature of the docstrings
        for f in symbols:
            if f.__doc__:
                Signature.update(f.__doc__)

        lr_init_vars()

        if error:
            raise YaccError,"Unable to construct parser."

        if not lr_read_tables(tabmodule):

            # Validate files
            for filename in files.keys():
                if not validate_file(filename):
                    error =3D 1

            # Validate dictionary
            validate_dict(ldict)

            if start and not Prodnames.has_key(start):
                raise YaccError,"Bad starting symbol '%s'" % start

            augment_grammar(start)
            error =3D verify_productions(cycle_check=3Dcheck_recursion)
            otherfunc =3D [ldict[f] for f in ldict.keys()
               if (isinstance(ldict[f],types.FunctionType) and
ldict[f].__name__[:2] !=3D 'p_')]

            if error:
                raise YaccError,"Unable to construct parser."

            build_lritems()
            compute_first1()
            compute_follow(start)

            if method =3D=3D 'SLR':
                slr_parse_table()
            elif method =3D=3D 'LALR1':
                lalr_parse_table()
                return
            else:
                raise YaccError, "Unknown parsing method '%s'" %
method

            lr_write_tables(tabmodule)

            if yaccdebug:
                try:
                    f =3D open(debug_file,"w")
                    f.write(_vfc.getvalue())
                    f.write("\n\n")
                    f.write(_vf.getvalue())
                    f.close()
                except IOError,e:
                    print "#yacc: can't create '%s'" % debug_file,e

    # Made it here.   Create a parser object and set up its internal
state.
    # Set global parse() method to bound method of parser object.

    p =3D Parser("xyzzy")
    p.productions =3D Productions
    p.errorfunc =3D Errorfunc
    p.action =3D _lr_action
    p.goto   =3D _lr_goto
    p.method =3D _lr_method
    p.require =3D Requires

    global parse
    parse =3D p.parse

    # Clean up all of the globals we created
    if (not optimize):
        yacc_cleanup()
    return p

# yacc_cleanup function.  Delete all of the global variables
# used during table construction

def yacc_cleanup():
    global _lr_action, _lr_goto, _lr_method, _lr_goto_cache
    del _lr_action, _lr_goto, _lr_method, _lr_goto_cache

    global Productions, Prodnames, Prodmap, Terminals
    global Nonterminals, First, Follow, Precedence, LRitems
    global Errorfunc, Signature, Requires

    del Productions, Prodnames, Prodmap, Terminals
    del Nonterminals, First, Follow, Precedence, LRitems
    del Errorfunc, Signature, Requires

    global _vf, _vfc
    del _vf, _vfc


# Stub that raises an error if parsing is attempted without first
calling yacc()
def parse(*args,**kwargs):
    raise YaccError, "yacc: No parser built with yacc()"



0
1/11/2012 1:54:29 PM
On Wed, 11 Jan 2012 12:28:52 +0100, Laurent Claessens
<moky.math@gmail.com> wrote:

>
>Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
>[GCC 4.4.5] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
>>>> import hashlib
>>>> h=hashlib.new("md5")
>>>> h.update("Hello")
>>>> h.hexdigest()
>'d992641f1b2b9c08b569c0a17c4e7cb8'
>
	Interesting... I get a different result here...

PythonWin 2.7.1 (r271:86832, Feb  7 2011, 11:33:02) [MSC v.1500 64 bit
(AMD64)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin'
for further copyright information.
>>> import hashlib
>>> h = hashlib.new("md5")
>>> h.update("Hello")
>>> h.hexdigest()
'8b1a9953c4611296a827abf8c47804d7'
>>> 

PythonWin 2.7.1 (r271:86832, Feb  7 2011, 11:30:38) [MSC v.1500 32 bit
(Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin'
for further copyright information.
>>> import hashlib
>>> h = hashlib.new("md5")
>>> h.update("Hello")
>>> h.hexdigest()
'8b1a9953c4611296a827abf8c47804d7'
>>> 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

0
wlfraed (4596)
1/11/2012 5:12:45 PM
On 1/11/2012 6:19 AM, mike wrote:
> Hi,
>
> We are running are running Python program on Redhat 5.5.
>
> When executing our program we get the following error ( see below).
>
> Any ideas what this is due to?
>
> br,
>
> //mike
>
> /pysibelius/lib/common/

> DataTypes.py
> Overwriten ...
> ERROR:root:code for hash md5 was not found.

These 3 lines do not come from the interpreter.
It might come from the hashlib module.

> Traceback (most recent call last):
>    File "/python/lib/python2.7/hashlib.py", line 139, in<module>
>      globals()[__func_name] = __get_hash(__func_name)
>    File "/python/lib/python2.7/hashlib.py", line 91, in
> __get_builtin_constructor
>      raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type md5

This is a standard traceback from the interpreter.
The manual says that md5 should always be available.
On the other hand, hashlib depends on the OpenSSL library on your 
system. Perhaps RedHat removed md5 because it has been broken.
I suggest you ask them or check your OpenSSL doc. The Python manual may 
need to be changed.

> ERROR:root:code for hash sha1 was not found

-- 
Terry Jan Reedy

0
tjreedy (5460)
1/11/2012 6:25:16 PM
On Wed, 11 Jan 2012 05:54:29 -0800, mike wrote:

> I did some more digging and found that our class imports a "yacc.py"
> that uses
> 
> import re, types, sys, cStringIO, hashlib, os.path
> 
> so it has hashlib.
> 
> yacc.py seems to be an old version 1.3 ( I found 2.3 -->).
> 
> Reading about hashlib it seems to be dependent on os installation of
> OpenSSL but I cannot find out how.

It shouldn't be. It will use OpenSSL if available, otherwise it will fall 
back on its own code.


> br,
> 
> //mike
> 
> yacc.py
> ===============
> 
#-----------------------------------------------------------------------------
> # ply: yacc.py
[snip over TWO THOUSAND lines of code]


Mike, what lead you to believe that an error in hashlib could be solved 
by posting the ENTIRE two thousand lines of yacc.py? Please do not post 
such huge chunks of code unless asked. It is unnecessary and annoying.

Try this. Open a terminal window and enter "python" at the prompt to 
start a clean interactive session. Then enter the following commands:

import sys
print(sys.version)
import hashlib
print(hashlib.__file__)
print(hashlib.md5)
import _md5
print(_md5.__file__)

and copy and paste (do not retype) the full output of these commands.




Thank you.




-- 
Steven
0
1/11/2012 11:28:10 PM
On Wed, 11 Jan 2012 13:25:16 -0500, Terry Reedy <tjreedy@udel.edu>
wrote:

	Given

>> /pysibelius/lib/common/
>

I suspect some library for accessing Sibelius music notation files...

>> DataTypes.py
>> Overwriten ...
>> ERROR:root:code for hash md5 was not found.
>
>These 3 lines do not come from the interpreter.
>It might come from the hashlib module.
>
.... might be responsible for those lines.

>
>> ERROR:root:code for hash sha1 was not found

	Note that whatever reported the MD5 failure appears to have tried a
follow-over to SHA1 and isn't finding that either.

	Makes me suspect the entire hashlib library may be, uhm, corrupted?
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

0
wlfraed (4596)
1/12/2012 2:23:23 AM
On Jan 12, 12:28=A0am, Steven D'Aprano <steve
+comp.lang.pyt...@pearwood.info> wrote:
> On Wed, 11 Jan 2012 05:54:29 -0800, mike wrote:
> > I did some more digging and found that our class imports a "yacc.py"
> > that uses
>
> > import re, types, sys, cStringIO, hashlib, os.path
>
> > so it has hashlib.
>
> > yacc.py seems to be an old version 1.3 ( I found 2.3 -->).
>
> > Reading about hashlib it seems to be dependent on os installation of
> > OpenSSL but I cannot find out how.
>
> It shouldn't be. It will use OpenSSL if available, otherwise it will fall
> back on its own code.
>
> > br,
>
> > //mike
>
> > yacc.py
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> #------------------------------------------------------------------------=
-----> # ply: yacc.py
>
> [snip over TWO THOUSAND lines of code]
>
> Mike, what lead you to believe that an error in hashlib could be solved
> by posting the ENTIRE two thousand lines of yacc.py? Please do not post
> such huge chunks of code unless asked. It is unnecessary and annoying.
>
> Try this. Open a terminal window and enter "python" at the prompt to
> start a clean interactive session. Then enter the following commands:
>
> import sys
> print(sys.version)
> import hashlib
> print(hashlib.__file__)
> print(hashlib.md5)
> import _md5
> print(_md5.__file__)
>
> and copy and paste (do not retype) the full output of these commands.
>
> Thank you.
>
> --
> Steven

Hi,

Sorry for posting huge file. I added your copy-paste snippet.

esekilx5030 [7:09am] [roamFroBl/pysibelius/bin] -> python
Python 2.7.2 (default, Jun 16 2011, 15:05:49)
[GCC 4.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
print(sys.version)
import hashlib
print(hashlib.__file__)
print(hashlib.md5)
import _md5
print(_md5.__file__) >>> 2.7.2 (default, Jun 16 2011, 15:05:49)
[GCC 4.5.0]
>>> ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha512
>>> /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/hashlib.pyc
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'md5'
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named _md5

Thanks for support!

//mike
0
1/12/2012 6:13:16 AM
On Jan 12, 7:13=A0am, mike <mikaelpetters...@gmail.com> wrote:
> On Jan 12, 12:28=A0am, Steven D'Aprano <steve
>
>
>
>
>
>
>
>
>
> +comp.lang.pyt...@pearwood.info> wrote:
> > On Wed, 11 Jan 2012 05:54:29 -0800, mike wrote:
> > > I did some more digging and found that our class imports a "yacc.py"
> > > that uses
>
> > > import re, types, sys, cStringIO, hashlib, os.path
>
> > > so it has hashlib.
>
> > > yacc.py seems to be an old version 1.3 ( I found 2.3 -->).
>
> > > Reading about hashlib it seems to be dependent on os installation of
> > > OpenSSL but I cannot find out how.
>
> > It shouldn't be. It will use OpenSSL if available, otherwise it will fa=
ll
> > back on its own code.
>
> > > br,
>
> > > //mike
>
> > > yacc.py
> > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > #----------------------------------------------------------------------=
-------> # ply: yacc.py
>
> > [snip over TWO THOUSAND lines of code]
>
> > Mike, what lead you to believe that an error in hashlib could be solved
> > by posting the ENTIRE two thousand lines of yacc.py? Please do not post
> > such huge chunks of code unless asked. It is unnecessary and annoying.
>
> > Try this. Open a terminal window and enter "python" at the prompt to
> > start a clean interactive session. Then enter the following commands:
>
> > import sys
> > print(sys.version)
> > import hashlib
> > print(hashlib.__file__)
> > print(hashlib.md5)
> > import _md5
> > print(_md5.__file__)
>
> > and copy and paste (do not retype) the full output of these commands.
>
> > Thank you.
>
> > --
> > Steven
>
> Hi,
>
> Sorry for posting huge file. I added your copy-paste snippet.
>
> esekilx5030 [7:09am] [roamFroBl/pysibelius/bin] -> python
> Python 2.7.2 (default, Jun 16 2011, 15:05:49)
> [GCC 4.5.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>>=
 import sys
>
> print(sys.version)
> import hashlib
> print(hashlib.__file__)
> print(hashlib.md5)
> import _md5
> print(_md5.__file__) >>> 2.7.2 (default, Jun 16 2011, 15:05:49)
> [GCC 4.5.0]>>> ERROR:root:code for hash md5 was not found.
>
> Traceback (most recent call last):
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
> =A0 =A0 globals()[__func_name] =3D __get_hash(__func_name)
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> =A0 =A0 raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type md5
> ERROR:root:code for hash sha1 was not found.
> Traceback (most recent call last):
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
> =A0 =A0 globals()[__func_name] =3D __get_hash(__func_name)
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> =A0 =A0 raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type sha1
> ERROR:root:code for hash sha224 was not found.
> Traceback (most recent call last):
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
> =A0 =A0 globals()[__func_name] =3D __get_hash(__func_name)
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> =A0 =A0 raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type sha224
> ERROR:root:code for hash sha256 was not found.
> Traceback (most recent call last):
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
> =A0 =A0 globals()[__func_name] =3D __get_hash(__func_name)
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> =A0 =A0 raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type sha256
> ERROR:root:code for hash sha384 was not found.
> Traceback (most recent call last):
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
> =A0 =A0 globals()[__func_name] =3D __get_hash(__func_name)
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> =A0 =A0 raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type sha384
> ERROR:root:code for hash sha512 was not found.
> Traceback (most recent call last):
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
> =A0 =A0 globals()[__func_name] =3D __get_hash(__func_name)
> =A0 File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> =A0 =A0 raise ValueError('unsupported hash type %s' % name)
> ValueError: unsupported hash type sha512>>> /vobs/rnc/rrt/roam1/roamSs/ro=
amFroBl/python/lib/python2.7/hashlib.pyc
> >>> Traceback (most recent call last):
>
> =A0 File "<stdin>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'md5'>>> Traceback (most=
 recent call last):
>
> =A0 File "<stdin>", line 1, in <module>
> ImportError: No module named _md5
>
> Thanks for support!
>
> //mike

Hi,

I did some more testing.

The python 2.7.2 lib is stored in a clearcase vob. When I set the env.
and run suggested lines ( with slight modification), on Redhat 5.5,
( by Steven) I get the following:

-> python
Python 2.7.2 (default, Jun 16 2011, 15:05:49)
[GCC 4.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
print(sys.version)
import hashlib
print(hashlib.__file__)
print(hashlib.md5)
import md5
print(md5.__file__)>>> 2.7.2 (default, Jun 16 2011, 15:05:49)
[GCC 4.5.0]
>>> ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 139, in <module>
    globals()[__func_name] =3D __get_hash(__func_name)
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha512
>>> /vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/hashlib.pyc
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'md5'
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
md5.py", line 10, in <module>
    from hashlib import md5
ImportError: cannot import name md5

But when I execute the same lines on a Suse 10.4 I get the following
output:

python
Python 2.7.2 (default, Jun 16 2011, 15:05:49)
[GCC 4.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.version)
2.7.2 (default, Jun 16 2011, 15:05:49)
[GCC 4.5.0]
>>> import hashlib
>>> print(hashlib.__file__)
/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/hashlib.pyc
>>> print(hashlib.md5)
<built-in function openssl_md5>
>>> import md5
>>> print(md5.__file__)
/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/md5.pyc

That looks correct to me.

It really confuses me!?

br,

//mike

Ps. Thanks for all the replies.



0
1/12/2012 7:25:09 AM
On Wed, 11 Jan 2012 22:13:16 -0800, mike wrote:
[...]
> esekilx5030 [7:09am] [roamFroBl/pysibelius/bin] -> python Python 2.7.2
> (default, Jun 16 2011, 15:05:49) [GCC 4.5.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
> print(sys.version)
> import hashlib
> print(hashlib.__file__)
> print(hashlib.md5)
> import _md5
> print(_md5.__file__) >>> 2.7.2 (default, Jun 16 2011, 15:05:49) [GCC
> 4.5.0]
>>>> ERROR:root:code for hash md5 was not found.
> Traceback (most recent call last):
>   File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in <module>
>     globals()[__func_name] = __get_hash(__func_name)
>   File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
>     raise ValueError('unsupported hash type %s' % name)


It looks like pysibelius comes with its own Python installation, which is 
*seriously* broken.

What is pysibelius? I can't find it on the web. Does it have anything to 
do with Sibelius the music composition software?

It looks like the installation you are trying to use is missing modules. 
You might need to consult the pysibelius forums or mailing lists, if they 
have any, or the author, or possibly re-install it and see if the problem 
goes away.



-- 
Steven
0
1/13/2012 3:34:41 AM
On Jan 13, 1:34=A0pm, Steven D'Aprano <steve
+comp.lang.pyt...@pearwood.info> wrote:
> What is pysibelius? I can't find it on the web. Does it have anything to
> do with Sibelius the music composition software?

Yes, please provide more information about the pysibelius package,
especially if this is the case.

The few tenuous Python/Sibelius links I found didn't have anything on
pysibelius, unfortunately.

0
wuwei23 (1194)
1/13/2012 4:41:13 AM
On Jan 13, 5:41=A0am, alex23 <wuwe...@gmail.com> wrote:
> On Jan 13, 1:34=A0pm, Steven D'Aprano <steve
>
> +comp.lang.pyt...@pearwood.info> wrote:
> > What is pysibelius? I can't find it on the web. Does it have anything t=
o
> > do with Sibelius the music composition software?
>
> Yes, please provide more information about the pysibelius package,
> especially if this is the case.
>
> The few tenuous Python/Sibelius links I found didn't have anything on
> pysibelius, unfortunately.

Hi,

pysibelius is a lib that we use.

I am not sure that is the problem since the python program works on
SuSE but not on RH server. And AFAIK
the only difference ( well that I can see) is the OpenSSL version.

According to code it uses openssl:

<built-in function openssl_md5>

So I need to find a way to convince the linux sys admin to install
same version of openssl on both servers.

Thanks a lot for your valuable time.

//mike
0
1/13/2012 2:14:50 PM
On 01/13/2012 07:14 AM, mike wrote:
> pysibelius is a lib that we use.
> 
> I am not sure that is the problem since the python program works on
> SuSE but not on RH server. And AFAIK
> the only difference ( well that I can see) is the OpenSSL version.
> 
> According to code it uses openssl:
> 
> <built-in function openssl_md5>
> 
> So I need to find a way to convince the linux sys admin to install
> same version of openssl on both servers.

Unfortunately that's going to be fairly difficult, as they would have to
install a new version of openssl alongside the existing system version,
which you can't just replace.  Or it might be possible to copy the
openssl libraries from SuSE over.  Either way you will have to use the
LD_LIBRARY_PATH or the LD_LIBRARY_PRELOAD environment variables to get
PySibelius to load that version instead of the system one.
0
torriem1 (469)
1/13/2012 4:49:35 PM
On Fri, 13 Jan 2012 06:14:50 -0800, mike wrote:

> On Jan 13, 5:41 am, alex23 <wuwe...@gmail.com> wrote:
>> On Jan 13, 1:34 pm, Steven D'Aprano <steve
>>
>> +comp.lang.pyt...@pearwood.info> wrote:
>> > What is pysibelius? I can't find it on the web. Does it have anything
>> > to do with Sibelius the music composition software?
>>
>> Yes, please provide more information about the pysibelius package,
>> especially if this is the case.
>>
>> The few tenuous Python/Sibelius links I found didn't have anything on
>> pysibelius, unfortunately.
> 
> Hi,
> 
> pysibelius is a lib that we use.
> 
> I am not sure that is the problem since the python program works on SuSE
> but not on RH server. And AFAIK
> the only difference ( well that I can see) is the OpenSSL version.

OpenSSL is irrelevant. If it isn't available, or doesn't provide md5, 
then the hashlib library will use its own implementation. But the _md5 
module is missing in the pysibelius Python on your RedHat system.

As I said, your Python installation is seriously broken. Required modules 
are just *gone*.

pysibelius appears to have patched Python in some way, because strange 
unexpected error messages are being printed that do not happen on a 
normal unpatched Python, e.g.:

ERROR:root:code for hash sha224 was not found.

That is not a normal Python error message. That looks like something 
added by pysibelius.



-- 
Steven
0
1/14/2012 4:30:24 AM
Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote:
> On Fri, 13 Jan 2012 06:14:50 -0800, mike wrote:
>> pysibelius is a lib that we use.
>> 
>> I am not sure that is the problem since the python program works on SuSE
>> but not on RH server. And AFAIK
>> the only difference ( well that I can see) is the OpenSSL version.
> 
> OpenSSL is irrelevant. If it isn't available, or doesn't provide md5, 
> then the hashlib library will use its own implementation. But the _md5 
> module is missing in the pysibelius Python on your RedHat system.
> 
> As I said, your Python installation is seriously broken. Required modules 
> are just *gone*.
> 
> pysibelius appears to have patched Python in some way, because strange 
> unexpected error messages are being printed that do not happen on a 
> normal unpatched Python, e.g.:
> 
> ERROR:root:code for hash sha224 was not found.
> 
> That is not a normal Python error message. That looks like something 
> added by pysibelius.

Steven, I think you're wrong with regard to the error message. 
Straight from the tarball, Python-2.7.2/Lib/hashlib.py line 135ff:

for __func_name in __always_supported:
    # try them all, some may not work due to the OpenSSL
    # version not supporting that algorithm.
    try:
        globals()[__func_name] = __get_hash(__func_name)
    except ValueError:
        import logging
        logging.exception('code for hash %s was not found.', __func_name)

Of course this does not invalidate the fact (is that even possible?) of
the brokenness of the installation.

Ciao
  Marc
0
usenet8095 (43)
1/14/2012 12:33:12 PM
I had that problem after moving my Python installation into another directory. Reinstalling Python helped.
0
klausem (1)
9/27/2012 2:44:56 PM
On Wednesday, January 11, 2012 12:28:52 PM UTC+1, Laurent Claessens wrote:
> Le 11/01/2012 12:19, mike a =EF=BF=BDcrit :
>=20
> > Hi,
>=20
> >
>=20
> > We are running are running Python program on Redhat 5.5.
>=20
> >
>=20
> > When executing our program we get the following error ( see below).
>=20
> >
>=20
> > Any ideas what this is due to?
>=20
>=20
>=20
> On my computer hashlib has "md5" :
>=20
>=20
>=20
>=20
>=20
>=20
>=20
> Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
>=20
> [GCC 4.4.5] on linux2
>=20
> Type "help", "copyright", "credits" or "license" for more information.
>=20
> >>> import hashlib
>=20
> >>> h=3Dhashlib.new("md5")
>=20
> >>> h.update("Hello")
>=20
> >>> h.hexdigest()
>=20
> 'd992641f1b2b9c08b569c0a17c4e7cb8'
>=20
>=20
>=20
> While if I ask for a hash method that hashlib does not know, I get the=20
>=20
> same error as you :
>=20
>=20
>=20
>  >>> g=3Dhashlib.new("bla")
>=20
> Traceback (most recent call last):
>=20
>    File "<stdin>", line 1, in <module>
>=20
>    File "/usr/lib/python2.6/hashlib.py", line 101, in __hash_new
>=20
>      return __get_builtin_constructor(name)(string)
>=20
>    File "/usr/lib/python2.6/hashlib.py", line 80, in=20
>=20
> __get_builtin_constructor
>=20
>      raise ValueError, "unsupported hash type"
>=20
> ValueError: unsupported hash type
>=20
>=20
>=20
>=20
>=20
> You should give us a more comprehensive example of your problem.
>=20
>=20
>=20
> Laurent

Dear Laurent,

I have encountered similar problem and your suggestion was helpful. Thanks =
a lot!

Sincerely,

Bidzina Kapanadze,
Abastumani Astrophysical Observatory,
Ilia State University, Tbilisi, Georgia
0
2/5/2013 3:10:04 PM
Reply:

Similar Artilces:

Re: ERROR:root:code for hash md5 was not found
Hello, I am bit new to python and am struggling to install NumPy and SciPy on to P= ython 2.7. Based on my understanding I believe that the problem is with my = Python install rather than the way I am installing NumPy. I have seen only = two other threads that deal with this issue but both threads just end with = no solutions. I am on a CENTOS 5.8 system. With python 2.7 installed from source in a sel= f contained folder. I am using environment modules to manage the different = versions of python. When I invoke the NumPy installer I get the following: python setup.py build ...

Error code when there is no error??
In my source I have: wndclass.hIcon = LoadIcon (hInstance, "test") ; test.ico is a valid icon. file. Everythig works ok. But when I test for an error like this: ShowLastError(); // no problems here wndclass.hIcon = LoadIcon (hInstance, "test") ; ShowLastError(); // I get "The system cannot find the file specidied" wndclass.hIcon get a valid handle. Here is my ShowLastError program: VOID ShowLastError(void) { LPVOID lpMsgBuf; DWORD error_code; int status; char sa1[1024]; error_code = Get...

how to run part of my python code as root
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey, is there possibility how to run part of my code (function for example) as superuser. Or only way how to do this is create a wrapper and run is with Popen through sudo (but I have to configure sudo to run "whole" python as root). Thanks for advice. - -- Tom Key fingerprint = 06C0 23C6 9EB7 0761 9807 65F4 7F6F 7EAB 496B 28AA -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAktrGoYACgkQf29+q0lrKKqaNACdEvfg+g0n3DzFr/7R3...

Python error codes and messages location
Where can I find all error codes and messages that Python throws (actual co= des and messages from exceptions raised by stdlib)?=0A= =0A= I've already found the module 'errno' and got a dictionary (errno.errorcode= ) and some system error messages (os.strerror(errno.ENAMETOOLONG)) but ther= e's more I couldn't find. = On Mon, 27 May 2013 02:13:54 +0300, Carlos Nepomuceno wrote: > Where can I find all error codes and messages that Python throws (actual > codes and messages from exceptions raised by stdlib)? There is no list. It is subject to ch...

I could use some help making this Python code run faster using only Python code.
I am new to Python however I would like some feedback from those who know more about Python than I do at this time. def scrambleLine(line): s = '' for c in line: s += chr(ord(c) | 0x80) return s def descrambleLine(line): s = '' for c in line: s += chr(ord(c) & 0x7f) return s def scrambleFile(fname,action=1): if (path.exists(fname)): try: f = open(fname, "r") toks = fname.split('.') while (len(toks) > 2): toks.pop() fname = '.'.j...

Error: An error occurred while shelling out to mbuild (error code = 1).
Hi! I'm trying to create an exe file from my GUI, so that the GUI can be run on computers not having MATLAB. I'm using MATLAB 7.9.0(R2009b) and the Compiler version is 4.11(R2009b). I receive the following error message when using deploytool: mkdir 'C:\Documents and Settings\Paulo\Meus documentos\MATLAB\test_deploy\distrib' Warning: Directory already exists. mkdir 'C:\Documents and Settings\Paulo\Meus documentos\MATLAB\test_deploy\src' Warning: Directory already exists. mcc -F C:\Documents and Settings\Paulo\Meus documentos\MATLAB\test_deploy.prj mcc -o &#...

Error: An error occurred while shelling out to mbuild (error code = 255).
Hello, I am trying to compile a m-file using Visual C++ l2010 library (as setup by "mbuild -setup)" to create COM DLL. But the compiler gives me Error: Using options file: C:\Users\User\AppData\Roaming\MathWorks\MATLAB\R2011b\compopts.bat You cannot use this file with the UNKNOWN architecture because it enables a compiler for a different architecture. Running mbuild -setup may resolve this problem. Error: An error occurred while shelling out to mbuild (error code = 255). Unable to build executable. (see full build log below). The ...

error in error code database
Hi, &nbsp; I have this error (screenshot provided), which problem is its asking for a password. I think this vi is ni developed. So,&nbsp;I have tried to reinstall labview but still this cannot work. Thanks, for any help. &nbsp; Best regards, Edwin &nbsp; error_code_database_password.zip: http://forums.ni.com/attachments/ni/170/130546/1/error_code_database_password.zip Hi Edwin, The error is most likely caused by opening an LLB in a newer version of LabVIEW than the version it was developed on. It is commonly seen with the "Error Code Database.vi" when upgrading f...

Error codes to go with errors?
Hi all, I've been hunting around the techdocs site looking for a comprehensive list= of error codes for certain errors. The only thing I can find is a list of= a few (textual) errors - nothing that includes codes/numbers, and nothing = comprehensive. This is making it hard to catch specific errors ... can any= one point me to a list somewhere (or tell me the bad news that PostgreSQL l= acks error codes). Ciao Fuzzy :-) ---------------------------------- "Everything you think, do, and say was in the pill you took today." -- Zager and Evans -------------...

Code coverage to Python code
Hey, What is the best code coverage tool available for Python? Thanks. Hussein> What is the best code coverage tool available for Python? Probably Ned Batchelders coverage.py. There is a trace.py module which comes with Python as well. -- Skip Montanaro - skip@pobox.com - http://smontanaro.dyndns.org/ Hussein B wrote: > Hey, > What is the best code coverage tool available for Python? I like Titus Brown's figleaf. http://darcs.idyll.org/~t/projects/figleaf/doc/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is...

wince time.cpp code error found
Upon compiling wx 2.6.3 for wince, the compiler found a number of areas in the code that were unreachable. time.cpp:454 time.cpp:455 time.cpp:457 time.cpp:458 The culprit is the following code segment: === code segment start === if (t->tm_isdst < 0) continue; continue; === code segment end === The culprit is the second continue statement after the if() statement, which will skip the remaining code below. This second continue statement should be removed. I would be happy to submit a patch if you would like. Let me know. Regards, Nicholas Also, ...

"Pseudo-hashes are deprecated" error and accessing a hash of hashes
OK, so I see that this is a Perl 5.8 change. I am getting this "Pseudo-hashes are deprecated" error while following the Camel Book v3 and trying to generate a count of items in a hash of hashes thus: scalar(keys %{ $logips{$key} } ) Basically I'm parsing a Web log file and am trying to keep a list of unique IPs that visited each page (modifying Perl Cookbook recipe 4.6) thus: my %logips=(); my %logipseen=(); foreach $snifferlog (@ARGV) { blah blah blah; push (@{ $logips{$logfile} }, $logip) unless ( $logipseen{ $logfile }{ $logip } )++; } foreach $key (@logfil...

Error: An error occurred while shelling out to mbuild (error code = 1). #2
uilding COM object... mcc -M -silentsetup -d 'D:/matlab2006/work/testww//src' -B 'ccom:testww,testwwclass,1.0' -g -S 'D:/matlab2006/work/testww.m' mwcomtypes.idl oaidl.idl objidl.idl unknwn.idl wtypes.idl ocidl.idl oleidl.idl servprov.idl urlmon.idl msxml.idl testww_idl.idl oaidl.idl objidl.idl unknwn.idl wtypes.idl ocidl.idl oleidl.idl servprov.idl urlmon.idl msxml.idl mwcomtypes.idl 'rc' &#19981;&#26159;&#20869;&#37096;&#25110;&#22806;&#37096;&#21629;&#2019 6;&#65292;&#20063;&#19981;&#26159;&#21487;&#...

Error: Windows SDK function returned an error. (Error code -12)
I receive this error when attempting to build an installer for my Labview application. &nbsp; &nbsp; CDK_Item_OnDoProperties.vi.ProxyCaller &gt;&gt; CDK_Item_OnDoProperties.vi &gt;&gt; CDK_InstallerConfiguration_Editor.vi &gt;&gt; CDK_Build_Invoke.vi &gt;&gt; CDK_Engine_Main.vi &gt;&gt; CDK_Engine_Build.vi &gt;&gt; NI_MDF.lvlib:MDFDistCopyList_CopyItem.vi Loading product deployment informationLoading product deployment informationAdding files to installerDone adding filesPreparing to build deploymentCopying products from distributionsCopy...

Web resources about - ERROR:root:code for hash md5 was not found - comp.lang.python

Resources last updated: 2/9/2016 3:42:29 PM