Skip to content

Syntax error in Python 3.12 #173

@mkhludnev

Description

@mkhludnev

Describe the bug
In one cloud function environment this dependency installed like source (I don't know whether it's ok). But when python 3.12 attempts to interpret the source it fails with a syntax error. Qwen suggests that it's a version incompatibility.

File or Malware sample to reproduce the bug
Please attach the file(s) that can be used to reproduce the bug.
If this is malware, store it in a password protected zip archive, or provide a link where it can be downloaded (e.g. Hybrid Analysis, preferably not VirusTotal which requires paid access). If not possible, please provide a hash.

How To Reproduce the bug
Steps to reproduce the behavior, including the full command line or the options you used.

Expected behavior
A clear and concise description of what you expected to happen.

Console output / Screenshots

Successfully built olefile langdetect
Installing collected packages: ..., olefile, .., unstructured
Successfully installed .. olefile-0.40 ..

===> will start 'python3.12 compileall' in /function/code
*** Error compiling '/function/code/olefile/olefile2.py'...
  File "/function/code/olefile/olefile2.py", line 277
    MAXREGSECT = 0xFFFFFFFAL; # maximum SECT
                          ^
SyntaxError: invalid hexadecimal literal

Version information:

  • OS: Linux
  • Python version: 3.12
  • olefile version: 0.40, 0.47

Qwen considerations

The error you're encountering is due to an invalid hexadecimal literal in Python 3.12:
python

1
MAXREGSECT = 0xFFFFFFFAL; # maximum SECT

In Python versions before 3.12, a trailing L (or l) was sometimes used to denote a long integer (from Python 2). However, in Python 3, all integers are of arbitrary precision, and the L suffix is no longer valid syntax—especially in Python 3.12, where this now raises a SyntaxError.
`✅ Fix:

Remove the trailing L from the hexadecimal literal:

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions