Skip to content

Conversation

@tahatehran
Copy link
Contributor

No description provided.

Saraye Tell and others added 17 commits January 31, 2026 00:20
# Conflicts:
#	iran_encoding/__init__.py
- Ported legacy C logic to pure Python for zero-dependency reliability.
- Implemented requested language detection and number handling rules.
- Improved C extension and wrapper for performance optimization.
- Professionalized documentation in English and Persian.
- Updated and expanded test suite (all 37 tests passing).
- Prepared for PyPI distribution as v1.1.0.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Deleted redundant and failing `.github/workflows/python-package-conda.yml`.
- Updated `.github/workflows/ci.yml` and `qodana-ci.yml` to run on all branches for better validation.
- Updated `MANIFEST.in` to include C and H source files for proper source distribution.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
…0-10619367560126165419

Professional overhaul of Iran System encoding library
- Fixed `qodana.yml` by merging duplicate `properties` keys.
- Fixed `tests/test_suite.py` to correctly add the tests directory to `sys.path`, resolving `ModuleNotFoundError` during test collection in CI.
- Verified fix by running `pytest` locally.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
…0-10619367560126165419

fix: resolve CI failures in qodana and test suite
- Updated author metadata and support email in `setup.py`.
- Overhauled README and Wiki documentation in both English and Persian.
- Refactored Qodana configuration to `.qodana/qodana.yml`.
- Cleaned up redundant files (`requirements.txt`, `test_encoding.py`).
- Optimized CI workflows for the new project structure.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Removed `.idea/` directory.
- Refined `.gitignore` to include more specific exclusions for C compiled artifacts, IDE settings, and Qodana caches.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `qodana-ci.yml` to use `--yaml-name` instead of `-c` and upgraded action version to `v2024.3`.
- Ensured all documentation and metadata are finalized.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Fixed `qodana.yml` by quoting boolean values in `properties` to satisfy the `map[string]string` constraint.
- Refined `exclude` section to use a standard format.
- Updated `qodana-ci.yml` to symlink the config to the root for better compatibility with the Qodana action.
- Verified all tests pass.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `publish-to-pypi.yml` to trigger automatically on push to `main`.
- Added twine check step for package distribution validation.
- Upgraded checkout and setup-python actions to latest versions.
- Finalized professional configuration for release.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Refactored `qodana.yaml` to use the correct `linter` key and hidden directory.
- Updated `qodana-ci.yml` to point to the new configuration location.
- Verified all tests pass.
- Cleaned up .idea and refined .gitignore.
- Finalized professional documentation and wiki.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `qodana.yaml` to use the correct `linter` key and Community image.
- Quoted boolean values in `properties` to satisfy the map[string]string constraint.
- Updated `qodana-ci.yml` to copy the configuration file to the root during analysis, ensuring the scan finds it.
- Verified project integrity with all 76 tests passing.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Removed redundant `bootstrap` command from `qodana.yaml`.
- Set linter to `jetbrains/qodana-python-community:latest` for compatibility with the free version.
- Simplified configuration properties.
- Verified all tests pass.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Removed `tests/corpus.json` as requested.
- Verified that the visual encoding logic (parentheses and alphanumeric sequences) correctly matches legacy expectations.
- Confirmed all 76 tests pass.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `encode` to produce visual RTL byte sequences as requested (e.g., "سلام" results in `f4 91 f3 a8`).
- Updated `decode` to correctly handle visual RTL sequences and return logical Unicode.
- Improved `ReverseAlphaNumeric` to accurately handle bi-directional chunks (English, numbers, symbols).
- Ensured parity between Python and C implementations.
- Updated all tests to reflect the visual ordering requirement.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @tahatehran, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request represents a significant architectural overhaul and professionalization of the iran-encoding library. It transitions from relying on external dependencies for text shaping and bidirectional handling to a self-contained, high-performance core. By directly porting the original C logic into both a pure Python implementation and an optional C extension, the library achieves greater stability, speed, and control over character encoding. The update also introduces sophisticated locale-aware processing, comprehensive testing, and user-friendly documentation, making it a robust solution for Iran System character encoding.

Highlights

  • Core Logic Refactoring: The library's core encoding and decoding logic has been completely rewritten, removing external dependencies like arabic_reshaper and python-bidi. It now features a pure Python implementation directly ported from the original C code.
  • C Extension for Performance: An optional C extension has been integrated to provide maximum performance for encoding and decoding operations. A new build_c_extension.py script automates the compilation process across different platforms.
  • Intelligent Locale Detection and Number Handling: The library now includes intelligent locale detection, automatically identifying Persian ('fa') or English ('en') contexts. This enables smart number handling, converting numbers to Iran System format in Persian text and normalizing Persian digits to ASCII in English text.
  • Comprehensive Documentation and Testing: Extensive new documentation has been added in both English and Farsi, covering usage guides, technical details, and troubleshooting. The test suite has been significantly expanded and improved for thorough coverage and reliability.
  • Project Modernization: The .gitignore and setup.py files have been modernized, cleaning up ignore patterns and updating project metadata, dependencies, and classifiers for better maintainability and distribution.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (5)
    • .github/workflows/ci.yml
    • .github/workflows/publish-to-pypi.yml
    • .github/workflows/python-package-conda.yml
    • .github/workflows/python-publish.yml
    • .github/workflows/qodana-ci.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a massive and impressive refactoring that significantly improves the library. The removal of external dependencies, introduction of a pure Python core ported from C, addition of an optional C extension, and the vastly improved API, tests, and documentation are all excellent changes. However, I've identified a critical security vulnerability and a high-severity data loss bug in the C implementation that must be addressed. I've also noted a minor issue with an orphaned CLI argument and an opportunity to strengthen one of the new test cases.

I am having trouble creating individual review comments. Click here to see my feedback.

iran_encoding/iran_system.c (299-308)

critical

There is a critical buffer overflow vulnerability here. The finalReverse buffer has a fixed size of 2048 bytes, but the loop iterates len times without checking if len is greater than or equal to 2048. This can lead to a crash or arbitrary code execution if a long string is passed. To fix this, you should use dynamic memory allocation (malloc/free) or pass the buffer and its size as parameters to ensure memory safety.

iran_encoding/iran_system.c (161-164)

high

These fixed-size buffers of 2048 bytes introduce a risk of data loss. The check on line 164 (if (len >= 2048) len = 2047;) prevents a buffer overflow but does so by silently truncating user data. For a library function, this can lead to subtle and hard-to-debug issues. It would be better to either handle arbitrarily long strings (e.g., using dynamic memory allocation) or return an error if the input string is too long, as silent data corruption is dangerous.

iran_encoding/cli.py (44-45)

medium

While the usage of the --config argument is correctly removed here, its definition in the ArgumentParser setup (line 18 of the file) is now orphaned. To complete the removal of this deprecated feature, the argument definition should also be deleted from the CLI parser.

tests/test_iran_system_v1.py (40-61)

medium

This test's assertion on line 61 is too weak to be meaningful; it only checks the type of the output. To properly test the visual ordering, you should assert that the output matches the exact expected byte sequence.

        text = "سلام"
        encoded = encode(text, visual_ordering=True)
        # The expected visual order for "سلام" is 'م' 'ا' 'ل' 'س'
        expected_bytes = bytes([0xF4, 0x91, 0xF3, 0xA8])
        self.assertEqual(encoded, expected_bytes)

        decoded = decode(encoded)
        self.assertEqual(decoded, text)

google-labs-jules bot and others added 2 commits January 30, 2026 23:56
…on/C parity

- Implemented refined in-place Persian chunk reversal to better handle mixed English/Persian text.
- Ensured English and numbers remain in logical LTR order for visual terminal compatibility.
- Ported the full C logic to a pure Python core while maintaining a C performance fallback.
- Updated documentation (README and Wiki) in both English and Persian.
- Expanded test suite to cover mixed-text scenarios and verified 100% parity.
- Bumped version to 1.2.0.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Implemented Global RTL reversal with local chunk correction for LTR elements (English/Numbers).
- Fixed digit mapping collisions between Persian letters and digits in the script tables.
- Updated both Python and C engines to match the refined visual ordering logic.
- Improved `decode` to handle pure ASCII strings logically (without reversal).
- Verified with 45 tests covering mixed-text scenarios and Python/C parity.
- Synchronized documentation to reflect the advanced visual ordering behavior.

Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants